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.19 2007-03-20 19:31:29 kmorimatsu Exp $
18 * @version $NucleusJP: ADMIN.php,v 1.18 2007/03/19 10:21:41 shizuki 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 . " ($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.'">'.$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 . $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 . $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 . $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 . $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 . $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 = postVar('start');
847 // amount of items to show
848 if (postVar('amount'))
849 $amount = postVar('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 = postVar('start');
899 // amount of items to show
900 if (postVar('amount'))
901 $amount = postVar('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 = postVar('start');
940 // amount of items to show
941 if (postVar('amount'))
942 $amount = postVar('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 = postVar('start');
993 // amount of items to show
994 if (postVar('amount'))
995 $amount = postVar('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);
1169 ITEM::delete($draftid);
1172 $blogid = getBlogIDFromItemID($itemid);
1173 $blog =& $manager->getBlog($blogid);
1174 if (!$closed && $publish && $wasdraft && $blog->pingUserland()) {
1175 $this->action_sendping($blogid);
1179 // show category edit window when we created a new category
1180 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1181 if ($catid != intPostVar('catid')) {
1182 $this->action_categoryedit(
1185 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1188 // TODO: set start item correctly for itemlist
1189 $this->action_itemlist(getBlogIDFromItemID($itemid));
1194 * @todo document this
1196 function action_itemdelete() {
1197 global $member, $manager;
1199 $itemid = intRequestVar('itemid');
1201 // only allow if user is allowed to alter item
1202 $member->canAlterItem($itemid) or $this->disallow();
1204 if (!$manager->existsItem($itemid,1,1))
1205 $this->error(_ERROR_NOSUCHITEM);
1207 $item =& $manager->getItem($itemid,1,1);
1208 $title = htmlspecialchars(strip_tags($item['title']));
1209 $body = strip_tags($item['body']);
1210 $body = htmlspecialchars(shorten($body,300,'...'));
1214 <h2><?php echo _DELETE_CONFIRM?></h2>
1216 <p><?php echo _CONFIRMTXT_ITEM?></p>
1219 <b>"<?php echo $title ?>"</b>
1224 <form method="post" action="index.php"><div>
1225 <input type="hidden" name="action" value="itemdeleteconfirm" />
1226 <?php $manager->addTicketHidden() ?>
1227 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1228 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
1235 * @todo document this
1237 function action_itemdeleteconfirm() {
1240 $itemid = intRequestVar('itemid');
1242 // only allow if user is allowed to alter item
1243 $member->canAlterItem($itemid) or $this->disallow();
1246 $blogid = getBlogIdFromItemId($itemid);
1248 // delete item (note: some checks will be performed twice)
1249 $this->deleteOneItem($itemid);
1251 $this->action_itemlist($blogid);
1255 * Deletes one item and returns error if something goes wrong
1256 * @param int $itemid
1258 function deleteOneItem($itemid) {
1259 global $member, $manager;
1261 // only allow if user is allowed to alter item (also checks if itemid exists)
1262 if (!$member->canAlterItem($itemid))
1263 return _ERROR_DISALLOWED;
1265 $manager->loadClass('ITEM');
1266 ITEM::delete($itemid);
1270 * @todo document this
1272 function action_itemmove() {
1273 global $member, $manager;
1275 $itemid = intRequestVar('itemid');
1277 // only allow if user is allowed to alter item
1278 $member->canAlterItem($itemid) or $this->disallow();
1280 $item =& $manager->getItem($itemid,1,1);
1284 <h2><?php echo _MOVE_TITLE?></h2>
1285 <form method="post" action="index.php"><div>
1286 <input type="hidden" name="action" value="itemmoveto" />
1287 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1291 $manager->addTicketHidden();
1292 $this->selectBlogCategory('catid',$item['catid'],10,1);
1295 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1302 * @todo document this
1304 function action_itemmoveto() {
1305 global $member, $manager;
1307 $itemid = intRequestVar('itemid');
1308 $catid = requestVar('catid');
1310 // create new category if needed
1311 if (strstr($catid,'newcat')) {
1313 list($blogid) = sscanf($catid,'newcat-%d');
1316 $blog =& $manager->getBlog($blogid);
1317 $catid = $blog->createNewCategory();
1319 // show error when sth goes wrong
1321 $this->doError(_ERROR_CATCREATEFAIL);
1324 // only allow if user is allowed to alter item
1325 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1327 ITEM::move($itemid, $catid);
1329 if ($catid != intRequestVar('catid'))
1330 $this->action_categoryedit($catid, $blog->getID());
1332 $this->action_itemlist(getBlogIDFromCatID($catid));
1336 * Moves one item to a given category (category existance should be checked by caller)
1337 * errors are returned
1338 * @param int $itemid
1339 * @param int $destCatid category ID to which the item will be moved
1341 function moveOneItem($itemid, $destCatid) {
1344 // only allow if user is allowed to move item
1345 if (!$member->canUpdateItem($itemid, $destCatid))
1346 return _ERROR_DISALLOWED;
1348 ITEM::move($itemid, $destCatid);
1352 * Adds a item to the chosen blog
1354 function action_additem() {
1355 global $member, $manager, $CONF;
1357 $manager->loadClass('ITEM');
1359 $result = ITEM::createFromRequest();
1361 if ($result['status'] == 'error')
1362 $this->error($result['message']);
1364 $blogid = getBlogIDFromItemID($result['itemid']);
1365 $blog =& $manager->getBlog($blogid);
1367 $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
1369 if ($result['status'] == 'newcategory')
1370 $this->action_categoryedit(
1373 $blog->pingUserland() ? $pingUrl : ''
1375 elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland())
1376 $this->action_sendping($blogid);
1378 $this->action_itemlist($blogid);
1382 * Shows a window that says we're about to ping weblogs.com.
1383 * immediately refresh to the real pinging page, which will
1384 * show an error, or redirect to the blog.
1386 * @param int $blogid ID of blog for which ping needs to be sent out
1388 function action_sendping($blogid = -1) {
1389 global $member, $manager;
1392 $blogid = intRequestVar('blogid');
1394 $member->isLoggedIn() or $this->disallow();
1396 $rawPingUrl = $manager->addTicketToUrl('index.php?action=rawping&blogid=' . intval($blogid));
1398 $this->pagehead('<meta http-equiv="refresh" content="1; url='.htmlspecialchars($rawPingUrl).'" />');
1400 <h2>Site Updated, Now pinging weblogs.com</h2>
1403 Pinging weblogs.com! This can a while...
1405 When the ping is complete (and successfull), your weblog will show up in the weblogs.com updates list.
1409 If you aren't automatically passed through, <a href="index.php?action=rawping&blogid=<?php echo $blogid?>">try again</a>
1411 <?php $this->pagefoot();
1415 * Ping to Weblogs.com
1416 * Sends the real ping (can take up to 10 seconds!)
1418 function action_rawping() {
1422 $blogid = intRequestVar('blogid');
1423 $blog =& $manager->getBlog($blogid);
1425 $result = $blog->sendUserlandPing();
1431 <h2>Ping Results</h2>
1433 <p>The following message was returned by weblogs.com:</p>
1435 <div class='note'><?php echo $result ?></div>
1438 <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>
1439 <li><a href="<?php echo $blog->getURL()?>">Visit your own site</a></li>
1442 <?php $this->pagefoot();
1446 * Allows to edit previously made comments
1448 function action_commentedit() {
1449 global $member, $manager;
1451 $commentid = intRequestVar('commentid');
1453 $member->canAlterComment($commentid) or $this->disallow();
1455 $comment = COMMENT::getComment($commentid);
1457 $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
1459 // change <br /> to \n
1460 $comment['body'] = str_replace('<br />','',$comment['body']);
1462 $comment['body'] = eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>","\\1",$comment['body']);
1467 <h2><?php echo _EDITC_TITLE?></h2>
1469 <form action="index.php" method="post"><div>
1471 <input type="hidden" name="action" value="commentupdate" />
1472 <?php $manager->addTicketHidden(); ?>
1473 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1475 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1477 <td><?php echo _EDITC_WHO?></td>
1479 <?php if ($comment['member'])
1480 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1482 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1486 <td><?php echo _EDITC_WHEN?></td>
1487 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1489 <td><?php echo _EDITC_HOST?></td>
1490 <td><?php echo $comment['host']; ?></td>
1492 <td><?php echo _EDITC_TEXT?></td>
1494 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1495 echo $comment['body'];
1499 <td><?php echo _EDITC_EDIT?></td>
1500 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1509 * @todo document this
1511 function action_commentupdate() {
1512 global $member, $manager;
1514 $commentid = intRequestVar('commentid');
1516 $member->canAlterComment($commentid) or $this->disallow();
1518 $body = postVar('body');
1520 // intercept words that are too long
1521 if (eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}",$body) != false)
1522 $this->error(_ERROR_COMMENT_LONGWORD);
1525 if (strlen($body)<3)
1526 $this->error(_ERROR_COMMENT_NOCOMMENT);
1527 if (strlen($body)>5000)
1528 $this->error(_ERROR_COMMENT_TOOLONG);
1532 $body = COMMENT::prepareBody($body);
1535 $manager->notify('PreUpdateComment',array('body' => &$body));
1537 $query = 'UPDATE '.sql_table('comment')
1538 . " SET cbody='" .addslashes($body). "'"
1539 . " WHERE cnumber=" . $commentid;
1543 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1544 $o = mysql_fetch_object($res);
1545 $itemid = $o->citem;
1547 if ($member->canAlterItem($itemid))
1548 $this->action_itemcommentlist($itemid);
1550 $this->action_browseowncomments();
1555 * @todo document this
1557 function action_commentdelete() {
1558 global $member, $manager;
1560 $commentid = intRequestVar('commentid');
1562 $member->canAlterComment($commentid) or $this->disallow();
1564 $comment = COMMENT::getComment($commentid);
1566 $body = strip_tags($comment['body']);
1567 $body = htmlspecialchars(shorten($body, 300, '...'));
1569 if ($comment['member'])
1570 $author = $comment['member'];
1572 $author = $comment['user'];
1577 <h2><?php echo _DELETE_CONFIRM?></h2>
1579 <p><?php echo _CONFIRMTXT_COMMENT?></p>
1582 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
1584 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
1587 <form method="post" action="index.php"><div>
1588 <input type="hidden" name="action" value="commentdeleteconfirm" />
1589 <?php $manager->addTicketHidden() ?>
1590 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1591 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
1598 * @todo document this
1600 function action_commentdeleteconfirm() {
1603 $commentid = intRequestVar('commentid');
1605 // get item id first
1606 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1607 $o = mysql_fetch_object($res);
1608 $itemid = $o->citem;
1610 $error = $this->deleteOneComment($commentid);
1612 $this->doError($error);
1614 if ($member->canAlterItem($itemid))
1615 $this->action_itemcommentlist($itemid);
1617 $this->action_browseowncomments();
1621 * @todo document this
1623 function deleteOneComment($commentid) {
1624 global $member, $manager;
1626 $commentid = intval($commentid);
1628 if (!$member->canAlterComment($commentid))
1629 return _ERROR_DISALLOWED;
1631 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1633 // delete the comments associated with the item
1634 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1637 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1643 * Usermanagement main
1645 function action_usermanagement() {
1646 global $member, $manager;
1649 $member->isAdmin() or $this->disallow();
1653 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1655 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1657 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1659 // show list of members with actions
1661 . ' FROM '.sql_table('member');
1662 $template['content'] = 'memberlist';
1663 $template['tabindex'] = 10;
1665 $manager->loadClass("ENCAPSULATE");
1666 $batch =& new BATCH('member');
1667 $batch->showlist($query,'table',$template);
1669 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1671 <form method="post" action="index.php" name="memberedit"><div>
1673 <input type="hidden" name="action" value="memberadd" />
1674 <?php $manager->addTicketHidden() ?>
1678 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1680 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1681 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1683 <td><input tabindex="10010" name="name" size="16" maxlength="16" /></td>
1685 <td><?php echo _MEMBERS_REALNAME?></td>
1686 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1688 <td><?php echo _MEMBERS_PWD?></td>
1689 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1691 <td><?php echo _MEMBERS_REPPWD?></td>
1692 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1694 <td><?php echo _MEMBERS_EMAIL?></td>
1695 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1697 <td><?php echo _MEMBERS_URL?></td>
1698 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1700 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1701 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1703 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1704 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1706 <td><?php echo _MEMBERS_NOTES?></td>
1707 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1709 <td><?php echo _MEMBERS_NEW?></td>
1710 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1719 * Edit member settings
1721 function action_memberedit() {
1722 $this->action_editmembersettings(intRequestVar('memberid'));
1726 * @todo document this
1728 function action_editmembersettings($memberid = '') {
1729 global $member, $manager, $CONF;
1731 if ($memberid == '')
1732 $memberid = $member->getID();
1735 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1737 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1738 $this->pagehead($extrahead);
1740 // show message to go back to member overview (only for admins)
1741 if ($member->isAdmin())
1742 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1744 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1746 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1748 $mem = MEMBER::createFromID($memberid);
1751 <form method="post" action="index.php" name="memberedit"><div>
1753 <input type="hidden" name="action" value="changemembersettings" />
1754 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1755 <?php $manager->addTicketHidden() ?>
1758 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1760 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1761 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1764 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1765 <input name="name" tabindex="10" maxlength="16" size="16" value="<?php echo htmlspecialchars($mem->getDisplayName()); ?>" />
1767 echo htmlspecialchars($member->getDisplayName());
1772 <td><?php echo _MEMBERS_REALNAME?></td>
1773 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo htmlspecialchars($mem->getRealName()); ?>" /></td>
1775 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1776 <td><?php echo _MEMBERS_PWD?></td>
1777 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1779 <td><?php echo _MEMBERS_REPPWD?></td>
1780 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1783 <td><?php echo _MEMBERS_EMAIL?>
1784 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1786 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo htmlspecialchars($mem->getEmail()); ?>" /></td>
1788 <td><?php echo _MEMBERS_URL?></td>
1789 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getURL()); ?>" /></td>
1790 <?php // only allow to change this by super-admins
1791 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1792 if ($member->isAdmin()) {
1795 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1796 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1798 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1799 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1802 <td><?php echo _MEMBERS_NOTES?></td>
1803 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getNotes()); ?>" /></td>
1805 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
1809 <select name="deflang" tabindex="85">
1810 <option value=""><?php echo _MEMBERS_USESITELANG?></option>
1811 <?php // show a dropdown list of all available languages
1813 $dirhandle = opendir($DIR_LANG);
1814 while ($filename = readdir($dirhandle)) {
1815 if (ereg("^(.*)\.php$",$filename,$matches)) {
1816 $name = $matches[1];
1817 echo "<option value='$name'";
1818 if ($name == $mem->getLanguage())
1819 echo " selected='selected'";
1820 echo ">$name</option>";
1823 closedir($dirhandle);
1832 $this->_insertPluginOptions('member',$memberid);
1835 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1837 <td><?php echo _MEMBERS_EDIT?></td>
1838 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1844 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1847 'MemberSettingsFormExtras',
1857 * @todo document this
1859 function action_changemembersettings() {
1860 global $member, $CONF, $manager;
1862 $memberid = intRequestVar('memberid');
1865 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1867 $name = trim(strip_tags(postVar('name')));
1868 $realname = trim(strip_tags(postVar('realname')));
1869 $password = postVar('password');
1870 $repeatpassword = postVar('repeatpassword');
1871 $email = strip_tags(postVar('email'));
1872 $url = strip_tags(postVar('url'));
1874 // Sometimes user didn't prefix the URL with http://, this cause a malformed URL. Let's fix it.
1875 if (!eregi("^https?://", $url))
1876 $url = "http://".$url;
1878 $admin = postVar('admin');
1879 $canlogin = postVar('canlogin');
1880 $notes = strip_tags(postVar('notes'));
1881 $deflang = postVar('deflang');
1883 $mem = MEMBER::createFromID($memberid);
1885 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1887 if (!isValidDisplayName($name))
1888 $this->error(_ERROR_BADNAME);
1890 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1891 $this->error(_ERROR_NICKNAMEINUSE);
1893 if ($password != $repeatpassword)
1894 $this->error(_ERROR_PASSWORDMISMATCH);
1896 if ($password && (strlen($password) < 6))
1897 $this->error(_ERROR_PASSWORDTOOSHORT);
1900 if (!isValidMailAddress($email))
1901 $this->error(_ERROR_BADMAILADDRESS);
1905 $this->error(_ERROR_REALNAMEMISSING);
1907 if (($deflang != '') && (!checkLanguage($deflang)))
1908 $this->error(_ERROR_NOSUCHLANGUAGE);
1910 // check if there will remain at least one site member with both the logon and admin rights
1911 // (check occurs when taking away one of these rights from such a member)
1912 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
1913 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
1916 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
1917 if (mysql_num_rows($r) < 2)
1918 $this->error(_ERROR_ATLEASTONEADMIN);
1921 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1922 $mem->setDisplayName($name);
1924 $mem->setPassword($password);
1927 $oldEmail = $mem->getEmail();
1929 $mem->setRealName($realname);
1930 $mem->setEmail($email);
1932 $mem->setNotes($notes);
1933 $mem->setLanguage($deflang);
1936 // only allow super-admins to make changes to the admin status
1937 if ($member->isAdmin()) {
1938 $mem->setAdmin($admin);
1939 $mem->setCanLogin($canlogin);
1945 // store plugin options
1946 $aOptions = requestArray('plugoption');
1947 NucleusPlugin::_applyPluginOptions($aOptions);
1948 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
1950 // if email changed, generate new password
1951 if ($oldEmail != $mem->getEmail())
1953 $mem->sendActivationLink('addresschange', $oldEmail);
1955 $mem->newCookieKey();
1957 // only log out if the member being edited is the current member.
1958 if ($member->getID() == $memberid)
1960 $this->action_login(_MSG_ACTIVATION_SENT, 0);
1965 if ( ( $mem->getID() == $member->getID() )
1966 && ( $mem->getDisplayName() != $member->getDisplayName() )
1968 $mem->newCookieKey();
1970 $this->action_login(_MSG_LOGINAGAIN, 0);
1972 $this->action_overview(_MSG_SETTINGSCHANGED);
1977 * @todo document this
1979 function action_memberadd() {
1980 global $member, $manager;
1983 $member->isAdmin() or $this->disallow();
1985 if (postVar('password') != postVar('repeatpassword'))
1986 $this->error(_ERROR_PASSWORDMISMATCH);
1987 if (strlen(postVar('password')) < 6)
1988 $this->error(_ERROR_PASSWORDTOOSHORT);
1990 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
1994 // fire PostRegister event
1995 $newmem = new MEMBER();
1996 $newmem->readFromName(postVar('name'));
1997 $manager->notify('PostRegister',array('member' => &$newmem));
1999 $this->action_usermanagement();
2003 * Account activation
2007 function action_activate() {
2009 $key = getVar('key');
2010 $this->_showActivationPage($key);
2014 * @todo document this
2016 function _showActivationPage($key, $message = '')
2020 // clean up old activation keys
2021 MEMBER::cleanupActivationTable();
2023 // get activation info
2024 $info = MEMBER::getActivationInfo($key);
2027 $this->error(_ERROR_ACTIVATE);
2029 $mem = MEMBER::createFromId($info->vmember);
2032 $this->error(_ERROR_ACTIVATE);
2036 $bNeedsPasswordChange = true;
2038 switch ($info->vtype)
2041 $title = _ACTIVATE_FORGOT_TITLE;
2042 $text = _ACTIVATE_FORGOT_TEXT;
2045 $title = _ACTIVATE_REGISTER_TITLE;
2046 $text = _ACTIVATE_REGISTER_TEXT;
2048 case 'addresschange':
2049 $title = _ACTIVATE_CHANGE_TITLE;
2050 $text = _ACTIVATE_CHANGE_TEXT;
2051 $bNeedsPasswordChange = false;
2052 MEMBER::activate($key);
2057 'memberName' => htmlspecialchars($mem->getDisplayName())
2059 $title = TEMPLATE::fill($title, $aVars);
2060 $text = TEMPLATE::fill($text, $aVars);
2064 echo '<h2>' , $title, '</h2>';
2065 echo '<p>' , $text, '</p>';
2069 echo '<p class="error">',$message,'</p>';
2072 if ($bNeedsPasswordChange)
2075 <div><form action="index.php" method="post">
2077 <input type="hidden" name="action" value="activatesetpwd" />
2078 <?php $manager->addTicketHidden() ?>
2079 <input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />
2082 <td><?php echo _MEMBERS_PWD?></td>
2083 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2085 <td><?php echo _MEMBERS_REPPWD?></td>
2086 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2090 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2094 <td><?php echo _MEMBERS_SETPWD ?></td>
2095 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2110 * Account activation - set password part
2114 function action_activatesetpwd() {
2116 $key = postVar('key');
2118 // clean up old activation keys
2119 MEMBER::cleanupActivationTable();
2121 // get activation info
2122 $info = MEMBER::getActivationInfo($key);
2124 if (!$info || ($info->type == 'addresschange'))
2125 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2127 $mem = MEMBER::createFromId($info->vmember);
2130 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2132 $password = postVar('password');
2133 $repeatpassword = postVar('repeatpassword');
2135 if ($password != $repeatpassword)
2136 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2138 if ($password && (strlen($password) < 6))
2139 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2143 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2145 return $this->_showActivationPage($key, $error);
2149 $mem->setPassword($password);
2152 // do the activation
2153 MEMBER::activate($key);
2156 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2157 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2164 function action_manageteam() {
2165 global $member, $manager;
2167 $blogid = intRequestVar('blogid');
2170 $member->blogAdminRights($blogid) or $this->disallow();
2174 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2176 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2178 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2182 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2183 . ' FROM '.sql_table('member').', '.sql_table('team')
2184 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2186 $template['content'] = 'teamlist';
2187 $template['tabindex'] = 10;
2189 $manager->loadClass("ENCAPSULATE");
2190 $batch =& new BATCH('team');
2191 $batch->showlist($query, 'table', $template);
2194 <h3><?php echo _TEAM_ADDNEW?></h3>
2196 <form method='post' action='index.php'><div>
2198 <input type='hidden' name='action' value='teamaddmember' />
2199 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2200 <?php $manager->addTicketHidden() ?>
2203 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2204 <td><?php // TODO: try to make it so only non-team-members are listed
2205 $query = 'SELECT mname as text, mnumber as value'
2206 . ' FROM '.sql_table('member');
2208 $template['name'] = 'memberid';
2209 $template['tabindex'] = 10000;
2210 showlist($query,'select',$template);
2213 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2214 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2216 <td><?php echo _TEAM_ADD?></td>
2217 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2226 * Add member to team
2228 function action_teamaddmember() {
2229 global $member, $manager;
2231 $memberid = intPostVar('memberid');
2232 $blogid = intPostVar('blogid');
2233 $admin = intPostVar('admin');
2236 $member->blogAdminRights($blogid) or $this->disallow();
2238 $blog =& $manager->getBlog($blogid);
2239 if (!$blog->addTeamMember($memberid, $admin))
2240 $this->error(_ERROR_ALREADYONTEAM);
2242 $this->action_manageteam();
2247 * @todo document this
2249 function action_teamdelete() {
2250 global $member, $manager;
2252 $memberid = intRequestVar('memberid');
2253 $blogid = intRequestVar('blogid');
2256 $member->blogAdminRights($blogid) or $this->disallow();
2258 $teammem = MEMBER::createFromID($memberid);
2259 $blog =& $manager->getBlog($blogid);
2263 <h2><?php echo _DELETE_CONFIRM?></h2>
2265 <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo $teammem->getDisplayName() ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo htmlspecialchars(strip_tags($blog->getName())) ?></b>
2269 <form method="post" action="index.php"><div>
2270 <input type="hidden" name="action" value="teamdeleteconfirm" />
2271 <?php $manager->addTicketHidden() ?>
2272 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2273 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2274 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2281 * @todo document this
2283 function action_teamdeleteconfirm() {
2286 $memberid = intRequestVar('memberid');
2287 $blogid = intRequestVar('blogid');
2289 $error = $this->deleteOneTeamMember($blogid, $memberid);
2291 $this->error($error);
2294 $this->action_manageteam();
2298 * @todo document this
2300 function deleteOneTeamMember($blogid, $memberid) {
2301 global $member, $manager;
2303 $blogid = intval($blogid);
2304 $memberid = intval($memberid);
2307 if (!$member->blogAdminRights($blogid))
2308 return _ERROR_DISALLOWED;
2310 // check if: - there remains at least one blog admin
2311 // - (there remains at least one team member)
2312 $tmem = MEMBER::createFromID($memberid);
2314 $manager->notify('PreDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
2316 if ($tmem->isBlogAdmin($blogid)) {
2317 // check if there are more blog members left and at least one admin
2318 // (check for at least two admins before deletion)
2319 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2320 $r = sql_query($query);
2321 if (mysql_num_rows($r) < 2)
2322 return _ERROR_ATLEASTONEBLOGADMIN;
2325 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2328 $manager->notify('PostDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
2334 * @todo document this
2336 function action_teamchangeadmin() {
2339 $blogid = intRequestVar('blogid');
2340 $memberid = intRequestVar('memberid');
2343 $member->blogAdminRights($blogid) or $this->disallow();
2345 $mem = MEMBER::createFromID($memberid);
2347 // don't allow when there is only one admin at this moment
2348 if ($mem->isBlogAdmin($blogid)) {
2349 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2350 if (mysql_num_rows($r) == 1)
2351 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2354 if ($mem->isBlogAdmin($blogid))
2359 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2362 // only show manageteam if member did not change its own admin privileges
2363 if ($member->isBlogAdmin($blogid))
2364 $this->action_manageteam();
2366 $this->action_overview(_MSG_ADMINCHANGED);
2370 * @todo document this
2372 function action_blogsettings() {
2373 global $member, $manager;
2375 $blogid = intRequestVar('blogid');
2378 $member->blogAdminRights($blogid) or $this->disallow();
2380 $blog =& $manager->getBlog($blogid);
2382 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2383 $this->pagehead($extrahead);
2385 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2387 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2389 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2391 <p>Members currently on your team:
2393 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2394 $aMemberNames = array();
2395 while ($o = mysql_fetch_object($res))
2396 array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');
2397 echo implode(',', $aMemberNames);
2404 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2407 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2409 <form method="post" action="index.php"><div>
2411 <input type="hidden" name="action" value="blogsettingsupdate" />
2412 <?php $manager->addTicketHidden() ?>
2413 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2415 <td><?php echo _EBLOG_NAME?></td>
2416 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getName()) ?>" /></td>
2418 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2419 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2421 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo htmlspecialchars($blog->getShortName()) ?>" /></td>
2423 <td><?php echo _EBLOG_DESC?></td>
2424 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo htmlspecialchars($blog->getDescription()) ?>" /></td>
2426 <td><?php echo _EBLOG_URL?></td>
2427 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo htmlspecialchars($blog->getURL()) ?>" /></td>
2429 <td><?php echo _EBLOG_DEFSKIN?>
2430 <?php help('blogdefaultskin'); ?>
2434 $query = 'SELECT sdname as text, sdnumber as value'
2435 . ' FROM '.sql_table('skin_desc');
2436 $template['name'] = 'defskin';
2437 $template['selected'] = $blog->getDefaultSkin();
2438 $template['tabindex'] = 50;
2439 showlist($query,'select',$template);
2444 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2446 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2448 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2450 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2452 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2454 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2456 <td><?php echo _EBLOG_ANONYMOUS?>
2458 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2460 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2462 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2464 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2465 <td><input name="notify" tabindex="80" maxlength="60" size="40" value="<?php echo htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>
2467 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2469 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2470 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2471 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2473 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2474 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2475 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2477 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2478 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2479 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2482 <td><?php echo _EBLOG_PING?> <?php help('pinguserland'); ?></td>
2483 <td><?php $this->input_yesno('pinguserland',$blog->pingUserland(),85); ?></td>
2485 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2486 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo htmlspecialchars($blog->getMaxComments()); ?>" /></td>
2488 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2489 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getUpdateFile()) ?>" /></td>
2491 <td><?php echo _EBLOG_DEFCAT?></td>
2494 $query = 'SELECT cname as text, catid as value'
2495 . ' FROM '.sql_table('category')
2496 . ' WHERE cblog=' . $blog->getID();
2497 $template['name'] = 'defcat';
2498 $template['selected'] = $blog->getDefaultCategory();
2499 $template['tabindex'] = 110;
2500 showlist($query,'select',$template);
2504 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2505 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
2506 <br /><?php echo _EBLOG_BTIME?> <b><?php echo strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2508 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo htmlspecialchars($blog->getTimeOffset()); ?>" /></td>
2510 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2511 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2515 $this->_insertPluginOptions('blog',$blogid);
2518 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2520 <td><?php echo _EBLOG_CHANGE?></td>
2521 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2526 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2530 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2531 $template['content'] = 'categorylist';
2532 $template['tabindex'] = 200;
2534 $manager->loadClass("ENCAPSULATE");
2535 $batch =& new BATCH('category');
2536 $batch->showlist($query,'table',$template);
2541 <form action="index.php" method="post"><div>
2542 <input name="action" value="categorynew" type="hidden" />
2543 <?php $manager->addTicketHidden() ?>
2544 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2547 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2549 <td><?php echo _EBLOG_CAT_NAME?></td>
2550 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2552 <td><?php echo _EBLOG_CAT_DESC?></td>
2553 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2555 <td><?php echo _EBLOG_CAT_CREATE?></td>
2556 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2563 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2566 'BlogSettingsFormExtras',
2576 * @todo document this
2578 function action_categorynew() {
2579 global $member, $manager;
2581 $blogid = intRequestVar('blogid');
2583 $member->blogAdminRights($blogid) or $this->disallow();
2585 $cname = postVar('cname');
2586 $cdesc = postVar('cdesc');
2588 if (!isValidCategoryName($cname))
2589 $this->error(_ERROR_BADCATEGORYNAME);
2591 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid);
2592 $res = sql_query($query);
2593 if (mysql_num_rows($res) > 0)
2594 $this->error(_ERROR_DUPCATEGORYNAME);
2596 $blog =& $manager->getBlog($blogid);
2597 $newCatID = $blog->createNewCategory($cname, $cdesc);
2599 $this->action_blogsettings();
2603 * @todo document this
2605 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2606 global $member, $manager;
2609 $blogid = intGetVar('blogid');
2611 $blogid = intval($blogid);
2613 $catid = intGetVar('catid');
2615 $catid = intval($catid);
2617 $member->blogAdminRights($blogid) or $this->disallow();
2619 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2620 $obj = mysql_fetch_object($res);
2622 $cname = $obj->cname;
2623 $cdesc = $obj->cdesc;
2625 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2626 $this->pagehead($extrahead);
2628 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2631 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>
2632 <form method='post' action='index.php'><div>
2633 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2634 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2635 <input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />
2636 <input name="action" type="hidden" value="categoryupdate" />
2637 <?php $manager->addTicketHidden(); ?>
2640 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2642 <td><?php echo _EBLOG_CAT_NAME?></td>
2643 <td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>
2645 <td><?php echo _EBLOG_CAT_DESC?></td>
2646 <td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>
2649 // insert plugin options
2650 $this->_insertPluginOptions('category',$catid);
2653 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2655 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2656 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2665 * @todo document this
2667 function action_categoryupdate() {
2668 global $member, $manager;
2670 $blogid = intPostVar('blogid');
2671 $catid = intPostVar('catid');
2672 $cname = postVar('cname');
2673 $cdesc = postVar('cdesc');
2674 $desturl = postVar('desturl');
2676 $member->blogAdminRights($blogid) or $this->disallow();
2678 if (!isValidCategoryName($cname))
2679 $this->error(_ERROR_BADCATEGORYNAME);
2681 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2682 $res = sql_query($query);
2683 if (mysql_num_rows($res) > 0)
2684 $this->error(_ERROR_DUPCATEGORYNAME);
2686 $query = 'UPDATE '.sql_table('category').' SET'
2687 . " cname='" . addslashes($cname) . "',"
2688 . " cdesc='" . addslashes($cdesc) . "'"
2689 . " WHERE catid=" . $catid;
2693 // store plugin options
2694 $aOptions = requestArray('plugoption');
2695 NucleusPlugin::_applyPluginOptions($aOptions);
2696 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2703 $this->action_blogsettings();
2708 * @todo document this
2710 function action_categorydelete() {
2711 global $member, $manager;
2713 $blogid = intRequestVar('blogid');
2714 $catid = intRequestVar('catid');
2716 $member->blogAdminRights($blogid) or $this->disallow();
2718 $blog =& $manager->getBlog($blogid);
2720 // check if the category is valid
2721 if (!$blog->isValidCategory($catid))
2722 $this->error(_ERROR_NOSUCHCATEGORY);
2724 // don't allow deletion of default category
2725 if ($blog->getDefaultCategory() == $catid)
2726 $this->error(_ERROR_DELETEDEFCATEGORY);
2728 // check if catid is the only category left for blogid
2729 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2730 $res = sql_query($query);
2731 if (mysql_num_rows($res) == 1)
2732 $this->error(_ERROR_DELETELASTCATEGORY);
2737 <h2><?php echo _DELETE_CONFIRM?></h2>
2740 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo $blog->getCategoryName($catid)?></b>
2743 <form method="post" action="index.php"><div>
2744 <input type="hidden" name="action" value="categorydeleteconfirm" />
2745 <?php $manager->addTicketHidden() ?>
2746 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2747 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2748 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2755 * @todo document this
2757 function action_categorydeleteconfirm() {
2758 global $member, $manager;
2760 $blogid = intRequestVar('blogid');
2761 $catid = intRequestVar('catid');
2763 $member->blogAdminRights($blogid) or $this->disallow();
2765 $error = $this->deleteOneCategory($catid);
2767 $this->error($error);
2769 $this->action_blogsettings();
2773 * @todo document this
2775 function deleteOneCategory($catid) {
2776 global $manager, $member;
2778 $catid = intval($catid);
2780 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2782 $blogid = getBlogIDFromCatID($catid);
2784 if (!$member->blogAdminRights($blogid))
2785 return ERROR_DISALLOWED;
2788 $blog =& $manager->getBlog($blogid);
2790 // check if the category is valid
2791 if (!$blog || !$blog->isValidCategory($catid))
2792 return _ERROR_NOSUCHCATEGORY;
2794 $destcatid = $blog->getDefaultCategory();
2796 // don't allow deletion of default category
2797 if ($blog->getDefaultCategory() == $catid)
2798 return _ERROR_DELETEDEFCATEGORY;
2800 // check if catid is the only category left for blogid
2801 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2802 $res = sql_query($query);
2803 if (mysql_num_rows($res) == 1)
2804 return _ERROR_DELETELASTCATEGORY;
2806 // change category for all items to the default category
2807 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2810 // delete all associated plugin options
2811 NucleusPlugin::_deleteOptionValues('category', $catid);
2814 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2817 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2822 * @todo document this
2824 function moveOneCategory($catid, $destblogid) {
2825 global $manager, $member;
2827 $catid = intval($catid);
2828 $destblogid = intval($destblogid);
2830 $blogid = getBlogIDFromCatID($catid);
2832 // mover should have admin rights on both blogs
2833 if (!$member->blogAdminRights($blogid))
2834 return _ERROR_DISALLOWED;
2835 if (!$member->blogAdminRights($destblogid))
2836 return _ERROR_DISALLOWED;
2838 // cannot move to self
2839 if ($blogid == $destblogid)
2840 return _ERROR_MOVETOSELF;
2843 $blog =& $manager->getBlog($blogid);
2844 $destblog =& $manager->getBlog($destblogid);
2846 // check if the category is valid
2847 if (!$blog || !$blog->isValidCategory($catid))
2848 return _ERROR_NOSUCHCATEGORY;
2850 // don't allow default category to be moved
2851 if ($blog->getDefaultCategory() == $catid)
2852 return _ERROR_MOVEDEFCATEGORY;
2858 'sourceblog' => &$blog,
2859 'destblog' => &$destblog
2863 // update comments table (cblog)
2864 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
2865 $items = sql_query($query);
2866 while ($oItem = mysql_fetch_object($items)) {
2867 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
2870 // update items (iblog)
2871 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
2875 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
2882 'sourceblog' => &$blog,
2883 'destblog' => $destblog
2890 * @todo document this
2892 function action_blogsettingsupdate() {
2893 global $member, $manager;
2895 $blogid = intRequestVar('blogid');
2897 $member->blogAdminRights($blogid) or $this->disallow();
2899 $blog =& $manager->getBlog($blogid);
2901 $notify = trim(postVar('notify'));
2902 $shortname = trim(postVar('shortname'));
2903 $updatefile = trim(postVar('update'));
2905 $notifyComment = intPostVar('notifyComment');
2906 $notifyVote = intPostVar('notifyVote');
2907 $notifyNewItem = intPostVar('notifyNewItem');
2909 if ($notifyComment == 0) $notifyComment = 1;
2910 if ($notifyVote == 0) $notifyVote = 1;
2911 if ($notifyNewItem == 0) $notifyNewItem = 1;
2913 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
2917 $not =& new NOTIFICATION($notify);
2918 if (!$not->validAddresses())
2919 $this->error(_ERROR_BADNOTIFY);
2923 if (!isValidShortName($shortname))
2924 $this->error(_ERROR_BADSHORTBLOGNAME);
2926 if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
2927 $this->error(_ERROR_DUPSHORTBLOGNAME);
2929 // check if update file is writable
2930 if ($updatefile && !is_writeable($updatefile))
2931 $this->error(_ERROR_UPDATEFILE);
2933 $blog->setName(trim(postVar('name')));
2934 $blog->setShortName($shortname);
2935 $blog->setNotifyAddress($notify);
2936 $blog->setNotifyType($notifyType);
2937 $blog->setMaxComments(postVar('maxcomments'));
2938 $blog->setCommentsEnabled(postVar('comments'));
2939 $blog->setTimeOffset(postVar('timeoffset'));
2940 $blog->setUpdateFile($updatefile);
2941 $blog->setURL(trim(postVar('url')));
2942 $blog->setDefaultSkin(intPostVar('defskin'));
2943 $blog->setDescription(trim(postVar('desc')));
2944 $blog->setPublic(postVar('public'));
2945 $blog->setPingUserland(postVar('pinguserland'));
2946 $blog->setConvertBreaks(intPostVar('convertbreaks'));
2947 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
2948 $blog->setDefaultCategory(intPostVar('defcat'));
2949 $blog->setSearchable(intPostVar('searchable'));
2950 $blog->setEmailRequired(intPostVar('reqemail'));
2952 $blog->writeSettings();
2954 // store plugin options
2955 $aOptions = requestArray('plugoption');
2956 NucleusPlugin::_applyPluginOptions($aOptions);
2957 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
2960 $this->action_overview(_MSG_SETTINGSCHANGED);
2964 * @todo document this
2966 function action_deleteblog() {
2967 global $member, $CONF, $manager;
2969 $blogid = intRequestVar('blogid');
2971 $member->blogAdminRights($blogid) or $this->disallow();
2973 // check if blog is default blog
2974 if ($CONF['DefaultBlog'] == $blogid)
2975 $this->error(_ERROR_DELDEFBLOG);
2977 $blog =& $manager->getBlog($blogid);
2981 <h2><?php echo _DELETE_CONFIRM?></h2>
2983 <p><?php echo _WARNINGTXT_BLOGDEL?>
2987 <?php echo _CONFIRMTXT_BLOG?><b><?php echo htmlspecialchars($blog->getName())?></b>
2990 <form method="post" action="index.php"><div>
2991 <input type="hidden" name="action" value="deleteblogconfirm" />
2992 <?php $manager->addTicketHidden() ?>
2993 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2994 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3001 * @todo document this
3003 function action_deleteblogconfirm() {
3004 global $member, $CONF, $manager;
3006 $blogid = intRequestVar('blogid');
3008 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3010 $member->blogAdminRights($blogid) or $this->disallow();
3012 // check if blog is default blog
3013 if ($CONF['DefaultBlog'] == $blogid)
3014 $this->error(_ERROR_DELDEFBLOG);
3016 // delete all comments
3017 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3021 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3024 // delete all team members
3025 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3029 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3032 // delete all categories
3033 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3036 // delete all associated plugin options
3037 NucleusPlugin::_deleteOptionValues('blog', $blogid);
3039 // delete the blog itself
3040 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3043 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3045 $this->action_overview(_DELETED_BLOG);
3049 * @todo document this
3051 function action_memberdelete() {
3052 global $member, $manager;
3054 $memberid = intRequestVar('memberid');
3056 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3058 $mem = MEMBER::createFromID($memberid);
3062 <h2><?php echo _DELETE_CONFIRM?></h2>
3064 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo $mem->getDisplayName() ?></b>
3068 Please note that media files will <b>NOT</b> be deleted. (At least not in this Nucleus version)
3071 <form method="post" action="index.php"><div>
3072 <input type="hidden" name="action" value="memberdeleteconfirm" />
3073 <?php $manager->addTicketHidden() ?>
3074 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3075 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3082 * @todo document this
3084 function action_memberdeleteconfirm() {
3087 $memberid = intRequestVar('memberid');
3089 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3091 $error = $this->deleteOneMember($memberid);
3093 $this->error($error);
3095 if ($member->isAdmin())
3096 $this->action_usermanagement();
3098 $this->action_overview(_DELETED_MEMBER);
3103 * @todo document this
3105 function deleteOneMember($memberid) {
3108 $memberid = intval($memberid);
3109 $mem = MEMBER::createFromID($memberid);
3111 if (!$mem->canBeDeleted())
3112 return _ERROR_DELETEMEMBER;
3114 $manager->notify('PreDeleteMember', array('member' => &$mem));
3116 /* unlink comments from memberid */
3117 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. addslashes($mem->getDisplayName())
3118 .'" WHERE cmember='.$memberid;
3121 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3124 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3127 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3130 // delete all associated plugin options
3131 NucleusPlugin::_deleteOptionValues('member', $memberid);
3133 $manager->notify('PostDeleteMember', array('member' => &$mem));
3139 * @todo document this
3141 function action_createnewlog() {
3142 global $member, $CONF, $manager;
3144 // Only Super-Admins can do this
3145 $member->isAdmin() or $this->disallow();
3149 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3151 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3155 <p>作成にあたって、下記の<strong>注意事項</strong> をまずお読み下さい</p>
3157 <p>新しいweblogを作成した後に、このblogにアクセスするための方法を紹介しておきます。方法は2つあります:</p>
3160 <li><strong>簡単な方法:</strong> <code>index.php</code>の複製を作り、新しいblogを表示するように変更を加えます。 この変更の詳細は、作成後に表示されます。</li>
3161 <li><strong>高度な方法:</strong> 現在のblogで使用しているスキンに<code>otherblog</code>というコードを使った記述を加えます。この方法では、同じページ内で複数のblogを展開することが可能となります。</li>
3167 <?php echo _EBLOG_CREATE_TEXT?>
3170 <form method="post" action="index.php"><div>
3172 <input type="hidden" name="action" value="addnewlog" />
3173 <?php $manager->addTicketHidden() ?>
3177 <td><?php echo _EBLOG_NAME?></td>
3178 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3180 <td><?php echo _EBLOG_SHORTNAME?>
3181 <?php help('shortblogname'); ?>
3183 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3185 <td><?php echo _EBLOG_DESC?></td>
3186 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3188 <td><?php echo _EBLOG_DEFSKIN?>
3189 <?php help('blogdefaultskin'); ?>
3193 $query = 'SELECT sdname as text, sdnumber as value'
3194 . ' FROM '.sql_table('skin_desc');
3195 $template['name'] = 'defskin';
3196 $template['tabindex'] = 50;
3197 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3198 showlist($query,'select',$template);
3202 <td><?php echo _EBLOG_OFFSET?>
3203 <?php help('blogtimeoffset'); ?>
3204 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
3206 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3208 <td><?php echo _EBLOG_ADMIN?>
3209 <?php help('teamadmin'); ?>
3211 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3213 <td><?php echo _EBLOG_CREATE?></td>
3214 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3223 * @todo document this
3225 function action_addnewlog() {
3226 global $member, $manager, $CONF;
3228 // Only Super-Admins can do this
3229 $member->isAdmin() or $this->disallow();
3231 $bname = trim(postVar('name'));
3232 $bshortname = trim(postVar('shortname'));
3233 $btimeoffset = postVar('timeoffset');
3234 $bdesc = trim(postVar('desc'));
3235 $bdefskin = postVar('defskin');
3237 if (!isValidShortName($bshortname))
3238 $this->error(_ERROR_BADSHORTBLOGNAME);
3240 if ($manager->existsBlog($bshortname))
3241 $this->error(_ERROR_DUPSHORTBLOGNAME);
3247 'shortname' => &$bshortname,
3248 'timeoffset' => &$btimeoffset,
3249 'description' => &$bdescription,
3250 'defaultskin' => &$bdefskin
3255 // add slashes for sql queries
3256 $bname = addslashes($bname);
3257 $bshortname = addslashes($bshortname);
3258 $btimeoffset = addslashes($btimeoffset);
3259 $bdesc = addslashes($bdesc);
3260 $bdefskin = addslashes($bdefskin);
3263 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3265 $blogid = mysql_insert_id();
3266 $blog =& $manager->getBlog($blogid);
3268 // create new category
3269 sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, 'General','Items that do not fit in other categories')");
3270 $catid = mysql_insert_id();
3272 // set as default category
3273 $blog->setDefaultCategory($catid);
3274 $blog->writeSettings();
3276 // create team member
3277 $memberid = $member->getID();
3278 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3282 $blog->additem($blog->getDefaultCategory(),'First Item','これはあなたのweblogにおける最初のアイテムです。自由に削除していただいてかまいません。','',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3295 'name' => 'General',
3296 'description' => 'Items that do not fit in other categories',
3303 <h2>新しいweblogが作成されました</h2>
3305 <p>新しいweblog 「<?php echo htmlspecialchars($bname)?>」が作成されました。続けて、これにアクセスするために以下のどちらかの手順に進んでください。</p>
3308 <li><a href="#index_php">簡単な方法: 下のコードを貼付けた <code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成する</a></li>
3309 <li><a href="#skins">高度な方法: 現在使用しているスキンに新しいweblogを展開させるための記述を加える</a></li>
3312 <h3><a id="index_php">方法 1: <code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成</a></h3>
3314 <p><code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成して、中身に以下のコードを貼り付ける:</p>
3317 $CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';
3319 include('<i>./config.php</i>');
3321 selectBlog('<b><?php echo htmlspecialchars($bshortname)?></b>');
3326 <p>すでにある<code>index.php</code>と同じディレクトリにアップロードします。</p>
3328 <p>新しいweblogの作成を完了するためには、下にこのファイルのURLを入力してください。 (すでに用意した値で合っているとは思いますが保証はしません):</p>
3330 <form action="index.php" method="post"><div>
3331 <input type="hidden" name="action" value="addnewlog2" />
3332 <?php $manager->addTicketHidden() ?>
3333 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3335 <td><?php echo _EBLOG_URL?></td>
3336 <td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3338 <td><?php echo _EBLOG_CREATE?></td>
3339 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3343 <h3><a id="skins">方法 2: 現在使用しているスキンに新しいweblogを展開する記述を加える</a></h3>
3345 <p>新しいweblogの作成を完了するためには、下にURLを入力してください。 (大抵は既存blogと同じURL)</p>
3347 <form action="index.php" method="post"><div>
3348 <input type="hidden" name="action" value="addnewlog2" />
3349 <?php $manager->addTicketHidden() ?>
3350 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3352 <td><?php echo _EBLOG_URL?></td>
3353 <td><input name="url" maxlength="100" size="40" /></td>
3355 <td><?php echo _EBLOG_CREATE?></td>
3356 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3360 <?php $this->pagefoot();
3365 * @todo document this
3367 function action_addnewlog2() {
3368 global $member, $manager;
3370 $member->blogAdminRights($blogid) or $this->disallow();
3372 $burl = requestVar('url');
3373 $blogid = intRequestVar('blogid');
3375 $blog =& $manager->getBlog($blogid);
3376 $blog->setURL(trim($burl));
3377 $blog->writeSettings();
3379 $this->action_overview(_MSG_NEWBLOG);
3383 * @todo document this
3385 function action_skinieoverview() {
3386 global $member, $DIR_LIBS, $manager;
3388 $member->isAdmin() or $this->disallow();
3390 // load skinie class
3391 include_once($DIR_LIBS . 'skinie.php');
3395 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3398 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3400 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3401 <?php global $DIR_SKINS;
3403 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3405 if (sizeof($candidates) > 0) {
3407 <form method="post" action="index.php"><div>
3408 <input type="hidden" name="action" value="skinieimport" />
3409 <?php $manager->addTicketHidden() ?>
3410 <input type="hidden" name="mode" value="file" />
3411 <select name="skinfile" id="skinie_import_local">
3412 <?php foreach ($candidates as $skinname => $skinfile) {
3413 $html = htmlspecialchars($skinfile);
3414 echo '<option value="',$html,'">',$skinname,'</option>';
3418 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3421 echo _SKINIE_NOCANDIDATES;
3426 <p><em><?php echo _OR?></em></p>
3428 <form method="post" action="index.php"><p>
3429 <?php $manager->addTicketHidden() ?>
3430 <input type="hidden" name="action" value="skinieimport" />
3431 <input type="hidden" name="mode" value="url" />
3432 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3433 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3434 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3438 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3439 <form method="post" action="index.php"><div>
3440 <input type="hidden" name="action" value="skinieexport" />
3441 <?php $manager->addTicketHidden() ?>
3443 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3446 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3448 <?php // show list of skins
3449 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3450 while ($skinObj = mysql_fetch_object($res)) {
3451 $id = 'skinexp' . $skinObj->sdnumber;
3452 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3453 echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';
3454 echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';
3458 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3460 // show list of templates
3461 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3462 while ($templateObj = mysql_fetch_object($res)) {
3463 $id = 'templateexp' . $templateObj->tdnumber;
3464 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3465 echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';
3466 echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';
3471 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3473 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3475 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3477 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3487 * @todo document this
3489 function action_skinieimport() {
3490 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3492 $member->isAdmin() or $this->disallow();
3494 // load skinie class
3495 include_once($DIR_LIBS . 'skinie.php');
3497 $skinFileRaw= postVar('skinfile');
3498 $mode = postVar('mode');
3500 $importer =& new SKINIMPORT();
3502 // get full filename
3503 if ($mode == 'file')
3505 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3507 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3508 if (!file_exists($skinFile))
3509 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3511 $skinFile = $skinFileRaw;
3514 // read only metadata
3515 $error = $importer->readFile($skinFile, 1);
3518 $skinNameClashes = $importer->checkSkinNameClashes();
3519 $templateNameClashes = $importer->checkTemplateNameClashes();
3520 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3522 if ($error) $this->error($error);
3526 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3528 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3531 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
3532 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3533 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3535 if ($hasNameClashes)
3538 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3539 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3541 } // if (hasNameClashes)
3545 <form method="post" action="index.php"><div>
3546 <input type="hidden" name="action" value="skiniedoimport" />
3547 <?php $manager->addTicketHidden() ?>
3548 <input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />
3549 <input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />
3550 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3552 if ($hasNameClashes)
3556 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3558 } // if (hasNameClashes)
3568 * @todo document this
3570 function action_skiniedoimport() {
3571 global $member, $DIR_LIBS, $DIR_SKINS;
3573 $member->isAdmin() or $this->disallow();
3575 // load skinie class
3576 include_once($DIR_LIBS . 'skinie.php');
3578 $skinFileRaw= postVar('skinfile');
3579 $mode = postVar('mode');
3581 $allowOverwrite = intPostVar('overwrite');
3583 // get full filename
3584 if ($mode == 'file')
3586 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3588 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3589 if (!file_exists($skinFile))
3590 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3593 $skinFile = $skinFileRaw;
3596 $importer =& new SKINIMPORT();
3598 $error = $importer->readFile($skinFile);
3601 $this->error($error);
3603 $error = $importer->writeToDatabase($allowOverwrite);
3606 $this->error($error);
3610 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3612 <h2><?php echo _SKINIE_DONE?></h2>
3615 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
3616 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3617 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3620 <?php $this->pagefoot();
3625 * @todo document this
3627 function action_skinieexport() {
3628 global $member, $DIR_LIBS;
3630 $member->isAdmin() or $this->disallow();
3632 // load skinie class
3633 include_once($DIR_LIBS . 'skinie.php');
3635 $aSkins = requestIntArray('skin');
3636 $aTemplates = requestIntArray('template');
3638 if (!is_array($aTemplates)) $aTemplates = array();
3639 if (!is_array($aSkins)) $aSkins = array();
3641 $skinList = array_keys($aSkins);
3642 $templateList = array_keys($aTemplates);
3644 $info = postVar('info');
3646 $exporter =& new SKINEXPORT();
3647 foreach ($skinList as $skinId) {
3648 $exporter->addSkin($skinId);
3650 foreach ($templateList as $templateId) {
3651 $exporter->addTemplate($templateId);
3653 $exporter->setInfo($info);
3655 $exporter->export();
3659 * @todo document this
3661 function action_templateoverview() {
3662 global $member, $manager;
3664 $member->isAdmin() or $this->disallow();
3668 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3670 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3671 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3673 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3674 $template['content'] = 'templatelist';
3675 $template['tabindex'] = 10;
3676 showlist($query,'table',$template);
3678 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3681 <form method="post" action="index.php"><div>
3683 <input name="action" value="templatenew" type="hidden" />
3684 <?php $manager->addTicketHidden() ?>
3686 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3687 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3689 <td><?php echo _TEMPLATE_DESC?></td>
3690 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3692 <td><?php echo _TEMPLATE_CREATE?></td>
3693 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3703 * @todo document this
3705 function action_templateedit($msg = '') {
3706 global $member, $manager;
3708 $templateid = intRequestVar('templateid');
3710 $member->isAdmin() or $this->disallow();
3712 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3713 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.addslashes(_EDITTEMPLATE_EMPTY).'");</script>';
3715 $this->pagehead($extrahead);
3717 $templatename = TEMPLATE::getNameFromId($templateid);
3718 $templatedescription = TEMPLATE::getDesc($templateid);
3719 $template =& $manager->getTemplate($templatename);
3723 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3726 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo $templatename; ?>'</h2>
3728 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3731 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3733 <form method="post" action="index.php">
3736 <input type="hidden" name="action" value="templateupdate" />
3737 <?php $manager->addTicketHidden() ?>
3738 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3741 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3743 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3744 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo htmlspecialchars($templatename) ?>" /></td>
3746 <td><?php echo _TEMPLATE_DESC?></td>
3747 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo htmlspecialchars($templatedescription) ?>" /></td>
3749 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3751 <td><?php echo _TEMPLATE_UPDATE?></td>
3753 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3754 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3757 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3758 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3759 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3760 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3761 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3762 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3763 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3766 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3767 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3768 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3769 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3770 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3771 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3772 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3773 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3776 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3778 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3781 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3782 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3785 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3786 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3787 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3788 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3791 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3792 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3793 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3794 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3797 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3798 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 160);
3799 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 170);
3800 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 180);
3803 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3804 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 190);
3805 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 200);
3806 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 210);
3807 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 220);
3808 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 230);
3811 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3812 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 240);
3813 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 250);
3814 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 260);
3817 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3818 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',270);
3819 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',280);
3822 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3824 <td><?php echo _TEMPLATE_UPDATE?></td>
3826 <input type="submit" tabindex="290" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3827 <input type="reset" tabindex="300" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3838 * @todo document this
3840 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3844 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3845 <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>
3850 * @todo document this
3852 function action_templateupdate() {
3855 $templateid = intRequestVar('templateid');
3857 $member->isAdmin() or $this->disallow();
3859 $name = postVar('tname');
3860 $desc = postVar('tdesc');
3862 if (!isValidTemplateName($name))
3863 $this->error(_ERROR_BADTEMPLATENAME);
3865 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
3866 $this->error(_ERROR_DUPTEMPLATENAME);
3869 $name = addslashes($name);
3870 $desc = addslashes($desc);
3872 // 1. Remove all template parts
3873 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
3876 // 2. Update description
3877 $query = 'UPDATE '.sql_table('template_desc').' SET'
3878 . " tdname='" . $name . "',"
3879 . " tddesc='" . $desc . "'"
3880 . " WHERE tdnumber=" . $templateid;
3883 // 3. Add non-empty template parts
3884 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
3885 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
3886 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
3887 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
3888 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
3889 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
3890 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
3891 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
3892 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
3893 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
3894 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
3895 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
3896 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
3897 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
3898 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
3899 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
3900 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
3901 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
3902 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
3903 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
3904 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
3905 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
3906 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
3907 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
3908 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
3909 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
3910 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
3911 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
3912 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
3913 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
3914 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
3915 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
3916 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
3917 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
3920 // jump back to template edit
3921 $this->action_templateedit(_TEMPLATE_UPDATED);
3926 * @todo document this
3928 function addToTemplate($id, $partname, $content) {
3929 $partname = addslashes($partname);
3930 $content = addslashes($content);
3934 // don't add empty parts:
3935 if (!trim($content)) return -1;
3937 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
3938 . "VALUES ($id, '$partname', '$content')";
3939 sql_query($query) or die("Query error: " . mysql_error());
3940 return mysql_insert_id();
3944 * @todo document this
3946 function action_templatedelete() {
3947 global $member, $manager;
3949 $member->isAdmin() or $this->disallow();
3951 $templateid = intRequestVar('templateid');
3952 // TODO: check if template can be deleted
3956 $name = TEMPLATE::getNameFromId($templateid);
3957 $desc = TEMPLATE::getDesc($templateid);
3960 <h2><?php echo _DELETE_CONFIRM?></h2>
3963 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo $name?></b> (<?php echo htmlspecialchars($desc) ?>)
3966 <form method="post" action="index.php"><div>
3967 <input type="hidden" name="action" value="templatedeleteconfirm" />
3968 <?php $manager->addTicketHidden() ?>
3969 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
3970 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3977 * @todo document this
3979 function action_templatedeleteconfirm() {
3980 global $member, $manager;
3982 $templateid = intRequestVar('templateid');
3984 $member->isAdmin() or $this->disallow();
3986 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
3988 // 1. delete description
3989 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
3992 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
3994 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
3996 $this->action_templateoverview();
4000 * @todo document this
4002 function action_templatenew() {
4005 $member->isAdmin() or $this->disallow();
4007 $name = postVar('name');
4008 $desc = postVar('desc');
4010 if (!isValidTemplateName($name))
4011 $this->error(_ERROR_BADTEMPLATENAME);
4013 if (TEMPLATE::exists($name))
4014 $this->error(_ERROR_DUPTEMPLATENAME);
4016 $newTemplateId = TEMPLATE::createNew($name, $desc);
4018 $this->action_templateoverview();
4022 * @todo document this
4024 function action_templateclone() {
4027 $templateid = intRequestVar('templateid');
4029 $member->isAdmin() or $this->disallow();
4031 // 1. read old template
4032 $name = TEMPLATE::getNameFromId($templateid);
4033 $desc = TEMPLATE::getDesc($templateid);
4035 // 2. create desc thing
4036 $name = "cloned" . $name;
4038 // if a template with that name already exists:
4039 if (TEMPLATE::exists($name)) {
4041 while (TEMPLATE::exists($name . $i))
4046 $newid = TEMPLATE::createNew($name, $desc);
4049 // go through parts of old template and add them to the new one
4050 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4051 while ($o = mysql_fetch_object($res)) {
4052 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4055 $this->action_templateoverview();
4059 * @todo document this
4061 function action_skinoverview() {
4062 global $member, $manager;
4064 $member->isAdmin() or $this->disallow();
4068 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4070 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4072 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4074 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4075 $template['content'] = 'skinlist';
4076 $template['tabindex'] = 10;
4077 showlist($query,'table',$template);
4079 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4082 <form method="post" action="index.php">
4085 <input name="action" value="skinnew" type="hidden" />
4086 <?php $manager->addTicketHidden() ?>
4088 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4089 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4091 <td><?php echo _SKIN_DESC?></td>
4092 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4094 <td><?php echo _SKIN_CREATE?></td>
4095 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4106 * @todo document this
4108 function action_skinnew() {
4111 $member->isAdmin() or $this->disallow();
4113 $name = trim(postVar('name'));
4114 $desc = trim(postVar('desc'));
4116 if (!isValidSkinName($name))
4117 $this->error(_ERROR_BADSKINNAME);
4119 if (SKIN::exists($name))
4120 $this->error(_ERROR_DUPSKINNAME);
4122 $newId = SKIN::createNew($name, $desc);
4124 $this->action_skinoverview();
4128 * @todo document this
4130 function action_skinedit() {
4131 global $member, $manager;
4133 $skinid = intRequestVar('skinid');
4135 $member->isAdmin() or $this->disallow();
4137 $skin =& new SKIN($skinid);
4142 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4144 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4146 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4147 <?php echo _SKIN_PARTS_MSG?>
4149 <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>
4150 <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>
4151 <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>
4152 <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>
4153 <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>
4154 <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>
4155 <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>
4156 <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>
4161 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4162 $res = sql_query($query);
4164 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4165 echo '<form method="get" action="index.php">' . "\r\n";
4166 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4167 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4168 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4169 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4170 echo '</form>' . "\r\n";
4172 if ($res && mysql_num_rows($res) > 0) {
4176 while ($row = mysql_fetch_assoc($res)) {
4177 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . strtolower($row['stype']) . '">' . ucfirst($row['stype']) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . strtolower($row['stype']) . '">remove</a>)</li>';
4185 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4186 <form method="post" action="index.php">
4189 <input type="hidden" name="action" value="skineditgeneral" />
4190 <?php $manager->addTicketHidden() ?>
4191 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4193 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4194 <td><input name="name" tabindex="90" value="<?php echo htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>
4196 <td><?php echo _SKIN_DESC?></td>
4197 <td><input name="desc" tabindex="100" value="<?php echo htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4199 <td><?php echo _SKIN_TYPE?></td>
4200 <td><input name="type" tabindex="110" value="<?php echo htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4202 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4203 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4205 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4206 <td><input name="inc_prefix" tabindex="130" value="<?php echo htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4208 <td><?php echo _SKIN_CHANGE?></td>
4209 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4216 <?php $this->pagefoot();
4220 * @todo document this
4222 function action_skineditgeneral() {
4225 $skinid = intRequestVar('skinid');
4227 $member->isAdmin() or $this->disallow();
4229 $name = postVar('name');
4230 $desc = postVar('desc');
4231 $type = postVar('type');
4232 $inc_mode = postVar('inc_mode');
4233 $inc_prefix = postVar('inc_prefix');
4235 $skin =& new SKIN($skinid);
4238 if (!isValidSkinName($name))
4239 $this->error(_ERROR_BADSKINNAME);
4241 if (($skin->getName() != $name) && SKIN::exists($name))
4242 $this->error(_ERROR_DUPSKINNAME);
4244 if (!$type) $type = 'text/html';
4245 if (!$inc_mode) $inc_mode = 'normal';
4247 // 2. Update description
4248 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4250 $this->action_skinedit();
4255 * @todo document this
4257 function action_skinedittype($msg = '') {
4258 global $member, $manager;
4260 $skinid = intRequestVar('skinid');
4261 $type = requestVar('type');
4263 $member->isAdmin() or $this->disallow();
4265 $type = trim($type);
4266 $type = strtolower($type);
4268 if (!isValidShortName($type)) {
4269 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4272 $skin =& new SKIN($skinid);
4274 $friendlyNames = SKIN::getFriendlyNames();
4278 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4280 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo $skin->getName() ?>': <?php echo (isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4282 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4286 <form method="post" action="index.php">
4289 <input type="hidden" name="action" value="skinupdate" />
4290 <?php $manager->addTicketHidden() ?>
4291 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4292 <input type="hidden" name="type" value="<?php echo $type ?>" />
4294 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4295 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4296 (skin type: <?php echo (isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4297 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4298 help('skinpart' . $type);
4300 help('skinpartspecial');
4304 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo htmlspecialchars($skin->getContent($type)) ?></textarea>
4307 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4308 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4309 (skin type: <?php echo (isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4312 <?php echo _SKIN_ALLOWEDVARS?>
4313 <?php $actions = SKIN::getAllowedActionsForType($type);
4317 while ($current = array_shift($actions)) {
4318 // skip deprecated vars
4319 if ($current == 'ifcat') continue;
4320 if ($current == 'imagetext') continue;
4321 if ($current == 'vars') continue;
4323 echo helplink('skinvar-' . $current) . "$current</a>";
4324 if (count($actions) != 0) echo ", ";
4329 <?php $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4330 showlist($query,'table',array('content'=>'shortblognames'));
4335 <?php $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4336 showlist($query,'table',array('content'=>'shortnames'));
4344 <?php $this->pagefoot();
4348 * @todo document this
4350 function action_skinupdate() {
4353 $skinid = intRequestVar('skinid');
4354 $content = trim(postVar('content'));
4355 $type = postVar('type');
4357 $member->isAdmin() or $this->disallow();
4359 $skin =& new SKIN($skinid);
4360 $skin->update($type, $content);
4362 $this->action_skinedittype(_SKIN_UPDATED);
4366 * @todo document this
4368 function action_skindelete() {
4369 global $member, $manager, $CONF;
4371 $skinid = intRequestVar('skinid');
4373 $member->isAdmin() or $this->disallow();
4375 // don't allow default skin to be deleted
4376 if ($skinid == $CONF['BaseSkin'])
4377 $this->error(_ERROR_DEFAULTSKIN);
4379 // don't allow deletion of default skins for blogs
4380 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4381 $r = sql_query($query);
4382 if ($o = mysql_fetch_object($r))
4383 $this->error(_ERROR_SKINDEFDELETE . $o->bname);
4387 $skin =& new SKIN($skinid);
4388 $name = $skin->getName();
4389 $desc = $skin->getDescription();
4392 <h2><?php echo _DELETE_CONFIRM?></h2>
4395 <?php echo _CONFIRMTXT_SKIN?><b><?php echo $name ?></b> (<?php echo htmlspecialchars($desc)?>)
4398 <form method="post" action="index.php"><div>
4399 <input type="hidden" name="action" value="skindeleteconfirm" />
4400 <?php $manager->addTicketHidden() ?>
4401 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4402 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4409 * @todo document this
4411 function action_skindeleteconfirm() {
4412 global $member, $CONF, $manager;
4414 $skinid = intRequestVar('skinid');
4416 $member->isAdmin() or $this->disallow();
4418 // don't allow default skin to be deleted
4419 if ($skinid == $CONF['BaseSkin'])
4420 $this->error(_ERROR_DEFAULTSKIN);
4422 // don't allow deletion of default skins for blogs
4423 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4424 $r = sql_query($query);
4425 if ($o = mysql_fetch_object($r))
4426 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4428 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4430 // 1. delete description
4431 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4434 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4436 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4438 $this->action_skinoverview();
4442 * @todo document this
4444 function action_skinremovetype() {
4445 global $member, $manager, $CONF;
4447 $skinid = intRequestVar('skinid');
4448 $skintype = requestVar('type');
4450 if (!isValidShortName($skintype)) {
4451 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4454 $member->isAdmin() or $this->disallow();
4456 // don't allow default skinparts to be deleted
4457 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4458 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4463 $skin =& new SKIN($skinid);
4464 $name = $skin->getName();
4465 $desc = $skin->getDescription();
4468 <h2><?php echo _DELETE_CONFIRM?></h2>
4471 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo $skintype; ?> (<?php echo $name; ?>)</b> (<?php echo htmlspecialchars($desc)?>)
4474 <form method="post" action="index.php"><div>
4475 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4476 <?php $manager->addTicketHidden() ?>
4477 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4478 <input type="hidden" name="type" value="<?php echo $skintype; ?>" />
4479 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4486 * @todo document this
4488 function action_skinremovetypeconfirm() {
4489 global $member, $CONF, $manager;
4491 $skinid = intRequestVar('skinid');
4492 $skintype = requestVar('type');
4494 if (!isValidShortName($skintype)) {
4495 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4498 $member->isAdmin() or $this->disallow();
4500 // don't allow default skinparts to be deleted
4501 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4502 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4505 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4508 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4510 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4512 $this->action_skinedit();
4516 * @todo document this
4518 function action_skinclone() {
4521 $skinid = intRequestVar('skinid');
4523 $member->isAdmin() or $this->disallow();
4525 // 1. read skin to clone
4526 $skin =& new SKIN($skinid);
4528 $name = "clone_" . $skin->getName();
4530 // if a skin with that name already exists:
4531 if (SKIN::exists($name)) {
4533 while (SKIN::exists($name . $i))
4538 // 2. create skin desc
4539 $newid = SKIN::createNew(
4541 $skin->getDescription(),
4542 $skin->getContentType(),
4543 $skin->getIncludeMode(),
4544 $skin->getIncludePrefix()
4550 $this->skinclonetype($skin, $newid, 'index');
4551 $this->skinclonetype($skin, $newid, 'item');
4552 $this->skinclonetype($skin, $newid, 'archivelist');
4553 $this->skinclonetype($skin, $newid, 'archive');
4554 $this->skinclonetype($skin, $newid, 'search');
4555 $this->skinclonetype($skin, $newid, 'error');
4556 $this->skinclonetype($skin, $newid, 'member');
4557 $this->skinclonetype($skin, $newid, 'imagepopup');
4560 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4561 $res = sql_query($query);
4562 while ($row = mysql_fetch_assoc($res)) {
4563 $this->skinclonetype($skin, $newid, $row['stype']);
4566 $this->action_skinoverview();
4571 * @todo document this
4573 function skinclonetype($skin, $newid, $type) {
4574 $newid = intval($newid);
4575 $content = $skin->getContent($type);
4577 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". addslashes($content)."', '". addslashes($type)."')";
4583 * @todo document this
4585 function action_settingsedit() {
4586 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4588 $member->isAdmin() or $this->disallow();
4592 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4595 <h2><?php echo _SETTINGS_TITLE?></h2>
4597 <form action="index.php" method="post">
4600 <input type="hidden" name="action" value="settingsupdate" />
4601 <?php $manager->addTicketHidden() ?>
4604 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4606 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4609 $query = 'SELECT bname as text, bnumber as value'
4610 . ' FROM '.sql_table('blog');
4611 $template['name'] = 'DefaultBlog';
4612 $template['selected'] = $CONF['DefaultBlog'];
4613 $template['tabindex'] = 10;
4614 showlist($query,'select',$template);
4618 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4621 $query = 'SELECT sdname as text, sdnumber as value'
4622 . ' FROM '.sql_table('skin_desc');
4623 $template['name'] = 'BaseSkin';
4624 $template['selected'] = $CONF['BaseSkin'];
4625 $template['tabindex'] = 1;
4626 showlist($query,'select',$template);
4630 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4631 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo htmlspecialchars($CONF['AdminEmail']) ?>" /></td>
4633 <td><?php echo _SETTINGS_SITENAME?></td>
4634 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo htmlspecialchars($CONF['SiteName']) ?>" /></td>
4636 <td><?php echo _SETTINGS_SITEURL?></td>
4637 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL']) ?>" /></td>
4639 <td><?php echo _SETTINGS_ADMINURL?></td>
4640 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo htmlspecialchars($CONF['AdminURL']) ?>" /></td>
4642 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4643 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo htmlspecialchars($CONF['PluginURL']) ?>" /></td>
4645 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4646 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo htmlspecialchars($CONF['SkinsURL']) ?>" /></td>
4648 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4649 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo htmlspecialchars($CONF['ActionURL']) ?>" /></td>
4651 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
4655 <select name="Language" tabindex="10050">
4656 <?php // show a dropdown list of all available languages
4658 $dirhandle = opendir($DIR_LANG);
4659 while ($filename = readdir($dirhandle)) {
4660 if (ereg("^(.*)\.php$",$filename,$matches)) {
4661 $name = $matches[1];
4662 echo "<option value='$name'";
4663 if ($name == $CONF['Language'])
4664 echo " selected='selected'";
4665 echo ">$name</option>";
4668 closedir($dirhandle);
4675 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4677 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4679 URL: <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo htmlspecialchars($CONF['DisableSiteURL'])?>" />
4682 <td><?php echo _SETTINGS_DIRS?></td>
4683 <td><?php echo htmlspecialchars($DIR_NUCLEUS) ?>
4684 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4686 <td><?php echo _SETTINGS_DBLOGIN?></td>
4687 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4691 echo _SETTINGS_JSTOOLBAR
4692 /* =_SETTINGS_DISABLEJS
4694 I temporary changed the meaning of DisableJsTools, until I can find a good
4695 way to select the javascript version to use
4699 1 : all javascript disabled
4700 2 : 'simpler' javascript (for mozilla/opera/mac)
4704 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4705 <select name="DisableJsTools" tabindex="10075">
4706 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4707 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4708 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4709 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4710 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4711 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4716 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4719 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4720 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4722 echo ' ', _SETTINGS_URLMODE_HELP;
4728 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4730 <td><?php echo _SETTINGS_MEDIADIR?></td>
4731 <td><?php echo htmlspecialchars($DIR_MEDIA) ?>
4732 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4733 <?php if (!is_dir($DIR_MEDIA))
4734 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4735 if (!is_readable($DIR_MEDIA))
4736 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4737 if (!is_writeable($DIR_MEDIA))
4738 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4742 <td><?php echo _SETTINGS_MEDIAURL?></td>
4744 <input name="MediaURL" tabindex="10080" size="40" value="<?php echo htmlspecialchars($CONF['MediaURL']) ?>" />
4747 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4748 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4750 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4752 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo htmlspecialchars($CONF['AllowedTypes']) ?>" />
4755 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4757 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo htmlspecialchars($CONF['MaxUploadSize']) ?>" />
4760 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4761 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4764 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4766 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4767 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4769 <td><?php echo _SETTINGS_ALLOWCREATE?>
4770 <?php help('allowaccountcreation'); ?>
4772 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4775 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4776 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4778 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4781 <td><?php echo _SETTINGS_MEMBERMSGS?>
4782 <?php help('messageservice'); ?>
4784 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
4787 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
4788 <?php help('messageservice'); ?>
4790 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
4793 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
4794 <?php help('protectmemnames'); ?>
4796 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
4802 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
4804 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
4805 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo htmlspecialchars($CONF['CookiePrefix'])?>" /></td>
4807 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
4808 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo htmlspecialchars($CONF['CookieDomain'])?>" /></td>
4810 <td><?php echo _SETTINGS_COOKIEPATH?></td>
4811 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo htmlspecialchars($CONF['CookiePath'])?>" /></td>
4813 <td><?php echo _SETTINGS_COOKIESECURE?></td>
4814 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
4816 <td><?php echo _SETTINGS_COOKIELIFE?></td>
4817 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
4818 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
4821 <td><?php echo _SETTINGS_LASTVISIT?></td>
4822 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
4827 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
4829 <td><?php echo _SETTINGS_UPDATE?></td>
4830 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
4837 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
4840 'GeneralSettingsFormExtras',
4848 * @todo document this
4850 function action_settingsupdate() {
4851 global $member, $CONF;
4853 $member->isAdmin() or $this->disallow();
4855 // check if email address for admin is valid
4856 if (!isValidMailAddress(postVar('AdminEmail')))
4857 $this->error(_ERROR_BADMAILADDRESS);
4861 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
4862 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
4863 $this->updateConfig('IndexURL', postVar('IndexURL'));
4864 $this->updateConfig('AdminURL', postVar('AdminURL'));
4865 $this->updateConfig('PluginURL', postVar('PluginURL'));
4866 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
4867 $this->updateConfig('ActionURL', postVar('ActionURL'));
4868 $this->updateConfig('Language', postVar('Language'));
4869 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
4870 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
4871 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
4872 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
4873 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
4874 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
4875 $this->updateConfig('SiteName', postVar('SiteName'));
4876 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
4877 $this->updateConfig('DisableSite', postVar('DisableSite'));
4878 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
4879 $this->updateConfig('LastVisit', postVar('LastVisit'));
4880 $this->updateConfig('MediaURL', postVar('MediaURL'));
4881 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
4882 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
4883 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
4884 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
4885 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
4886 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
4887 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
4888 $this->updateConfig('CookiePath', postVar('CookiePath'));
4889 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
4890 $this->updateConfig('URLMode', postVar('URLMode'));
4891 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
4893 // load new config and redirect (this way, the new language will be used is necessary)
4894 // note that when changing cookie settings, this redirect might cause the user
4895 // to have to log in again.
4897 redirect($CONF['AdminURL'] . '?action=manage');
4903 * @todo document this
4905 function updateConfig($name, $val) {
4906 $name = addslashes($name);
4907 $val = trim(addslashes($val));
4909 $query = 'UPDATE '.sql_table('config')
4910 . " SET value='$val'"
4911 . " WHERE name='$name'";
4913 sql_query($query) or die("Query error: " . mysql_error());
4914 return mysql_insert_id();
4919 * @param string $msg message that will be shown
4921 function error($msg) {
4927 echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
4933 * @todo document this
4935 function disallow() {
4936 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
4938 $this->error(_ERROR_DISALLOWED);
4942 * @todo document this
4944 function pagehead($extrahead = '') {
4945 global $member, $nucleus, $CONF, $manager;
4950 'extrahead' => &$extrahead,
4951 'action' => $this->action
4955 $baseUrl = htmlspecialchars($CONF['AdminURL']);
4958 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4959 <html xmlns="http://www.w3.org/1999/xhtml">
4961 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
4962 <title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>
4963 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin.css" />
4964 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
4965 href="<?php echo $baseUrl?>styles/addedit.css" />
4967 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
4968 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
4969 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
4971 <meta http-equiv='Pragma' content='no-cache' />
4972 <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
4973 <meta http-equiv='Expires' content='-1' />
4975 <?php echo $extrahead?>
4978 <div class="header">
4979 <h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>
4981 <div id="container">
4983 <div class="loginname">
4984 <?php if ($member->isLoggedIn())
4985 echo _LOGGEDINAS . ' ' . $member->getDisplayName()
4986 ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
4987 . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
4989 echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
4991 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
4995 // Note(JP): disabled code name description
4997 if ($member->isLoggedIn() && $member->isAdmin())
4998 echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"</a>';
5000 echo 'Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"';
5002 if ($member->isLoggedIn() && $member->isAdmin())
5003 echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' </a>';
5005 echo 'Nucleus CMS ', $nucleus['version'];
5011 * @todo document this
5013 function pagefoot() {
5014 global $action, $member, $manager;
5019 'action' => $this->action
5023 if ($member->isLoggedIn() && ($action != 'showlogin')) {
5025 <h2><?php echo _LOGOUT ?></h2>
5027 <li><a href="index.php?action=overview"><?php echo _BACKHOME?></a></li>
5028 <li><a href='index.php?action=logout'><?php echo _LOGOUT?></a></li>
5033 <a href="http://nucleuscms.org/">Nucleus CMS</a> © 2002-<?php echo date('Y'); ?> The Nucleus Group
5035 <a href="http://nucleuscms.org/donate.php">Donate!</a>
5038 </div><!-- content -->
5040 <div id="quickmenu">
5042 <?php // ---- user settings ----
5043 if (($action != 'showlogin') && ($member->isLoggedIn())) {
5045 echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
5048 echo '<h2>',_QMENU_ADD,'</h2>';
5049 echo '<form method="get" action="index.php"><div>';
5050 echo '<input type="hidden" name="action" value="createitem" />';
5052 $showAll = requestVar('showall');
5053 if (($member->isAdmin()) && ($showAll == 'yes')) {
5054 // Super-Admins have access to all blogs! (no add item support though)
5055 $query = 'SELECT bnumber as value, bname as text'
5056 . ' FROM ' . sql_table('blog')
5057 . ' ORDER BY bname';
5059 $query = 'SELECT bnumber as value, bname as text'
5060 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5061 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5062 . ' ORDER BY bname';
5064 $template['name'] = 'blogid';
5065 $template['tabindex'] = 15000;
5066 $template['extra'] = _QMENU_ADD_SELECT;
5067 $template['selected'] = -1;
5068 $template['shorten'] = 10;
5069 $template['shortenel'] = '';
5070 $template['javascript'] = 'onchange="return form.submit()"';
5071 showlist($query,'select',$template);
5073 echo '</div></form>';
5075 echo '<h2>' . $member->getDisplayName(). '</h2>';
5077 echo '<li><a href="index.php?action=editmembersettings">',_QMENU_USER_SETTINGS,'</a></li>';
5078 echo '<li><a href="index.php?action=browseownitems">',_QMENU_USER_ITEMS,'</a></li>';
5079 echo '<li><a href="index.php?action=browseowncomments">',_QMENU_USER_COMMENTS,'</a></li>';
5085 // ---- general settings ----
5086 if ($member->isAdmin()) {
5088 echo '<h2>',_QMENU_MANAGE,'</h2>';
5091 echo '<li><a href="index.php?action=actionlog">',_QMENU_MANAGE_LOG,'</a></li>';
5092 echo '<li><a href="index.php?action=settingsedit">',_QMENU_MANAGE_SETTINGS,'</a></li>';
5093 echo '<li><a href="index.php?action=usermanagement">',_QMENU_MANAGE_MEMBERS,'</a></li>';
5094 echo '<li><a href="index.php?action=createnewlog">',_QMENU_MANAGE_NEWBLOG,'</a></li>';
5095 echo '<li><a href="index.php?action=backupoverview">',_QMENU_MANAGE_BACKUPS,'</a></li>';
5096 echo '<li><a href="index.php?action=pluginlist">',_QMENU_MANAGE_PLUGINS,'</a></li>';
5099 echo '<h2>',_QMENU_LAYOUT,'</h2>';
5101 echo '<li><a href="index.php?action=skinoverview">',_QMENU_LAYOUT_SKINS,'</a></li>';
5102 echo '<li><a href="index.php?action=templateoverview">',_QMENU_LAYOUT_TEMPL,'</a></li>';
5103 echo '<li><a href="index.php?action=skinieoverview">',_QMENU_LAYOUT_IEXPORT,'</a></li>';
5108 $aPluginExtras = array();
5112 'options' => &$aPluginExtras
5115 if (count($aPluginExtras) > 0)
5117 echo '<h2>', _QMENU_PLUGINS, '</h2>';
5119 foreach ($aPluginExtras as $aInfo)
5121 echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';
5126 } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
5128 echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
5130 // introduction text on login screen
5131 echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
5136 <!-- content / quickmenu container -->
5145 * @todo document this
5147 function action_regfile() {
5148 global $member, $CONF;
5150 $blogid = intRequestVar('blogid');
5152 $member->teamRights($blogid) or $this->disallow();
5154 // header-code stolen from phpMyAdmin
5155 // REGEDIT and bookmarklet code stolen from GreyMatter
5157 $sjisBlogName = getBlogNameFromID($blogid);
5158 $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
5160 header('Content-Type: application/octetstream');
5161 header('Content-Disposition: filename="nucleus.reg"');
5162 header('Pragma: no-cache');
5163 header('Expires: 0');
5166 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\Post To &Nucleus (".$sjisBlogName.")]\n";
5167 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5168 echo '"contexts"=hex:31';
5172 * @todo document this
5174 function action_bookmarklet() {
5175 global $member, $manager;
5177 $blogid = intRequestVar('blogid');
5179 $member->teamRights($blogid) or $this->disallow();
5181 $blog =& $manager->getBlog($blogid);
5182 $bm = getBookmarklet($blogid);
5186 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5190 <h2>Bookmarklet<!-- and Right Click Menu --></h2>
5193 Bookmarklet とは、クリック1回で記事の投稿ができるシステムです。 この Bookmarklet をインストールすると、ブラウザのツールバーの'add to weblog'ボタンが利用可能となり、Nucleusの新規アイテムの追加ウィンドウがポップアップします。任意のWebページを開いた状態でこのボタンを押せば、そのWebページのタイトルと、そのページへのリンクタグがすでに埋め込まれた状態でアイテム追加ウィンドウが開き、さらに、そのページ内に引用したい文を選択した状態であればその引用文も自動的に引用します。
5196 <h3>Bookmarklet</h3>
5198 下のリンク部分を「お気に入り」もしくはツールバーにドラッグできます。<small>(その前にテストしてみたい場合は単純に下のリンクをクリックしてみてください)</small>
5201 <a href="<?php echo htmlspecialchars($bm)?>">Add to <?php echo $blog->getShortName()?></a> (ほとんどのブラウザで動作します)
5204 <h3>右クリックメニューにインストール (WindowsでIE使用時)</h3>
5207 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5208 $url = $manager->addTicketToUrl($url);
5210 あるいは<a href="<?php echo htmlspecialchars($url) ?>">右クリックメニュー</a>にインストールすることもできます (「開く」を選択すれば直接レジストリに登録します)
5214 このインストールした右クリックメニューを表示するためにはIEの再起動が必要です。
5219 「お気に入り」もしくはツールバーから消すには、単に削除するだけです。
5223 右クリックメニューから消したい時は、以下の手順を踏んでください:
5227 <li>スタートメニューから「ファイルを指定して実行...」を選択</li>
5228 <li>"regedit" と入力</li>
5229 <li>"OK" ボタンを押す</li>
5230 <li>"\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt" をツリーの中から検索</li>
5231 <li>"add to weblog" エントリを削除</li>
5240 * @todo document this
5242 function action_actionlog() {
5243 global $member, $manager;
5245 $member->isAdmin() or $this->disallow();
5249 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5251 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5254 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5255 <p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5257 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5259 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5260 $template['content'] = 'actionlist';
5261 $amount = showlist($query,'table',$template);
5268 * @todo document this
5270 function action_banlist() {
5271 global $member, $manager;
5273 $blogid = intRequestVar('blogid');
5275 $member->blogAdminRights($blogid) or $this->disallow();
5277 $blog =& $manager->getBlog($blogid);
5281 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5283 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5285 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5286 $template['content'] = 'banlist';
5287 $amount = showlist($query,'table',$template);
5292 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5293 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5301 * @todo document this
5303 function action_banlistdelete() {
5304 global $member, $manager;
5306 $blogid = intRequestVar('blogid');
5307 $iprange = requestVar('iprange');
5309 $member->blogAdminRights($blogid) or $this->disallow();
5311 $blog =& $manager->getBlog($blogid);
5315 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5317 <form method="post" action="index.php">
5319 <h3><?php echo _BAN_IPRANGE?></h3>
5322 <?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>
5323 <input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />
5326 <h3><?php echo _BAN_BLOGS?></h3>
5329 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5330 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">Only blog '<?php echo htmlspecialchars($blog->getName())?>'</label>
5332 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5335 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5338 <?php $manager->addTicketHidden() ?>
5339 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5340 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5349 * @todo document this
5351 function action_banlistdeleteconfirm() {
5352 global $member, $manager;
5354 $blogid = intPostVar('blogid');
5355 $allblogs = postVar('allblogs');
5356 $iprange = postVar('iprange');
5358 $member->blogAdminRights($blogid) or $this->disallow();
5363 if (BAN::removeBan($blogid, $iprange))
5364 array_push($deleted, $blogid);
5366 // get blogs fot which member has admin rights
5367 $adminblogs = $member->getAdminBlogs();
5368 foreach ($adminblogs as $blogje) {
5369 if (BAN::removeBan($blogje, $iprange))
5370 array_push($deleted, $blogje);
5374 if (sizeof($deleted) == 0)
5375 $this->error(_ERROR_DELETEBAN);
5379 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5380 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5381 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5384 foreach ($deleted as $delblog) {
5385 $b =& $manager->getBlog($delblog);
5386 echo "<li>" . htmlspecialchars($b->getName()). "</li>";
5395 * @todo document this
5397 function action_banlistnewfromitem() {
5398 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5402 * @todo document this
5404 function action_banlistnew($blogid = '') {
5405 global $member, $manager;
5408 $blogid = intRequestVar('blogid');
5410 $ip = requestVar('ip');
5412 $member->blogAdminRights($blogid) or $this->disallow();
5414 $blog =& $manager->getBlog($blogid);
5418 <h2><?php echo _BAN_ADD_TITLE?></h2>
5421 <form method="post" action="index.php">
5423 <h3><?php echo _BAN_IPRANGE?></h3>
5425 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5428 <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.
5434 <input name="iprange" type="radio" value="<?php echo htmlspecialchars($ip)?>" checked="checked" id="ip_fixed" /><label for="ip_fixed"><?php echo htmlspecialchars($ip)?></label>
5436 <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' />
5438 echo "<input name='iprange' value='custom' type='hidden' />";
5439 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5444 <h3><?php echo _BAN_BLOGS?></h3>
5446 <p><?php echo _BAN_BLOGS_TEXT?></p>
5449 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5450 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>
5452 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5455 <h3><?php echo _BAN_REASON_TITLE?></h3>
5457 <p><?php echo _BAN_REASON_TEXT?></p>
5459 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5461 <h3><?php echo _BAN_ADD_TITLE?></h3>
5464 <input name="action" type="hidden" value="banlistadd" />
5465 <?php $manager->addTicketHidden() ?>
5466 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5471 <?php $this->pagefoot();
5475 * @todo document this
5477 function action_banlistadd() {
5480 $blogid = intPostVar('blogid');
5481 $allblogs = postVar('allblogs');
5482 $iprange = postVar('iprange');
5483 if ($iprange == "custom")
5484 $iprange = postVar('customiprange');
5485 $reason = postVar('reason');
5487 $member->blogAdminRights($blogid) or $this->disallow();
5489 // TODO: check IP range validity
5492 if (!BAN::addBan($blogid, $iprange, $reason))
5493 $this->error(_ERROR_ADDBAN);
5495 // get blogs fot which member has admin rights
5496 $adminblogs = $member->getAdminBlogs();
5498 foreach ($adminblogs as $blogje) {
5499 if (!BAN::addBan($blogje, $iprange, $reason))
5503 $this->error(_ERROR_ADDBAN);
5506 $this->action_banlist();
5511 * @todo document this
5513 function action_clearactionlog() {
5516 $member->isAdmin() or $this->disallow();
5520 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5524 * @todo document this
5526 function action_backupoverview() {
5527 global $member, $manager;
5529 $member->isAdmin() or $this->disallow();
5533 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5535 <h2><?php echo _BACKUPS_TITLE?></h2>
5537 <h3><?php echo _BACKUP_TITLE?></h3>
5539 <p><?php echo _BACKUP_INTRO?></p>
5541 <form method="post" action="index.php"><p>
5542 <input type="hidden" name="action" value="backupcreate" />
5543 <?php $manager->addTicketHidden() ?>
5545 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
5547 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
5549 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
5553 <div class="note"><?php echo _BACKUP_NOTE?></div>
5556 <h3><?php echo _RESTORE_TITLE?></h3>
5558 <div class="note"><?php echo _RESTORE_NOTE?></div>
5560 <p><?php echo _RESTORE_INTRO?></p>
5562 <form method="post" action="index.php" enctype="multipart/form-data"><p>
5563 <input type="hidden" name="action" value="backuprestore" />
5564 <?php $manager->addTicketHidden() ?>
5565 <input name="backup_file" type="file" tabindex="30" />
5567 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
5568 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
5569 <br /><?php echo _RESTORE_WARNING?>
5572 <?php $this->pagefoot();
5576 * @todo document this
5578 function action_backupcreate() {
5579 global $member, $DIR_LIBS;
5581 $member->isAdmin() or $this->disallow();
5583 // use compression ?
5584 $useGzip = intval(postVar('gzip'));
5586 include($DIR_LIBS . 'backup.php');
5588 // try to extend time limit
5589 // (creating/restoring dumps might take a while)
5590 @set_time_limit(1200);
5592 do_backup($useGzip);
5597 * @todo document this
5599 function action_backuprestore() {
5600 global $member, $DIR_LIBS;
5602 $member->isAdmin() or $this->disallow();
5604 if (intPostVar('letsgo') != 1)
5605 $this->error(_ERROR_BACKUP_NOTSURE);
5607 include($DIR_LIBS . 'backup.php');
5609 // try to extend time limit
5610 // (creating/restoring dumps might take a while)
5611 @set_time_limit(1200);
5613 $message = do_restore();
5615 $this->error($message);
5619 <h2><?php echo _RESTORE_COMPLETE?></h2>
5620 <?php $this->pagefoot();
5625 * @todo document this
5627 function action_pluginlist() {
5628 global $member, $manager;
5631 $member->isAdmin() or $this->disallow();
5635 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5637 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
5639 echo '<h3>' , _PLUGS_TITLE_INSTALLED , '</h3>';
5642 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
5644 $template['content'] = 'pluginlist';
5645 $template['tabindex'] = 10;
5646 showlist($query, 'table', $template);
5649 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
5651 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
5653 <form method="post" action="index.php"><div>
5654 <input type="hidden" name="action" value="pluginupdate" />
5655 <?php $manager->addTicketHidden() ?>
5656 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
5659 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
5661 <?php // find a list of possibly non-installed plugins
5662 $candidates = array();
5663 global $DIR_PLUGINS;
5664 $dirhandle = opendir($DIR_PLUGINS);
5665 while ($filename = readdir($dirhandle)) {
5666 if (ereg('^NP_(.*)\.php$',$filename,$matches)) {
5667 $name = $matches[1];
5668 // only show in list when not yet installed
5669 $res = sql_query('SELECT * FROM '.sql_table('plugin').' WHERE pfile="NP_'.addslashes($name).'"');
5670 if (mysql_num_rows($res) == 0)
5671 array_push($candidates,$name);
5674 closedir($dirhandle);
5676 if (sizeof($candidates) > 0) {
5679 <p><?php echo _PLUGS_ADD_TEXT?></p>
5682 <form method='post' action='index.php'><div>
5683 <input type='hidden' name='action' value='pluginadd' />
5684 <?php $manager->addTicketHidden() ?>
5685 <select name="filename" tabindex="30">
5686 <?php foreach($candidates as $name)
5687 echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';
5690 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
5693 <?php } else { // sizeof(candidates) == 0
5694 echo '<p>',_PLUGS_NOCANDIDATES,'</p>';
5701 * @todo document this
5703 function action_pluginhelp() {
5704 global $member, $manager, $DIR_PLUGINS, $CONF;
5707 $member->isAdmin() or $this->disallow();
5709 $plugid = intGetVar('plugid');
5711 if (!$manager->pidInstalled($plugid))
5712 $this->error(_ERROR_NOSUCHPLUGIN);
5714 $plugName = getPluginNameFromPid($plugid);
5718 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
5720 echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';
5722 $plug =& $manager->getPlugin($plugName);
5723 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
5725 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
5726 @readfile($helpFile);
5728 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
5729 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
5737 * @todo document this
5739 function action_pluginadd() {
5740 global $member, $manager, $DIR_PLUGINS;
5743 $member->isAdmin() or $this->disallow();
5745 $name = postVar('filename');
5747 if ($manager->pluginInstalled($name))
5748 $this->error(_ERROR_DUPPLUGIN);
5749 if (!checkPlugin($name))
5750 $this->error(_ERROR_PLUGFILEERROR . ' (' . $name . ')');
5752 // get number of currently installed plugins
5753 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
5754 $numCurrent = mysql_num_rows($res);
5756 // plugin will be added as last one in the list
5757 $newOrder = $numCurrent + 1;
5766 // do this before calling getPlugin (in case the plugin id is used there)
5767 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.addslashes($name).'")';
5769 $iPid = mysql_insert_id();
5771 $manager->clearCachedInfo('installedPlugins');
5773 // Load the plugin for condition checking and instalation
5774 $plugin =& $manager->getPlugin($name);
5776 // check if it got loaded (could have failed)
5779 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
5780 $manager->clearCachedInfo('installedPlugins');
5781 $this->error(_ERROR_PLUGIN_LOAD);
5784 // check if plugin needs a newer Nucleus version
5785 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
5787 // uninstall plugin again...
5788 $this->deleteOnePlugin($plugin->getID());
5790 // ...and show error
5791 $this->error(_ERROR_NUCLEUSVERSIONREQ . $plugin->getMinNucleusVersion());
5794 // check if plugin needs a newer Nucleus version
5795 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
5797 // uninstall plugin again...
5798 $this->deleteOnePlugin($plugin->getID());
5800 // ...and show error
5801 $this->error(_ERROR_NUCLEUSVERSIONREQ . $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel());
5804 $pluginList = $plugin->getPluginDep();
5805 foreach ($pluginList as $pluginName)
5808 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
5809 if (mysql_num_rows($res) == 0)
5811 // uninstall plugin again...
5812 $this->deleteOnePlugin($plugin->getID());
5814 $this->error(_ERROR_INSREQPLUGIN . $pluginName);
5818 // call the install method of the plugin
5824 'plugin' => &$plugin
5828 // update all events
5829 $this->action_pluginupdate();
5833 * @todo document this
5835 function action_pluginupdate() {
5836 global $member, $manager;
5839 $member->isAdmin() or $this->disallow();
5841 // delete everything from plugin_events
5842 sql_query('DELETE FROM '.sql_table('plugin_event'));
5844 // loop over all installed plugins
5845 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
5846 while($o = mysql_fetch_object($res)) {
5848 $plug =& $manager->getPlugin($o->pfile);
5851 $eventList = $plug->getEventList();
5852 foreach ($eventList as $eventName)
5853 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.addslashes($eventName).'\')');
5857 $this->action_pluginlist();
5861 * @todo document this
5863 function action_plugindelete() {
5864 global $member, $manager;
5867 $member->isAdmin() or $this->disallow();
5869 $pid = intGetVar('plugid');
5871 if (!$manager->pidInstalled($pid))
5872 $this->error(_ERROR_NOSUCHPLUGIN);
5876 <h2><?php echo _DELETE_CONFIRM?></h2>
5878 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
5880 <form method="post" action="index.php"><div>
5881 <?php $manager->addTicketHidden() ?>
5882 <input type="hidden" name="action" value="plugindeleteconfirm" />
5883 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
5884 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5886 <?php $this->pagefoot();
5890 * @todo document this
5892 function action_plugindeleteconfirm() {
5893 global $member, $manager;
5896 $member->isAdmin() or $this->disallow();
5898 $pid = intPostVar('plugid');
5900 $error = $this->deleteOnePlugin($pid, 1);
5902 $this->error($error);
5905 $this->action_pluginlist();
5909 * @todo document this
5911 function deleteOnePlugin($pid, $callUninstall = 0) {
5914 $pid = intval($pid);
5916 if (!$manager->pidInstalled($pid))
5917 return _ERROR_NOSUCHPLUGIN;
5919 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
5921 // call the unInstall method of the plugin
5922 if ($callUninstall) {
5923 $plugin =& $manager->getPlugin($name);
5924 if ($plugin) $plugin->unInstall();
5927 // check dependency before delete
5928 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
5929 while($o = mysql_fetch_object($res)) {
5930 $plug =& $manager->getPlugin($o->pfile);
5933 $depList = $plug->getPluginDep();
5934 foreach ($depList as $depName)
5936 if ($name == $depName)
5938 return _ERROR_DELREQPLUGIN . $o->pfile;
5944 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
5946 // delete all subscriptions
5947 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
5949 // delete all options
5950 // get OIDs from plugin_option_desc
5951 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
5953 while ($o = mysql_fetch_object($res)) {
5954 array_push($aOIDs, $o->oid);
5957 // delete from plugin_option and plugin_option_desc
5958 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
5959 if (count($aOIDs) > 0)
5960 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
5962 // update order numbers
5963 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
5964 $o = mysql_fetch_object($res);
5965 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
5968 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
5970 $manager->clearCachedInfo('installedPlugins');
5971 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
5977 * @todo document this
5979 function action_pluginup() {
5980 global $member, $manager;
5983 $member->isAdmin() or $this->disallow();
5985 $plugid = intGetVar('plugid');
5987 if (!$manager->pidInstalled($plugid))
5988 $this->error(_ERROR_NOSUCHPLUGIN);
5990 // 1. get old order number
5991 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
5992 $o = mysql_fetch_object($res);
5993 $oldOrder = $o->porder;
5995 // 2. calculate new order number
5996 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
5998 // 3. update plug numbers
5999 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6000 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6002 $this->action_pluginlist();
6006 * @todo document this
6008 function action_plugindown() {
6009 global $member, $manager;
6012 $member->isAdmin() or $this->disallow();
6014 $plugid = intGetVar('plugid');
6015 if (!$manager->pidInstalled($plugid))
6016 $this->error(_ERROR_NOSUCHPLUGIN);
6018 // 1. get old order number
6019 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6020 $o = mysql_fetch_object($res);
6021 $oldOrder = $o->porder;
6023 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6024 $maxOrder = mysql_num_rows($res);
6026 // 2. calculate new order number
6027 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6029 // 3. update plug numbers
6030 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6031 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6033 $this->action_pluginlist();
6037 * @todo document this
6039 function action_pluginoptions($message = '') {
6040 global $member, $manager;
6043 $member->isAdmin() or $this->disallow();
6045 $pid = intRequestVar('plugid');
6046 if (!$manager->pidInstalled($pid))
6047 $this->error(_ERROR_NOSUCHPLUGIN);
6049 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
6050 $this->pagehead($extrahead);
6053 <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
6055 <h2>Options for <?php echo htmlspecialchars(getPluginNameFromPid($pid))?></h2>
6057 <?php if ($message) echo $message?>
6059 <form action="index.php" method="post">
6061 <input type="hidden" name="action" value="pluginoptionsupdate" />
6062 <input type="hidden" name="plugid" value="<?php echo $pid?>" />
6066 $manager->addTicketHidden();
6068 $aOptions = array();
6070 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
6071 $r = sql_query($query);
6072 while ($o = mysql_fetch_object($r)) {
6073 array_push($aOIDs, $o->oid);
6074 $aOptions[$o->oid] = array(
6076 'value' => $o->odef,
6077 'name' => $o->oname,
6078 'description' => $o->odesc,
6079 'type' => $o->otype,
6080 'typeinfo' => $o->oextra,
6084 // fill out actual values
6085 if (count($aOIDs) > 0) {
6086 $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
6087 while ($o = mysql_fetch_object($r))
6088 $aOptions[$o->oid]['value'] = $o->ovalue;
6092 $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
6094 $template['content'] = 'plugoptionlist';
6095 $amount = showlist($aOptions,'table',$template);
6097 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6102 <?php $this->pagefoot();
6109 * @todo document this
6111 function action_pluginoptionsupdate() {
6112 global $member, $manager;
6115 $member->isAdmin() or $this->disallow();
6117 $pid = intRequestVar('plugid');
6118 if (!$manager->pidInstalled($pid))
6119 $this->error(_ERROR_NOSUCHPLUGIN);
6121 $aOptions = requestArray('plugoption');
6122 NucleusPlugin::_applyPluginOptions($aOptions);
6124 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6126 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6131 * @todo document this
6133 function _insertPluginOptions($context, $contextid = 0) {
6134 // get all current values for this contextid
6135 // (note: this might contain doubles for overlapping contextids)
6136 $aIdToValue = array();
6137 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6138 while ($o = mysql_fetch_object($res)) {
6139 $aIdToValue[$o->oid] = $o->ovalue;
6142 // get list of oids per pid
6143 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6144 . ' WHERE opid=pid and ocontext=\''.addslashes($context).'\' ORDER BY porder, oid ASC';
6145 $res = sql_query($query);
6146 $aOptions = array();
6147 while ($o = mysql_fetch_object($res)) {
6148 if (in_array($o->oid, array_keys($aIdToValue)))
6149 $value = $aIdToValue[$o->oid];
6153 array_push($aOptions, array(
6155 'pfile' => $o->pfile,
6158 'name' => $o->oname,
6159 'description' => $o->odesc,
6160 'type' => $o->otype,
6161 'typeinfo' => $o->oextra,
6162 'contextid' => $contextid,
6168 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6172 foreach ($aOptions as $aOption) {
6175 if ($iPrevPid != $aOption['pid']) {
6176 $iPrevPid = $aOption['pid'];
6178 echo '<tr><th colspan="2">Options for ', htmlspecialchars($aOption['pfile']),'</th></tr>';
6182 listplug_plugOptionRow($aOption);
6191 * Helper functions to create option forms etc.
6192 * @todo document parameters
6194 function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
6195 $id = htmlspecialchars($name);
6196 $id = str_replace('[','-',$id);
6197 $id = str_replace(']','-',$id);
6198 $id1 = $id . htmlspecialchars($value1);
6199 $id2 = $id . htmlspecialchars($value2);
6201 if ($name=="admin") {
6202 echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
6204 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
6207 if ($checkedval == $value1)
6208 echo "tabindex='$tabindex' checked='checked'";
6209 echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
6211 if ($name=="admin") {
6212 echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
6214 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
6216 if ($checkedval != $value1)
6217 echo "tabindex='$tabindex' checked='checked'";
6218 if ($isAdmin && $name=="canlogin")
6219 echo " disabled='true'";
6220 echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';