3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2011 The Nucleus Group
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
13 * The code for the Nucleus admin area
\r
15 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
16 * @copyright Copyright (C) 2002-2011 The Nucleus Group
\r
18 * @version $NucleusJP: ADMIN.php,v 1.21.2.4 2007/10/30 19:04:24 kmorimatsu Exp $
\r
21 if ( !function_exists('requestVar') ) exit;
\r
22 require_once dirname(__FILE__) . '/showlist.php';
\r
25 * Builds the admin area and executes admin actions
\r
30 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
\r
42 * Executes an action
\r
44 * @param string $action action to be performed
\r
46 function action($action) {
\r
47 global $CONF, $manager;
\r
49 // list of action aliases
\r
51 'login' => 'overview',
\r
55 if (isset($alias[$action]))
\r
56 $action = $alias[$action];
\r
58 $methodName = 'action_' . $action;
\r
60 $this->action = strtolower($action);
\r
62 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
\r
63 // is an action that requires user interaction before something is actually done)
\r
64 // all safe actions are in this array:
\r
65 $aActionsNotToCheck = array(
\r
75 'editmembersettings',
\r
77 'browseowncomments',
\r
96 'banlistnewfromitem',
\r
117 // the rest of the actions needs to be checked
\r
118 $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
\r
120 if (!in_array($this->action, $aActionsNotToCheck))
\r
122 if (!$manager->checkTicket())
\r
123 $this->error(_ERROR_BADTICKET);
\r
126 if (method_exists($this, $methodName))
\r
127 call_user_func(array($this, $methodName));
\r
129 $this->error(_BADACTION . htmlspecialchars(" ($action)"));
\r
134 * @todo document this
\r
136 function action_showlogin() {
\r
138 $this->action_login($error);
\r
142 * @todo document this
\r
144 function action_login($msg = '', $passvars = 1) {
\r
147 // skip to overview when allowed
\r
148 if ($member->isLoggedIn() && $member->canLogin()) {
\r
149 $this->action_overview();
\r
155 echo '<h2>', _LOGIN ,'</h2>';
\r
156 if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
\r
159 <form action="index.php" method="post"><p>
\r
160 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
\r
162 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
\r
164 <input name="action" value="login" type="hidden" />
\r
166 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
\r
169 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
\r
170 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
\r
172 <?php // pass through vars
\r
174 $oldaction = postVar('oldaction');
\r
175 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
\r
182 <?php $this->pagefoot();
\r
187 * provides a screen with the overview of the actions available
\r
188 * @todo document parameter
\r
190 function action_overview($msg = '') {
\r
196 echo _MESSAGE , ': ', $msg;
\r
198 /* ---- add items ---- */
\r
199 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
\r
201 $showAll = requestVar('showall');
\r
203 if (($member->isAdmin()) && ($showAll == 'yes')) {
\r
204 // Super-Admins have access to all blogs! (no add item support though)
\r
205 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
\r
206 . ' FROM ' . sql_table('blog')
\r
207 . ' ORDER BY bname';
\r
209 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
\r
210 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
\r
211 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
\r
212 . ' ORDER BY bname';
\r
214 $template['content'] = 'bloglist';
\r
215 $template['superadmin'] = $member->isAdmin();
\r
216 $amount = showlist($query,'table',$template);
\r
218 if (($showAll != 'yes') && ($member->isAdmin())) {
\r
219 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
\r
220 if ($total > $amount)
\r
221 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
\r
225 echo _OVERVIEW_NOBLOGS;
\r
227 if ($amount != 0) {
\r
228 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
\r
229 $query = 'SELECT ititle, inumber, bshortname'
\r
230 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
\r
231 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
\r
232 $template['content'] = 'draftlist';
\r
233 $amountdrafts = showlist($query, 'table', $template);
\r
234 if ($amountdrafts == 0)
\r
235 echo _OVERVIEW_NODRAFTS;
\r
238 /* ---- user settings ---- */
\r
239 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
\r
241 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
\r
242 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
\r
243 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
\r
246 /* ---- general settings ---- */
\r
247 if ($member->isAdmin()) {
\r
248 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
\r
250 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
\r
259 * Returns a link to a weblog
\r
260 * @param object BLOG
\r
262 function bloglink(&$blog) {
\r
263 return '<a href="'.htmlspecialchars($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. htmlspecialchars( $blog->getName() ) .'</a>';
\r
267 * @todo document this
\r
269 function action_manage($msg = '') {
\r
272 $member->isAdmin() or $this->disallow();
\r
276 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
279 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
\r
282 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
\r
285 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
\r
286 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
\r
287 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
\r
288 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
\r
291 echo '<h2>' . _MANAGE_SKINS . '</h2>';
\r
293 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
\r
294 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
\r
295 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
\r
298 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
\r
300 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
\r
301 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
\r
308 * @todo document this
\r
310 function action_itemlist($blogid = '') {
\r
311 global $member, $manager, $CONF;
\r
314 $blogid = intRequestVar('blogid');
\r
316 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
\r
319 $blog =& $manager->getBlog($blogid);
\r
321 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
322 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
\r
325 if (postVar('start'))
\r
326 $start = intPostVar('start');
\r
331 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
\r
333 // amount of items to show
\r
334 if (postVar('amount'))
\r
335 $amount = intPostVar('amount');
\r
337 $amount = intval($CONF['DefaultListSize']);
\r
342 $search = postVar('search'); // search through items
\r
344 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime, bnumber, catid'
\r
345 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
\r
346 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
\r
349 $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
\r
351 // non-blog-admins can only edit/delete their own items
\r
352 if (!$member->blogAdminRights($blogid))
\r
353 $query .= ' and iauthor=' . $member->getID();
\r
356 $query .= ' ORDER BY itime DESC'
\r
357 . " LIMIT $start,$amount";
\r
359 $template['content'] = 'itemlist';
\r
360 $template['now'] = $blog->getCorrectTime(time());
\r
362 $manager->loadClass("ENCAPSULATE");
\r
363 $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
\r
364 $navList->showBatchList('item',$query,'table',$template);
\r
371 * @todo document this
\r
373 function action_batchitem() {
\r
374 global $member, $manager;
\r
376 // check if logged in
\r
377 $member->isLoggedIn() or $this->disallow();
\r
379 // more precise check will be done for each performed operation
\r
381 // get array of itemids from request
\r
382 $selected = requestIntArray('batch');
\r
383 $action = requestVar('batchaction');
\r
385 // Show error when no items were selected
\r
386 if (!is_array($selected) || sizeof($selected) == 0)
\r
387 $this->error(_BATCH_NOSELECTION);
\r
389 // On move: when no destination blog/category chosen, show choice now
\r
390 $destCatid = intRequestVar('destcatid');
\r
391 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
\r
392 $this->batchMoveSelectDestination('item',$selected);
\r
394 // On delete: check if confirmation has been given
\r
395 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
\r
396 $this->batchAskDeleteConfirmation('item',$selected);
\r
400 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
\r
401 echo '<h2>',_BATCH_ITEMS,'</h2>';
\r
402 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
\r
406 // walk over all itemids and perform action
\r
407 foreach ($selected as $itemid) {
\r
408 $itemid = intval($itemid);
\r
409 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
\r
411 // perform action, display errors if needed
\r
414 $error = $this->deleteOneItem($itemid);
\r
417 $error = $this->moveOneItem($itemid, $destCatid);
\r
420 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
\r
423 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
\r
428 echo '<b>',_BATCH_DONE,'</b>';
\r
436 * @todo document this
\r
438 function action_batchcomment() {
\r
441 // check if logged in
\r
442 $member->isLoggedIn() or $this->disallow();
\r
444 // more precise check will be done for each performed operation
\r
446 // get array of itemids from request
\r
447 $selected = requestIntArray('batch');
\r
448 $action = requestVar('batchaction');
\r
450 // Show error when no items were selected
\r
451 if (!is_array($selected) || sizeof($selected) == 0)
\r
452 $this->error(_BATCH_NOSELECTION);
\r
454 // On delete: check if confirmation has been given
\r
455 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
\r
456 $this->batchAskDeleteConfirmation('comment',$selected);
\r
460 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
\r
461 echo '<h2>',_BATCH_COMMENTS,'</h2>';
\r
462 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
\r
465 // walk over all itemids and perform action
\r
466 foreach ($selected as $commentid) {
\r
467 $commentid = intval($commentid);
\r
468 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
\r
470 // perform action, display errors if needed
\r
473 $error = $this->deleteOneComment($commentid);
\r
476 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
\r
479 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
\r
484 echo '<b>',_BATCH_DONE,'</b>';
\r
492 * @todo document this
\r
494 function action_batchmember() {
\r
497 // check if logged in and admin
\r
498 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
\r
500 // get array of itemids from request
\r
501 $selected = requestIntArray('batch');
\r
502 $action = requestVar('batchaction');
\r
504 // Show error when no members selected
\r
505 if (!is_array($selected) || sizeof($selected) == 0)
\r
506 $this->error(_BATCH_NOSELECTION);
\r
508 // On delete: check if confirmation has been given
\r
509 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
\r
510 $this->batchAskDeleteConfirmation('member',$selected);
\r
514 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
\r
515 echo '<h2>',_BATCH_MEMBERS,'</h2>';
\r
516 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
\r
519 // walk over all itemids and perform action
\r
520 foreach ($selected as $memberid) {
\r
521 $memberid = intval($memberid);
\r
522 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
\r
524 // perform action, display errors if needed
\r
527 $error = $this->deleteOneMember($memberid);
\r
531 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
\r
535 // there should always remain at least one super-admin
\r
536 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
\r
537 if (sql_num_rows($r) < 2)
\r
538 $error = _ERROR_ATLEASTONEADMIN;
\r
540 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
\r
543 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
\r
546 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
\r
551 echo '<b>',_BATCH_DONE,'</b>';
\r
559 * @todo document this
\r
561 function action_batchteam() {
\r
564 $blogid = intRequestVar('blogid');
\r
566 // check if logged in and admin
\r
567 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
\r
569 // get array of itemids from request
\r
570 $selected = requestIntArray('batch');
\r
571 $action = requestVar('batchaction');
\r
573 // Show error when no members selected
\r
574 if (!is_array($selected) || sizeof($selected) == 0)
\r
575 $this->error(_BATCH_NOSELECTION);
\r
577 // On delete: check if confirmation has been given
\r
578 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
\r
579 $this->batchAskDeleteConfirmation('team',$selected);
\r
583 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
\r
585 echo '<h2>',_BATCH_TEAM,'</h2>';
\r
586 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
\r
589 // walk over all itemids and perform action
\r
590 foreach ($selected as $memberid) {
\r
591 $memberid = intval($memberid);
\r
592 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
\r
594 // perform action, display errors if needed
\r
597 $error = $this->deleteOneTeamMember($blogid, $memberid);
\r
601 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
\r
605 // there should always remain at least one admin
\r
606 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
\r
607 if (sql_num_rows($r) < 2)
\r
608 $error = _ERROR_ATLEASTONEBLOGADMIN;
\r
610 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
\r
613 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
\r
616 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
\r
621 echo '<b>',_BATCH_DONE,'</b>';
\r
629 * @todo document this
\r
631 function action_batchcategory() {
\r
632 global $member, $manager;
\r
634 // check if logged in
\r
635 $member->isLoggedIn() or $this->disallow();
\r
637 // more precise check will be done for each performed operation
\r
639 // get array of itemids from request
\r
640 $selected = requestIntArray('batch');
\r
641 $action = requestVar('batchaction');
\r
643 // Show error when no items were selected
\r
644 if (!is_array($selected) || sizeof($selected) == 0)
\r
645 $this->error(_BATCH_NOSELECTION);
\r
647 // On move: when no destination blog chosen, show choice now
\r
648 $destBlogId = intRequestVar('destblogid');
\r
649 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
\r
650 $this->batchMoveCategorySelectDestination('category',$selected);
\r
652 // On delete: check if confirmation has been given
\r
653 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
\r
654 $this->batchAskDeleteConfirmation('category',$selected);
\r
658 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
\r
659 echo '<h2>',BATCH_CATEGORIES,'</h2>';
\r
660 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
\r
663 // walk over all itemids and perform action
\r
664 foreach ($selected as $catid) {
\r
665 $catid = intval($catid);
\r
666 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
\r
668 // perform action, display errors if needed
\r
671 $error = $this->deleteOneCategory($catid);
\r
674 $error = $this->moveOneCategory($catid, $destBlogId);
\r
677 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
\r
680 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
\r
685 echo '<b>',_BATCH_DONE,'</b>';
\r
692 * @todo document this
\r
694 function batchMoveSelectDestination($type, $ids) {
\r
698 <h2><?php echo _MOVE_TITLE?></h2>
\r
699 <form method="post" action="index.php"><div>
\r
701 <input type="hidden" name="action" value="batch<?php echo $type?>" />
\r
702 <input type="hidden" name="batchaction" value="move" />
\r
704 $manager->addTicketHidden();
\r
706 // insert selected item numbers
\r
708 foreach ($ids as $id)
\r
709 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
\r
711 // show blog/category selection list
\r
712 $this->selectBlogCategory('destcatid');
\r
717 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
\r
720 <?php $this->pagefoot();
\r
725 * @todo document this
\r
727 function batchMoveCategorySelectDestination($type, $ids) {
\r
731 <h2><?php echo _MOVECAT_TITLE?></h2>
\r
732 <form method="post" action="index.php"><div>
\r
734 <input type="hidden" name="action" value="batch<?php echo $type?>" />
\r
735 <input type="hidden" name="batchaction" value="move" />
\r
737 $manager->addTicketHidden();
\r
739 // insert selected item numbers
\r
741 foreach ($ids as $id)
\r
742 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
\r
744 // show blog/category selection list
\r
745 $this->selectBlog('destblogid');
\r
750 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
\r
753 <?php $this->pagefoot();
\r
758 * @todo document this
\r
760 function batchAskDeleteConfirmation($type, $ids) {
\r
765 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
\r
766 <form method="post" action="index.php"><div>
\r
768 <input type="hidden" name="action" value="batch<?php echo $type?>" />
\r
769 <?php $manager->addTicketHidden() ?>
\r
770 <input type="hidden" name="batchaction" value="delete" />
\r
771 <input type="hidden" name="confirmation" value="yes" />
\r
772 <?php // insert selected item numbers
\r
774 foreach ($ids as $id)
\r
775 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
\r
777 // add hidden vars for team & comment
\r
778 if ($type == 'team')
\r
780 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
\r
782 if ($type == 'comment')
\r
784 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
\r
789 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
\r
792 <?php $this->pagefoot();
\r
798 * Inserts a HTML select element with choices for all categories to which the current
\r
799 * member has access
\r
800 * @see function selectBlog
\r
802 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
\r
803 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
\r
807 * Inserts a HTML select element with choices for all blogs to which the user has access
\r
808 * mode = 'blog' => shows blognames and values are blogids
\r
809 * mode = 'category' => show category names and values are catids
\r
811 * @param $iForcedBlogInclude
\r
812 * ID of a blog that always needs to be included, without checking if the
\r
813 * member is on the blog team (-1 = none)
\r
814 * @todo document parameters
\r
816 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
\r
817 global $member, $CONF;
\r
819 // 0. get IDs of blogs to which member can post items (+ forced blog)
\r
820 $aBlogIds = array();
\r
821 if ($iForcedBlogInclude != -1)
\r
822 $aBlogIds[] = intval($iForcedBlogInclude);
\r
824 if (($member->isAdmin()) && (array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs']))
\r
825 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
\r
827 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
\r
828 $rblogids = sql_query($queryBlogs);
\r
829 while ($o = sql_fetch_object($rblogids))
\r
830 if ($o->bnumber != $iForcedBlogInclude)
\r
831 $aBlogIds[] = intval($o->bnumber);
\r
833 if (count($aBlogIds) == 0)
\r
836 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
\r
838 // 1. select blogs (we'll create optiongroups)
\r
839 // (only select those blogs that have the user on the team)
\r
840 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
\r
841 $blogs = sql_query($queryBlogs);
\r
842 if ($mode == 'category') {
\r
843 if (sql_num_rows($blogs) > 1)
\r
844 $multipleBlogs = 1;
\r
846 $multipleBlogs = 0;
\r
848 while ($oBlog = sql_fetch_object($blogs)) {
\r
849 if ($multipleBlogs)
\r
850 echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';
\r
852 // show selection to create new category when allowed/wanted
\r
854 // check if allowed to do so
\r
855 if ($member->blogAdminRights($oBlog->bnumber))
\r
856 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
\r
859 // 2. for each category in that blog
\r
860 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
\r
861 while ($oCat = sql_fetch_object($categories)) {
\r
862 if ($oCat->catid == $selected)
\r
863 $selectText = ' selected="selected" ';
\r
866 echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';
\r
869 if ($multipleBlogs)
\r
870 echo '</optgroup>';
\r
874 while ($oBlog = sql_fetch_object($blogs)) {
\r
875 echo '<option value="',$oBlog->bnumber,'"';
\r
876 if ($oBlog->bnumber == $selected)
\r
877 echo ' selected="selected"';
\r
878 echo'>',htmlspecialchars($oBlog->bname),'</option>';
\r
886 * @todo document this
\r
888 function action_browseownitems() {
\r
889 global $member, $manager, $CONF;
\r
893 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
894 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
\r
897 if (postVar('start'))
\r
898 $start = intPostVar('start');
\r
902 // amount of items to show
\r
903 if (postVar('amount'))
\r
904 $amount = intPostVar('amount');
\r
906 $amount = intval($CONF['DefaultListSize']);
\r
911 $search = postVar('search'); // search through items
\r
913 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
\r
914 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
\r
915 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
\r
918 $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
\r
920 $query .= ' ORDER BY itime DESC'
\r
921 . " LIMIT $start,$amount";
\r
923 $template['content'] = 'itemlist';
\r
924 $template['now'] = time();
\r
926 $manager->loadClass("ENCAPSULATE");
\r
927 $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
\r
928 $navList->showBatchList('item',$query,'table',$template);
\r
935 * Show all the comments for a given item
\r
936 * @param int $itemid
\r
938 function action_itemcommentlist($itemid = '') {
\r
939 global $member, $manager, $CONF;
\r
942 $itemid = intRequestVar('itemid');
\r
944 // only allow if user is allowed to alter item
\r
945 $member->canAlterItem($itemid) or $this->disallow();
\r
947 $blogid = getBlogIdFromItemId($itemid);
\r
952 if (postVar('start'))
\r
953 $start = intPostVar('start');
\r
957 // amount of items to show
\r
958 if (postVar('amount'))
\r
959 $amount = intPostVar('amount');
\r
961 $amount = intval($CONF['DefaultListSize']);
\r
966 $search = postVar('search');
\r
968 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
\r
969 echo '<h2>',_COMMENTS,'</h2>';
\r
971 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
\r
974 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
\r
976 $query .= ' ORDER BY ctime ASC'
\r
977 . " LIMIT $start,$amount";
\r
979 $template['content'] = 'commentlist';
\r
980 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
\r
982 $manager->loadClass("ENCAPSULATE");
\r
983 $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
\r
984 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
\r
990 * Browse own comments
\r
992 function action_browseowncomments() {
\r
993 global $member, $manager, $CONF;
\r
996 if (postVar('start'))
\r
997 $start = intPostVar('start');
\r
1001 // amount of items to show
\r
1002 if (postVar('amount'))
\r
1003 $amount = intPostVar('amount');
\r
1005 $amount = intval($CONF['DefaultListSize']);
\r
1010 $search = postVar('search');
\r
1013 $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();
\r
1016 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
\r
1018 $query .= ' ORDER BY ctime DESC'
\r
1019 . " LIMIT $start,$amount";
\r
1021 $this->pagehead();
\r
1023 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
1024 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
\r
1026 $template['content'] = 'commentlist';
\r
1027 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
\r
1029 $manager->loadClass("ENCAPSULATE");
\r
1030 $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
\r
1031 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
\r
1033 $this->pagefoot();
\r
1037 * Browse all comments for a weblog
\r
1038 * @param int $blogid
\r
1040 function action_blogcommentlist($blogid = '')
\r
1042 global $member, $manager, $CONF;
\r
1044 if ($blogid == '')
\r
1045 $blogid = intRequestVar('blogid');
\r
1047 $blogid = intval($blogid);
\r
1049 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
\r
1052 if (postVar('start'))
\r
1053 $start = intPostVar('start');
\r
1057 // amount of items to show
\r
1058 if (postVar('amount'))
\r
1059 $amount = intPostVar('amount');
\r
1061 $amount = intval($CONF['DefaultListSize']);
\r
1066 $search = postVar('search'); // search through comments
\r
1069 $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);
\r
1071 if ($search != '')
\r
1072 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
\r
1075 $query .= ' ORDER BY ctime DESC'
\r
1076 . " LIMIT $start,$amount";
\r
1079 $blog =& $manager->getBlog($blogid);
\r
1081 $this->pagehead();
\r
1083 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
1084 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
\r
1086 $template['content'] = 'commentlist';
\r
1087 $template['canAddBan'] = $member->blogAdminRights($blogid);
\r
1089 $manager->loadClass("ENCAPSULATE");
\r
1090 $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
\r
1091 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
\r
1093 $this->pagefoot();
\r
1097 * Provide a page to item a new item to the given blog
\r
1099 function action_createitem() {
\r
1100 global $member, $manager;
\r
1102 $blogid = intRequestVar('blogid');
\r
1104 // check if allowed
\r
1105 $member->teamRights($blogid) or $this->disallow();
\r
1107 $memberid = $member->getID();
\r
1109 $blog =& $manager->getBlog($blogid);
\r
1111 $this->pagehead();
\r
1113 // generate the add-item form
\r
1114 $formfactory = new PAGEFACTORY($blogid);
\r
1115 $formfactory->createAddForm('admin');
\r
1117 $this->pagefoot();
\r
1121 * @todo document this
\r
1123 function action_itemedit() {
\r
1124 global $member, $manager;
\r
1126 $itemid = intRequestVar('itemid');
\r
1128 // only allow if user is allowed to alter item
\r
1129 $member->canAlterItem($itemid) or $this->disallow();
\r
1131 $item =& $manager->getItem($itemid,1,1);
\r
1132 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
\r
1134 $param = array('item' => &$item);
\r
1135 $manager->notify('PrepareItemForEdit', $param);
\r
1137 if ($blog->convertBreaks()) {
\r
1138 $item['body'] = removeBreaks($item['body']);
\r
1139 $item['more'] = removeBreaks($item['more']);
\r
1142 // form to edit blog items
\r
1143 $this->pagehead();
\r
1144 $formfactory = new PAGEFACTORY($blog->getID());
\r
1145 $formfactory->createEditForm('admin',$item);
\r
1146 $this->pagefoot();
\r
1150 * @todo document this
\r
1152 function action_itemupdate() {
\r
1153 global $member, $manager, $CONF;
\r
1155 $itemid = intRequestVar('itemid');
\r
1156 $catid = postVar('catid');
\r
1158 // only allow if user is allowed to alter item
\r
1159 $member->canUpdateItem($itemid, $catid) or $this->disallow();
\r
1161 $actiontype = postVar('actiontype');
\r
1163 // delete actions are handled by itemdelete (which has confirmation)
\r
1164 if ($actiontype == 'delete') {
\r
1165 $this->action_itemdelete();
\r
1169 $body = postVar('body');
\r
1170 $title = postVar('title');
\r
1171 $more = postVar('more');
\r
1172 $closed = intPostVar('closed');
\r
1173 $draftid = intPostVar('draftid');
\r
1175 // default action = add now
\r
1177 $actiontype='addnow';
\r
1179 // create new category if needed
\r
1180 if (strstr($catid,'newcat')) {
\r
1182 list($blogid) = sscanf($catid,"newcat-%d");
\r
1185 $blog =& $manager->getBlog($blogid);
\r
1186 $catid = $blog->createNewCategory();
\r
1188 // show error when sth goes wrong
\r
1190 $this->doError(_ERROR_CATCREATEFAIL);
\r
1194 set some variables based on actiontype
\r
1197 draft items -> addnow, addfuture, adddraft, delete
\r
1198 non-draft items -> edit, changedate, delete
\r
1201 $timestamp: set to a nonzero value for future dates or date changes
\r
1202 $wasdraft: set to 1 when the item used to be a draft item
\r
1203 $publish: set to 1 when the edited item is not a draft
\r
1205 $blogid = getBlogIDFromItemID($itemid);
\r
1206 $blog =& $manager->getBlog($blogid);
\r
1208 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
\r
1209 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
\r
1210 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
\r
1211 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
\r
1212 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
\r
1217 // edit the item for real
\r
1218 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
\r
1220 $this->updateFuturePosted($blogid);
\r
1222 if ($draftid > 0) {
\r
1223 // delete permission is checked inside ITEM::delete()
\r
1224 ITEM::delete($draftid);
\r
1227 // show category edit window when we created a new category
\r
1228 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
\r
1229 if ($catid != intPostVar('catid')) {
\r
1230 $this->action_categoryedit(
\r
1233 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
\r
1236 // TODO: set start item correctly for itemlist
\r
1237 $this->action_itemlist(getBlogIDFromItemID($itemid));
\r
1242 * @todo document this
\r
1244 function action_itemdelete() {
\r
1245 global $member, $manager;
\r
1247 $itemid = intRequestVar('itemid');
\r
1249 // only allow if user is allowed to alter item
\r
1250 $member->canAlterItem($itemid) or $this->disallow();
\r
1252 if (!$manager->existsItem($itemid,1,1))
\r
1253 $this->error(_ERROR_NOSUCHITEM);
\r
1255 $item =& $manager->getItem($itemid,1,1);
\r
1256 $title = htmlspecialchars(strip_tags($item['title']));
\r
1257 $body = strip_tags($item['body']);
\r
1258 $body = htmlspecialchars(shorten($body,300,'...'));
\r
1260 $this->pagehead();
\r
1262 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
1264 <p><?php echo _CONFIRMTXT_ITEM?></p>
\r
1266 <div class="note">
\r
1267 <b>"<?php echo $title ?>"</b>
\r
1269 <?php echo $body?>
\r
1272 <form method="post" action="index.php"><div>
\r
1273 <input type="hidden" name="action" value="itemdeleteconfirm" />
\r
1274 <?php $manager->addTicketHidden() ?>
\r
1275 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
1276 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
\r
1279 $this->pagefoot();
\r
1283 * @todo document this
\r
1285 function action_itemdeleteconfirm() {
\r
1288 $itemid = intRequestVar('itemid');
\r
1290 // only allow if user is allowed to alter item
\r
1291 $member->canAlterItem($itemid) or $this->disallow();
\r
1293 // get blogid first
\r
1294 $blogid = getBlogIdFromItemId($itemid);
\r
1296 // delete item (note: some checks will be performed twice)
\r
1297 $this->deleteOneItem($itemid);
\r
1299 $this->action_itemlist($blogid);
\r
1303 * Deletes one item and returns error if something goes wrong
\r
1304 * @param int $itemid
\r
1306 function deleteOneItem($itemid) {
\r
1307 global $member, $manager;
\r
1309 // only allow if user is allowed to alter item (also checks if itemid exists)
\r
1310 if (!$member->canAlterItem($itemid))
\r
1311 return _ERROR_DISALLOWED;
\r
1313 // need to get blogid before the item is deleted
\r
1314 $blogid = getBlogIDFromItemId($itemid);
\r
1316 $manager->loadClass('ITEM');
\r
1317 ITEM::delete($itemid);
\r
1319 // update blog's futureposted
\r
1320 $this->updateFuturePosted($blogid);
\r
1324 * Update a blog's future posted flag
\r
1325 * @param int $blogid
\r
1327 function updateFuturePosted($blogid) {
\r
1330 $blog =& $manager->getBlog($blogid);
\r
1331 $currenttime = $blog->getCorrectTime(time());
\r
1332 $result = sql_query("SELECT * FROM ".sql_table('item').
\r
1333 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
\r
1334 if (sql_num_rows($result) > 0) {
\r
1335 $blog->setFuturePost();
\r
1338 $blog->clearFuturePost();
\r
1343 * @todo document this
\r
1345 function action_itemmove() {
\r
1346 global $member, $manager;
\r
1348 $itemid = intRequestVar('itemid');
\r
1350 // only allow if user is allowed to alter item
\r
1351 $member->canAlterItem($itemid) or $this->disallow();
\r
1353 $item =& $manager->getItem($itemid,1,1);
\r
1355 $this->pagehead();
\r
1357 <h2><?php echo _MOVE_TITLE?></h2>
\r
1358 <form method="post" action="index.php"><div>
\r
1359 <input type="hidden" name="action" value="itemmoveto" />
\r
1360 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
\r
1364 $manager->addTicketHidden();
\r
1365 $this->selectBlogCategory('catid',$item['catid'],10,1);
\r
1368 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
\r
1371 $this->pagefoot();
\r
1375 * @todo document this
\r
1377 function action_itemmoveto() {
\r
1378 global $member, $manager;
\r
1380 $itemid = intRequestVar('itemid');
\r
1381 $catid = requestVar('catid');
\r
1383 // create new category if needed
\r
1384 if (strstr($catid,'newcat')) {
\r
1386 list($blogid) = sscanf($catid,'newcat-%d');
\r
1389 $blog =& $manager->getBlog($blogid);
\r
1390 $catid = $blog->createNewCategory();
\r
1392 // show error when sth goes wrong
\r
1394 $this->doError(_ERROR_CATCREATEFAIL);
\r
1397 // only allow if user is allowed to alter item
\r
1398 $member->canUpdateItem($itemid, $catid) or $this->disallow();
\r
1400 $old_blogid = getBlogIDFromItemId($itemid);
\r
1402 ITEM::move($itemid, $catid);
\r
1404 // set the futurePosted flag on the blog
\r
1405 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
\r
1407 // reset the futurePosted in case the item is moved from one blog to another
\r
1408 $this->updateFuturePosted($old_blogid);
\r
1410 if ($catid != intRequestVar('catid'))
\r
1411 $this->action_categoryedit($catid, $blog->getID());
\r
1413 $this->action_itemlist(getBlogIDFromCatID($catid));
\r
1417 * Moves one item to a given category (category existance should be checked by caller)
\r
1418 * errors are returned
\r
1419 * @param int $itemid
\r
1420 * @param int $destCatid category ID to which the item will be moved
\r
1422 function moveOneItem($itemid, $destCatid) {
\r
1425 // only allow if user is allowed to move item
\r
1426 if (!$member->canUpdateItem($itemid, $destCatid))
\r
1427 return _ERROR_DISALLOWED;
\r
1429 ITEM::move($itemid, $destCatid);
\r
1433 * Adds a item to the chosen blog
\r
1435 function action_additem() {
\r
1436 global $manager, $CONF;
\r
1438 $manager->loadClass('ITEM');
\r
1440 $result = ITEM::createFromRequest();
\r
1442 if ($result['status'] == 'error')
\r
1443 $this->error($result['message']);
\r
1445 $blogid = getBlogIDFromItemID($result['itemid']);
\r
1446 $blog =& $manager->getBlog($blogid);
\r
1447 $btimestamp = $blog->getCorrectTime();
\r
1448 $item = $manager->getItem(intval($result['itemid']), 1, 1);
\r
1450 if ($result['status'] == 'newcategory') {
\r
1451 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
\r
1452 $this->action_categoryedit($result['catid'], $blogid, $distURI);
\r
1454 $methodName = 'action_itemList';
\r
1455 call_user_func(array($this, $methodName), $blogid);
\r
1460 * Allows to edit previously made comments
\r
1462 function action_commentedit() {
\r
1463 global $member, $manager;
\r
1465 $commentid = intRequestVar('commentid');
\r
1467 $member->canAlterComment($commentid) or $this->disallow();
\r
1469 $comment = COMMENT::getComment($commentid);
\r
1471 $param = array('comment' => &$comment);
\r
1472 $manager->notify('PrepareCommentForEdit', $param);
\r
1474 // change <br /> to \n
\r
1475 $comment['body'] = str_replace('<br />','',$comment['body']);
\r
1477 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
\r
1478 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
\r
1479 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
\r
1481 $this->pagehead();
\r
1484 <h2><?php echo _EDITC_TITLE?></h2>
\r
1486 <form action="index.php" method="post"><div>
\r
1488 <input type="hidden" name="action" value="commentupdate" />
\r
1489 <?php $manager->addTicketHidden(); ?>
\r
1490 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
\r
1492 <th colspan="2"><?php echo _EDITC_TITLE?></th>
\r
1494 <td><?php echo _EDITC_WHO?></td>
\r
1496 <?php if ($comment['member'])
\r
1497 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
\r
1499 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
\r
1503 <td><?php echo _EDITC_WHEN?></td>
\r
1504 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
\r
1506 <td><?php echo _EDITC_HOST?></td>
\r
1507 <td><?php echo $comment['host']; ?></td>
\r
1510 <td><?php echo _EDITC_URL; ?></td>
\r
1511 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
\r
1514 <td><?php echo _EDITC_EMAIL; ?></td>
\r
1515 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
\r
1518 <td><?php echo _EDITC_TEXT?></td>
\r
1520 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
\r
1521 echo $comment['body'];
\r
1525 <td><?php echo _EDITC_EDIT?></td>
\r
1526 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
\r
1531 $this->pagefoot();
\r
1535 * @todo document this
\r
1537 function action_commentupdate() {
\r
1538 global $member, $manager;
\r
1540 $commentid = intRequestVar('commentid');
\r
1542 $member->canAlterComment($commentid) or $this->disallow();
\r
1544 $url = postVar('url');
\r
1545 $email = postVar('email');
\r
1546 $body = postVar('body');
\r
1548 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
\r
1549 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
\r
1550 # important note that '\' must be matched with '\\\\' in preg* expressions
\r
1551 // intercept words that are too long
\r
1552 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
\r
1554 $this->error(_ERROR_COMMENT_LONGWORD);
\r
1558 if (strlen($body) < 3)
\r
1560 $this->error(_ERROR_COMMENT_NOCOMMENT);
\r
1562 if (strlen($body)>5000)
\r
1564 $this->error(_ERROR_COMMENT_TOOLONG);
\r
1568 $body = COMMENT::prepareBody($body);
\r
1571 $param = array('body' => &$body);
\r
1572 $manager->notify('PreUpdateComment', $param);
\r
1574 $query = 'UPDATE '.sql_table('comment')
\r
1575 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
\r
1576 . " WHERE cnumber=" . $commentid;
\r
1577 sql_query($query);
\r
1580 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
\r
1581 $o = sql_fetch_object($res);
\r
1582 $itemid = $o->citem;
\r
1584 if ($member->canAlterItem($itemid))
\r
1585 $this->action_itemcommentlist($itemid);
\r
1587 $this->action_browseowncomments();
\r
1592 * @todo document this
\r
1594 function action_commentdelete() {
\r
1595 global $member, $manager;
\r
1597 $commentid = intRequestVar('commentid');
\r
1599 $member->canAlterComment($commentid) or $this->disallow();
\r
1601 $comment = COMMENT::getComment($commentid);
\r
1603 $body = strip_tags($comment['body']);
\r
1604 $body = htmlspecialchars(shorten($body, 300, '...'));
\r
1606 if ($comment['member'])
\r
1607 $author = $comment['member'];
\r
1609 $author = $comment['user'];
\r
1611 $this->pagehead();
\r
1614 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
1616 <p><?php echo _CONFIRMTXT_COMMENT?></p>
\r
1618 <div class="note">
\r
1619 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
\r
1621 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
\r
1624 <form method="post" action="index.php"><div>
\r
1625 <input type="hidden" name="action" value="commentdeleteconfirm" />
\r
1626 <?php $manager->addTicketHidden() ?>
\r
1627 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
\r
1628 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
1631 $this->pagefoot();
\r
1635 * @todo document this
\r
1637 function action_commentdeleteconfirm() {
\r
1640 $commentid = intRequestVar('commentid');
\r
1642 // get item id first
\r
1643 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
\r
1644 $o = sql_fetch_object($res);
\r
1645 $itemid = $o->citem;
\r
1647 $error = $this->deleteOneComment($commentid);
\r
1649 $this->doError($error);
\r
1651 if ($member->canAlterItem($itemid))
\r
1652 $this->action_itemcommentlist($itemid);
\r
1654 $this->action_browseowncomments();
\r
1658 * @todo document this
\r
1660 function deleteOneComment($commentid) {
\r
1661 global $member, $manager;
\r
1663 $commentid = intval($commentid);
\r
1665 if (!$member->canAlterComment($commentid))
\r
1666 return _ERROR_DISALLOWED;
\r
1668 $param =array('commentid' => $commentid);
\r
1669 $manager->notify('PreDeleteComment', $param);
\r
1671 // delete the comments associated with the item
\r
1672 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
\r
1673 sql_query($query);
\r
1675 $param = array('commentid' => $commentid);
\r
1676 $manager->notify('PostDeleteComment', $param);
\r
1682 * Usermanagement main
\r
1684 function action_usermanagement() {
\r
1685 global $member, $manager;
\r
1687 // check if allowed
\r
1688 $member->isAdmin() or $this->disallow();
\r
1690 $this->pagehead();
\r
1692 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
1694 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
\r
1696 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
\r
1698 // show list of members with actions
\r
1699 $query = 'SELECT *'
\r
1700 . ' FROM '.sql_table('member');
\r
1701 $template['content'] = 'memberlist';
\r
1702 $template['tabindex'] = 10;
\r
1704 $manager->loadClass("ENCAPSULATE");
\r
1705 $batch = new BATCH('member');
\r
1706 $batch->showlist($query,'table',$template);
\r
1708 echo '<h3>' . _MEMBERS_NEW .'</h3>';
\r
1710 <form method="post" action="index.php" name="memberedit"><div>
\r
1712 <input type="hidden" name="action" value="memberadd" />
\r
1713 <?php $manager->addTicketHidden() ?>
\r
1717 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
\r
1719 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
\r
1720 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
\r
1722 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
\r
1724 <td><?php echo _MEMBERS_REALNAME?></td>
\r
1725 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
\r
1727 <td><?php echo _MEMBERS_PWD?></td>
\r
1728 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
\r
1730 <td><?php echo _MEMBERS_REPPWD?></td>
\r
1731 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
\r
1733 <td><?php echo _MEMBERS_EMAIL?></td>
\r
1734 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
\r
1736 <td><?php echo _MEMBERS_URL?></td>
\r
1737 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
\r
1739 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
\r
1740 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
\r
1742 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
\r
1743 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
\r
1745 <td><?php echo _MEMBERS_NOTES?></td>
\r
1746 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
\r
1748 <td><?php echo _MEMBERS_NEW?></td>
\r
1749 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
\r
1754 $this->pagefoot();
\r
1758 * Edit member settings
\r
1760 function action_memberedit() {
\r
1761 $this->action_editmembersettings(intRequestVar('memberid'));
\r
1765 * @todo document this
\r
1767 function action_editmembersettings($memberid = '') {
\r
1768 global $member, $manager, $CONF;
\r
1770 if ($memberid == '')
\r
1771 $memberid = $member->getID();
\r
1773 // check if allowed
\r
1774 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
\r
1776 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
\r
1777 $this->pagehead($extrahead);
\r
1779 // show message to go back to member overview (only for admins)
\r
1780 if ($member->isAdmin())
\r
1781 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
\r
1783 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
\r
1785 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
\r
1787 $mem = MEMBER::createFromID($memberid);
\r
1790 <form method="post" action="index.php" name="memberedit"><div>
\r
1792 <input type="hidden" name="action" value="changemembersettings" />
\r
1793 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
\r
1794 <?php $manager->addTicketHidden() ?>
\r
1797 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
\r
1799 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
\r
1800 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
\r
1803 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
\r
1804 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo htmlspecialchars($mem->getDisplayName()); ?>" />
\r
1806 echo htmlspecialchars($member->getDisplayName());
\r
1811 <td><?php echo _MEMBERS_REALNAME?></td>
\r
1812 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo htmlspecialchars($mem->getRealName()); ?>" /></td>
\r
1814 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
\r
1815 <td><?php echo _MEMBERS_PWD?></td>
\r
1816 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
\r
1818 <td><?php echo _MEMBERS_REPPWD?></td>
\r
1819 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
\r
1822 <td><?php echo _MEMBERS_EMAIL?>
\r
1823 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
\r
1825 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo htmlspecialchars($mem->getEmail()); ?>" /></td>
\r
1827 <td><?php echo _MEMBERS_URL?></td>
\r
1828 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getURL()); ?>" /></td>
\r
1829 <?php // only allow to change this by super-admins
\r
1830 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
\r
1831 if ($member->isAdmin()) {
\r
1834 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
\r
1835 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
\r
1837 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
\r
1838 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
\r
1841 <td><?php echo _MEMBERS_NOTES?></td>
\r
1842 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getNotes()); ?>" /></td>
\r
1844 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
\r
1848 <select name="deflang" tabindex="85">
\r
1849 <option value=""><?php echo _MEMBERS_USESITELANG?></option>
\r
1850 <?php // show a dropdown list of all available languages
\r
1852 $dirhandle = opendir($DIR_LANG);
\r
1853 while ($filename = readdir($dirhandle))
\r
1855 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
\r
1856 # original ereg: ereg("^(.*)\.php$", $filename, $matches)
\r
1857 if (preg_match('#^(.*)\.php$#', $filename, $matches) )
\r
1859 $name = $matches[1];
\r
1860 echo "<option value=\"$name\"";
\r
1861 if ($name == $mem->getLanguage() )
\r
1863 echo " selected=\"selected\"";
\r
1865 echo ">$name</option>";
\r
1868 closedir($dirhandle);
\r
1876 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
\r
1877 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
\r
1881 $this->_insertPluginOptions('member',$memberid);
\r
1884 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
\r
1886 <td><?php echo _MEMBERS_EDIT?></td>
\r
1887 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
\r
1893 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
\r
1895 $param = array('member' => &$mem);
\r
1896 $manager->notify('MemberSettingsFormExtras', $param);
\r
1898 $this->pagefoot();
\r
1902 * @todo document this
\r
1904 function action_changemembersettings() {
\r
1905 global $member, $CONF, $manager;
\r
1907 $memberid = intRequestVar('memberid');
\r
1909 // check if allowed
\r
1910 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
\r
1912 $name = trim(strip_tags(postVar('name')));
\r
1913 $realname = trim(strip_tags(postVar('realname')));
\r
1914 $password = postVar('password');
\r
1915 $repeatpassword = postVar('repeatpassword');
\r
1916 $email = strip_tags(postVar('email'));
\r
1917 $url = strip_tags(postVar('url'));
\r
1919 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
\r
1920 # original eregi: !eregi("^https?://", $url)
\r
1921 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
\r
1922 if (!preg_match('#^https?://#', $url) )
\r
1924 $url = 'http://' . $url;
\r
1926 $admin = postVar('admin');
\r
1927 $canlogin = postVar('canlogin');
\r
1928 $notes = strip_tags(postVar('notes'));
\r
1929 $deflang = postVar('deflang');
\r
1931 $mem = MEMBER::createFromID($memberid);
\r
1933 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
\r
1935 if (!isValidDisplayName($name))
\r
1936 $this->error(_ERROR_BADNAME);
\r
1938 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
\r
1939 $this->error(_ERROR_NICKNAMEINUSE);
\r
1941 if ($password != $repeatpassword)
\r
1942 $this->error(_ERROR_PASSWORDMISMATCH);
\r
1944 if ($password && (strlen($password) < 6))
\r
1945 $this->error(_ERROR_PASSWORDTOOSHORT);
\r
1951 'password' => $password,
\r
1952 'errormessage' => &$pwderror,
\r
1953 'valid' => &$pwdvalid
\r
1955 $manager->notify('PrePasswordSet', $param);
\r
1957 $this->error($pwderror);
\r
1962 if (!isValidMailAddress($email))
\r
1963 $this->error(_ERROR_BADMAILADDRESS);
\r
1967 $this->error(_ERROR_REALNAMEMISSING);
\r
1969 if (($deflang != '') && (!checkLanguage($deflang)))
\r
1970 $this->error(_ERROR_NOSUCHLANGUAGE);
\r
1972 // check if there will remain at least one site member with both the logon and admin rights
\r
1973 // (check occurs when taking away one of these rights from such a member)
\r
1974 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
\r
1975 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
\r
1978 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
\r
1979 if (sql_num_rows($r) < 2)
\r
1980 $this->error(_ERROR_ATLEASTONEADMIN);
\r
1983 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
\r
1984 $mem->setDisplayName($name);
\r
1986 $mem->setPassword($password);
\r
1989 $oldEmail = $mem->getEmail();
\r
1991 $mem->setRealName($realname);
\r
1992 $mem->setEmail($email);
\r
1993 $mem->setURL($url);
\r
1994 $mem->setNotes($notes);
\r
1995 $mem->setLanguage($deflang);
\r
1998 // only allow super-admins to make changes to the admin status
\r
1999 if ($member->isAdmin()) {
\r
2000 $mem->setAdmin($admin);
\r
2001 $mem->setCanLogin($canlogin);
\r
2004 $autosave = postVar ('autosave');
\r
2005 $mem->setAutosave($autosave);
\r
2009 // store plugin options
\r
2010 $aOptions = requestArray('plugoption');
\r
2011 NucleusPlugin::_applyPluginOptions($aOptions);
\r
2013 'context' => 'member',
\r
2014 'memberid' => $memberid,
\r
2017 $manager->notify('PostPluginOptionsUpdate', $param);
\r
2019 // if email changed, generate new password
\r
2020 if ($oldEmail != $mem->getEmail())
\r
2022 $mem->sendActivationLink('addresschange', $oldEmail);
\r
2024 $mem->newCookieKey();
\r
2026 // only log out if the member being edited is the current member.
\r
2027 if ($member->getID() == $memberid)
\r
2028 $member->logout();
\r
2029 $this->action_login(_MSG_ACTIVATION_SENT, 0);
\r
2034 if ( ( $mem->getID() == $member->getID() )
\r
2035 && ( $mem->getDisplayName() != $member->getDisplayName() )
\r
2037 $mem->newCookieKey();
\r
2038 $member->logout();
\r
2039 $this->action_login(_MSG_LOGINAGAIN, 0);
\r
2041 $this->action_overview(_MSG_SETTINGSCHANGED);
\r
2046 * @todo document this
\r
2048 function action_memberadd() {
\r
2049 global $member, $manager;
\r
2051 // check if allowed
\r
2052 $member->isAdmin() or $this->disallow();
\r
2054 if (postVar('password') != postVar('repeatpassword'))
\r
2055 $this->error(_ERROR_PASSWORDMISMATCH);
\r
2056 if (strlen(postVar('password')) < 6)
\r
2057 $this->error(_ERROR_PASSWORDTOOSHORT);
\r
2059 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
\r
2061 $this->error($res);
\r
2063 // fire PostRegister event
\r
2064 $newmem = new MEMBER();
\r
2065 $newmem->readFromName(postVar('name'));
\r
2066 $param = array('member' => &$newmem);
\r
2067 $manager->notify('PostRegister', $param);
\r
2069 $this->action_usermanagement();
\r
2073 * Account activation
\r
2077 function action_activate() {
\r
2079 $key = getVar('key');
\r
2080 $this->_showActivationPage($key);
\r
2084 * @todo document this
\r
2086 function _showActivationPage($key, $message = '')
\r
2090 // clean up old activation keys
\r
2091 MEMBER::cleanupActivationTable();
\r
2093 // get activation info
\r
2094 $info = MEMBER::getActivationInfo($key);
\r
2097 $this->error(_ERROR_ACTIVATE);
\r
2099 $mem = MEMBER::createFromId($info->vmember);
\r
2102 $this->error(_ERROR_ACTIVATE);
\r
2106 $bNeedsPasswordChange = true;
\r
2108 switch ($info->vtype)
\r
2111 $title = _ACTIVATE_FORGOT_TITLE;
\r
2112 $text = _ACTIVATE_FORGOT_TEXT;
\r
2115 $title = _ACTIVATE_REGISTER_TITLE;
\r
2116 $text = _ACTIVATE_REGISTER_TEXT;
\r
2118 case 'addresschange':
\r
2119 $title = _ACTIVATE_CHANGE_TITLE;
\r
2120 $text = _ACTIVATE_CHANGE_TEXT;
\r
2121 $bNeedsPasswordChange = false;
\r
2122 MEMBER::activate($key);
\r
2127 'memberName' => htmlspecialchars($mem->getDisplayName())
\r
2129 $title = TEMPLATE::fill($title, $aVars);
\r
2130 $text = TEMPLATE::fill($text, $aVars);
\r
2132 $this->pagehead();
\r
2134 echo '<h2>' , $title, '</h2>';
\r
2135 echo '<p>' , $text, '</p>';
\r
2137 if ($message != '')
\r
2139 echo '<p class="error">',$message,'</p>';
\r
2142 if ($bNeedsPasswordChange)
\r
2145 <div><form action="index.php" method="post">
\r
2147 <input type="hidden" name="action" value="activatesetpwd" />
\r
2148 <?php $manager->addTicketHidden() ?>
\r
2149 <input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />
\r
2152 <td><?php echo _MEMBERS_PWD?></td>
\r
2153 <td><input type="password" maxlength="40" size="16" name="password" /></td>
\r
2155 <td><?php echo _MEMBERS_REPPWD?></td>
\r
2156 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
\r
2161 'type' => 'activation',
\r
2164 $manager->notify('FormExtra', $param);
\r
2168 <td><?php echo _MEMBERS_SETPWD ?></td>
\r
2169 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
\r
2179 $this->pagefoot();
\r
2184 * Account activation - set password part
\r
2188 function action_activatesetpwd() {
\r
2190 $key = postVar('key');
\r
2192 // clean up old activation keys
\r
2193 MEMBER::cleanupActivationTable();
\r
2195 // get activation info
\r
2196 $info = MEMBER::getActivationInfo($key);
\r
2198 if (!$info || ($info->type == 'addresschange'))
\r
2199 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
\r
2201 $mem = MEMBER::createFromId($info->vmember);
\r
2204 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
\r
2206 $password = postVar('password');
\r
2207 $repeatpassword = postVar('repeatpassword');
\r
2210 return $this->_showActivationPage($key, _ERROR_PASSWORDMISSING);
\r
2213 if ($password != $repeatpassword) {
\r
2214 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
\r
2217 if (strlen($password) < 6) {
\r
2218 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
\r
2226 'password' => $password,
\r
2227 'errormessage' => &$pwderror,
\r
2228 'valid' => &$pwdvalid
\r
2230 $manager->notify('PrePasswordSet', $param);
\r
2233 return $this->_showActivationPage($key,$pwderror);
\r
2238 'type' => 'activation',
\r
2240 'error' => &$error
\r
2242 $manager->notify('ValidateForm', $param);
\r
2244 return $this->_showActivationPage($key, $error);
\r
2248 $mem->setPassword($password);
\r
2251 // do the activation
\r
2252 MEMBER::activate($key);
\r
2254 $this->pagehead();
\r
2255 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
\r
2256 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
\r
2257 $this->pagefoot();
\r
2263 function action_manageteam() {
\r
2264 global $member, $manager;
\r
2266 $blogid = intRequestVar('blogid');
\r
2268 // check if allowed
\r
2269 $member->blogAdminRights($blogid) or $this->disallow();
\r
2271 $this->pagehead();
\r
2273 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
\r
2275 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
\r
2277 echo '<h3>' . _TEAM_CURRENT . '</h3>';
\r
2281 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
\r
2282 . ' FROM '.sql_table('member').', '.sql_table('team')
\r
2283 . ' WHERE tmember=mnumber and tblog=' . $blogid;
\r
2285 $template['content'] = 'teamlist';
\r
2286 $template['tabindex'] = 10;
\r
2288 $manager->loadClass("ENCAPSULATE");
\r
2289 $batch = new BATCH('team');
\r
2290 $batch->showlist($query, 'table', $template);
\r
2293 <h3><?php echo _TEAM_ADDNEW?></h3>
\r
2295 <form method='post' action='index.php'><div>
\r
2297 <input type='hidden' name='action' value='teamaddmember' />
\r
2298 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
\r
2299 <?php $manager->addTicketHidden() ?>
\r
2302 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
\r
2303 <td><?php // TODO: try to make it so only non-team-members are listed
\r
2304 $query = 'SELECT mname as text, mnumber as value'
\r
2305 . ' FROM '.sql_table('member');
\r
2307 $template['name'] = 'memberid';
\r
2308 $template['tabindex'] = 10000;
\r
2309 showlist($query,'select',$template);
\r
2312 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
\r
2313 <td><?php $this->input_yesno('admin',0,10020); ?></td>
\r
2315 <td><?php echo _TEAM_ADD?></td>
\r
2316 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
\r
2321 $this->pagefoot();
\r
2325 * Add member to team
\r
2327 function action_teamaddmember() {
\r
2328 global $member, $manager;
\r
2330 $memberid = intPostVar('memberid');
\r
2331 $blogid = intPostVar('blogid');
\r
2332 $admin = intPostVar('admin');
\r
2334 // check if allowed
\r
2335 $member->blogAdminRights($blogid) or $this->disallow();
\r
2337 $blog =& $manager->getBlog($blogid);
\r
2338 if (!$blog->addTeamMember($memberid, $admin))
\r
2339 $this->error(_ERROR_ALREADYONTEAM);
\r
2341 $this->action_manageteam();
\r
2346 * @todo document this
\r
2348 function action_teamdelete() {
\r
2349 global $member, $manager;
\r
2351 $memberid = intRequestVar('memberid');
\r
2352 $blogid = intRequestVar('blogid');
\r
2354 // check if allowed
\r
2355 $member->blogAdminRights($blogid) or $this->disallow();
\r
2357 $teammem = MEMBER::createFromID($memberid);
\r
2358 $blog =& $manager->getBlog($blogid);
\r
2360 $this->pagehead();
\r
2362 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
2364 <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo htmlspecialchars($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo htmlspecialchars(strip_tags($blog->getName())) ?></b>
\r
2368 <form method="post" action="index.php"><div>
\r
2369 <input type="hidden" name="action" value="teamdeleteconfirm" />
\r
2370 <?php $manager->addTicketHidden() ?>
\r
2371 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
\r
2372 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
2373 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
2376 $this->pagefoot();
\r
2380 * @todo document this
\r
2382 function action_teamdeleteconfirm() {
\r
2385 $memberid = intRequestVar('memberid');
\r
2386 $blogid = intRequestVar('blogid');
\r
2388 $error = $this->deleteOneTeamMember($blogid, $memberid);
\r
2390 $this->error($error);
\r
2393 $this->action_manageteam();
\r
2397 * @todo document this
\r
2399 function deleteOneTeamMember($blogid, $memberid) {
\r
2400 global $member, $manager;
\r
2402 $blogid = intval($blogid);
\r
2403 $memberid = intval($memberid);
\r
2405 // check if allowed
\r
2406 if (!$member->blogAdminRights($blogid))
\r
2407 return _ERROR_DISALLOWED;
\r
2409 // check if: - there remains at least one blog admin
\r
2410 // - (there remains at least one team member)
\r
2411 $tmem = MEMBER::createFromID($memberid);
\r
2414 'member' => &$tmem,
\r
2415 'blogid' => $blogid
\r
2417 $manager->notify('PreDeleteTeamMember', $param);
\r
2419 if ($tmem->isBlogAdmin($blogid)) {
\r
2420 // check if there are more blog members left and at least one admin
\r
2421 // (check for at least two admins before deletion)
\r
2422 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
\r
2423 $r = sql_query($query);
\r
2424 if (sql_num_rows($r) < 2)
\r
2425 return _ERROR_ATLEASTONEBLOGADMIN;
\r
2428 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
\r
2429 sql_query($query);
\r
2432 'member' => &$tmem,
\r
2433 'blogid' => $blogid
\r
2435 $manager->notify('PostDeleteTeamMember', $param);
\r
2441 * @todo document this
\r
2443 function action_teamchangeadmin() {
\r
2446 $blogid = intRequestVar('blogid');
\r
2447 $memberid = intRequestVar('memberid');
\r
2449 // check if allowed
\r
2450 $member->blogAdminRights($blogid) or $this->disallow();
\r
2452 $mem = MEMBER::createFromID($memberid);
\r
2454 // don't allow when there is only one admin at this moment
\r
2455 if ($mem->isBlogAdmin($blogid)) {
\r
2456 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
\r
2457 if (sql_num_rows($r) == 1)
\r
2458 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
\r
2461 if ($mem->isBlogAdmin($blogid))
\r
2466 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
\r
2467 sql_query($query);
\r
2469 // only show manageteam if member did not change its own admin privileges
\r
2470 if ($member->isBlogAdmin($blogid))
\r
2471 $this->action_manageteam();
\r
2473 $this->action_overview(_MSG_ADMINCHANGED);
\r
2477 * @todo document this
\r
2479 function action_blogsettings() {
\r
2480 global $member, $manager;
\r
2482 $blogid = intRequestVar('blogid');
\r
2484 // check if allowed
\r
2485 $member->blogAdminRights($blogid) or $this->disallow();
\r
2487 $blog =& $manager->getBlog($blogid);
\r
2489 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
\r
2490 $this->pagehead($extrahead);
\r
2492 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
2494 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
\r
2496 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
\r
2498 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
\r
2500 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
\r
2501 $aMemberNames = array();
\r
2502 while ($o = sql_fetch_object($res))
\r
2503 array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');
\r
2504 echo implode(',', $aMemberNames);
\r
2511 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
\r
2514 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
\r
2516 <form method="post" action="index.php"><div>
\r
2518 <input type="hidden" name="action" value="blogsettingsupdate" />
\r
2519 <?php $manager->addTicketHidden() ?>
\r
2520 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
2522 <td><?php echo _EBLOG_NAME?></td>
\r
2523 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getName()) ?>" /></td>
\r
2525 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
\r
2526 <?php echo _EBLOG_SHORTNAME_EXTRA?>
\r
2528 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo htmlspecialchars($blog->getShortName()) ?>" /></td>
\r
2530 <td><?php echo _EBLOG_DESC?></td>
\r
2531 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo htmlspecialchars($blog->getDescription()) ?>" /></td>
\r
2533 <td><?php echo _EBLOG_URL?></td>
\r
2534 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo htmlspecialchars($blog->getURL()) ?>" /></td>
\r
2536 <td><?php echo _EBLOG_DEFSKIN?>
\r
2537 <?php help('blogdefaultskin'); ?>
\r
2541 $query = 'SELECT sdname as text, sdnumber as value'
\r
2542 . ' FROM '.sql_table('skin_desc');
\r
2543 $template['name'] = 'defskin';
\r
2544 $template['selected'] = $blog->getDefaultSkin();
\r
2545 $template['tabindex'] = 50;
\r
2546 showlist($query,'select',$template);
\r
2551 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
\r
2553 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
\r
2555 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
\r
2557 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
\r
2559 <td><?php echo _EBLOG_DISABLECOMMENTS?>
\r
2561 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
\r
2563 <td><?php echo _EBLOG_ANONYMOUS?>
\r
2565 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
\r
2567 <td><?php echo _EBLOG_REQUIREDEMAIL?>
\r
2569 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
\r
2571 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
\r
2572 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>
\r
2574 <td><?php echo _EBLOG_NOTIFY_ON?></td>
\r
2576 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
\r
2577 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
\r
2578 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
\r
2580 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
\r
2581 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
\r
2582 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
\r
2584 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
\r
2585 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
\r
2586 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
\r
2589 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
\r
2590 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo htmlspecialchars($blog->getMaxComments()); ?>" /></td>
\r
2592 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
\r
2593 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getUpdateFile()) ?>" /></td>
\r
2595 <td><?php echo _EBLOG_DEFCAT?></td>
\r
2598 $query = 'SELECT cname as text, catid as value'
\r
2599 . ' FROM '.sql_table('category')
\r
2600 . ' WHERE cblog=' . $blog->getID();
\r
2601 $template['name'] = 'defcat';
\r
2602 $template['selected'] = $blog->getDefaultCategory();
\r
2603 $template['tabindex'] = 110;
\r
2604 showlist($query,'select',$template);
\r
2608 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
\r
2609 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
\r
2610 <br /><?php echo _EBLOG_BTIME?> <b><?php echo strftime("%H:%M",$blog->getCorrectTime()); ?></b>
\r
2612 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo htmlspecialchars($blog->getTimeOffset()); ?>" /></td>
\r
2614 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
\r
2615 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
\r
2619 $this->_insertPluginOptions('blog',$blogid);
\r
2622 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
\r
2624 <td><?php echo _EBLOG_CHANGE?></td>
\r
2625 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
\r
2630 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
\r
2634 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
\r
2635 $template['content'] = 'categorylist';
\r
2636 $template['tabindex'] = 200;
\r
2638 $manager->loadClass("ENCAPSULATE");
\r
2639 $batch = new BATCH('category');
\r
2640 $batch->showlist($query,'table',$template);
\r
2645 <form action="index.php" method="post"><div>
\r
2646 <input name="action" value="categorynew" type="hidden" />
\r
2647 <?php $manager->addTicketHidden() ?>
\r
2648 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
\r
2651 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
\r
2653 <td><?php echo _EBLOG_CAT_NAME?></td>
\r
2654 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
\r
2656 <td><?php echo _EBLOG_CAT_DESC?></td>
\r
2657 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
\r
2659 <td><?php echo _EBLOG_CAT_CREATE?></td>
\r
2660 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
\r
2667 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
\r
2669 $param = array('blog' => &$blog);
\r
2670 $manager->notify('BlogSettingsFormExtras', $param);
\r
2672 $this->pagefoot();
\r
2676 * @todo document this
\r
2678 function action_categorynew() {
\r
2679 global $member, $manager;
\r
2681 $blogid = intRequestVar('blogid');
\r
2683 $member->blogAdminRights($blogid) or $this->disallow();
\r
2685 $cname = postVar('cname');
\r
2686 $cdesc = postVar('cdesc');
\r
2688 if (!isValidCategoryName($cname))
\r
2689 $this->error(_ERROR_BADCATEGORYNAME);
\r
2691 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
\r
2692 $res = sql_query($query);
\r
2693 if (sql_num_rows($res) > 0)
\r
2694 $this->error(_ERROR_DUPCATEGORYNAME);
\r
2696 $blog =& $manager->getBlog($blogid);
\r
2697 $newCatID = $blog->createNewCategory($cname, $cdesc);
\r
2699 $this->action_blogsettings();
\r
2703 * @todo document this
\r
2705 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
\r
2706 global $member, $manager;
\r
2708 if ($blogid == '')
\r
2709 $blogid = intGetVar('blogid');
\r
2711 $blogid = intval($blogid);
\r
2713 $catid = intGetVar('catid');
\r
2715 $catid = intval($catid);
\r
2717 $member->blogAdminRights($blogid) or $this->disallow();
\r
2719 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
\r
2720 $obj = sql_fetch_object($res);
\r
2722 $cname = $obj->cname;
\r
2723 $cdesc = $obj->cdesc;
\r
2725 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
\r
2726 $this->pagehead($extrahead);
\r
2728 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
\r
2731 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>
\r
2732 <form method='post' action='index.php'><div>
\r
2733 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
\r
2734 <input name="catid" type="hidden" value="<?php echo $catid?>" />
\r
2735 <input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />
\r
2736 <input name="action" type="hidden" value="categoryupdate" />
\r
2737 <?php $manager->addTicketHidden(); ?>
\r
2740 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
\r
2742 <td><?php echo _EBLOG_CAT_NAME?></td>
\r
2743 <td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>
\r
2745 <td><?php echo _EBLOG_CAT_DESC?></td>
\r
2746 <td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>
\r
2749 // insert plugin options
\r
2750 $this->_insertPluginOptions('category',$catid);
\r
2753 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
\r
2755 <td><?php echo _EBLOG_CAT_UPDATE?></td>
\r
2756 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
\r
2761 $this->pagefoot();
\r
2765 * @todo document this
\r
2767 function action_categoryupdate() {
\r
2768 global $member, $manager;
\r
2770 $blogid = intPostVar('blogid');
\r
2771 $catid = intPostVar('catid');
\r
2772 $cname = postVar('cname');
\r
2773 $cdesc = postVar('cdesc');
\r
2774 $desturl = postVar('desturl');
\r
2776 $member->blogAdminRights($blogid) or $this->disallow();
\r
2778 if (!isValidCategoryName($cname))
\r
2779 $this->error(_ERROR_BADCATEGORYNAME);
\r
2781 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
\r
2782 $res = sql_query($query);
\r
2783 if (sql_num_rows($res) > 0)
\r
2784 $this->error(_ERROR_DUPCATEGORYNAME);
\r
2786 $query = 'UPDATE '.sql_table('category').' SET'
\r
2787 . " cname='" . sql_real_escape_string($cname) . "',"
\r
2788 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
\r
2789 . " WHERE catid=" . $catid;
\r
2791 sql_query($query);
\r
2793 // store plugin options
\r
2794 $aOptions = requestArray('plugoption');
\r
2795 NucleusPlugin::_applyPluginOptions($aOptions);
\r
2797 'context' => 'category',
\r
2800 $manager->notify('PostPluginOptionsUpdate', $param);
\r
2804 redirect($desturl);
\r
2807 $this->action_blogsettings();
\r
2812 * @todo document this
\r
2814 function action_categorydelete() {
\r
2815 global $member, $manager;
\r
2817 $blogid = intRequestVar('blogid');
\r
2818 $catid = intRequestVar('catid');
\r
2820 $member->blogAdminRights($blogid) or $this->disallow();
\r
2822 $blog =& $manager->getBlog($blogid);
\r
2824 // check if the category is valid
\r
2825 if (!$blog->isValidCategory($catid))
\r
2826 $this->error(_ERROR_NOSUCHCATEGORY);
\r
2828 // don't allow deletion of default category
\r
2829 if ($blog->getDefaultCategory() == $catid)
\r
2830 $this->error(_ERROR_DELETEDEFCATEGORY);
\r
2832 // check if catid is the only category left for blogid
\r
2833 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
\r
2834 $res = sql_query($query);
\r
2835 if (sql_num_rows($res) == 1)
\r
2836 $this->error(_ERROR_DELETELASTCATEGORY);
\r
2839 $this->pagehead();
\r
2841 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
2844 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo htmlspecialchars($blog->getCategoryName($catid))?></b>
\r
2847 <form method="post" action="index.php"><div>
\r
2848 <input type="hidden" name="action" value="categorydeleteconfirm" />
\r
2849 <?php $manager->addTicketHidden() ?>
\r
2850 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
\r
2851 <input type="hidden" name="catid" value="<?php echo $catid?>" />
\r
2852 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
2855 $this->pagefoot();
\r
2859 * @todo document this
\r
2861 function action_categorydeleteconfirm() {
\r
2862 global $member, $manager;
\r
2864 $blogid = intRequestVar('blogid');
\r
2865 $catid = intRequestVar('catid');
\r
2867 $member->blogAdminRights($blogid) or $this->disallow();
\r
2869 $error = $this->deleteOneCategory($catid);
\r
2871 $this->error($error);
\r
2873 $this->action_blogsettings();
\r
2877 * @todo document this
\r
2879 function deleteOneCategory($catid) {
\r
2880 global $manager, $member;
\r
2882 $catid = intval($catid);
\r
2884 $blogid = getBlogIDFromCatID($catid);
\r
2886 if (!$member->blogAdminRights($blogid))
\r
2887 return ERROR_DISALLOWED;
\r
2890 $blog =& $manager->getBlog($blogid);
\r
2892 // check if the category is valid
\r
2893 if (!$blog || !$blog->isValidCategory($catid))
\r
2894 return _ERROR_NOSUCHCATEGORY;
\r
2896 $destcatid = $blog->getDefaultCategory();
\r
2898 // don't allow deletion of default category
\r
2899 if ($blog->getDefaultCategory() == $catid)
\r
2900 return _ERROR_DELETEDEFCATEGORY;
\r
2902 // check if catid is the only category left for blogid
\r
2903 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
\r
2904 $res = sql_query($query);
\r
2905 if (sql_num_rows($res) == 1)
\r
2906 return _ERROR_DELETELASTCATEGORY;
\r
2908 $param = array('catid' => $catid);
\r
2909 $manager->notify('PreDeleteCategory', $param);
\r
2911 // change category for all items to the default category
\r
2912 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
\r
2913 sql_query($query);
\r
2915 // delete all associated plugin options
\r
2916 NucleusPlugin::_deleteOptionValues('category', $catid);
\r
2918 // delete category
\r
2919 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
\r
2920 sql_query($query);
\r
2922 $param = array('catid' => $catid);
\r
2923 $manager->notify('PostDeleteCategory', $param);
\r
2928 * @todo document this
\r
2930 function moveOneCategory($catid, $destblogid) {
\r
2931 global $manager, $member;
\r
2933 $catid = intval($catid);
\r
2934 $destblogid = intval($destblogid);
\r
2936 $blogid = getBlogIDFromCatID($catid);
\r
2938 // mover should have admin rights on both blogs
\r
2939 if (!$member->blogAdminRights($blogid))
\r
2940 return _ERROR_DISALLOWED;
\r
2941 if (!$member->blogAdminRights($destblogid))
\r
2942 return _ERROR_DISALLOWED;
\r
2944 // cannot move to self
\r
2945 if ($blogid == $destblogid)
\r
2946 return _ERROR_MOVETOSELF;
\r
2949 $blog =& $manager->getBlog($blogid);
\r
2950 $destblog =& $manager->getBlog($destblogid);
\r
2952 // check if the category is valid
\r
2953 if (!$blog || !$blog->isValidCategory($catid))
\r
2954 return _ERROR_NOSUCHCATEGORY;
\r
2956 // don't allow default category to be moved
\r
2957 if ($blog->getDefaultCategory() == $catid)
\r
2958 return _ERROR_MOVEDEFCATEGORY;
\r
2961 'catid' => &$catid,
\r
2962 'sourceblog' => &$blog,
\r
2963 'destblog' => &$destblog
\r
2965 $manager->notify('PreMoveCategory', $param);
\r
2967 // update comments table (cblog)
\r
2968 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
\r
2969 $items = sql_query($query);
\r
2970 while ($oItem = sql_fetch_object($items)) {
\r
2971 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
\r
2974 // update items (iblog)
\r
2975 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
\r
2976 sql_query($query);
\r
2979 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
\r
2980 sql_query($query);
\r
2983 'catid' => &$catid,
\r
2984 'sourceblog' => &$blog,
\r
2985 'destblog' => $destblog
\r
2987 $manager->notify('PostMoveCategory', $param);
\r
2992 * @todo document this
\r
2994 function action_blogsettingsupdate() {
\r
2995 global $member, $manager;
\r
2997 $blogid = intRequestVar('blogid');
\r
2999 $member->blogAdminRights($blogid) or $this->disallow();
\r
3001 $blog =& $manager->getBlog($blogid);
\r
3003 $notify = trim(postVar('notify'));
\r
3004 $shortname = trim(postVar('shortname'));
\r
3005 $updatefile = trim(postVar('update'));
\r
3007 $notifyComment = intPostVar('notifyComment');
\r
3008 $notifyVote = intPostVar('notifyVote');
\r
3009 $notifyNewItem = intPostVar('notifyNewItem');
\r
3011 if ($notifyComment == 0) $notifyComment = 1;
\r
3012 if ($notifyVote == 0) $notifyVote = 1;
\r
3013 if ($notifyNewItem == 0) $notifyNewItem = 1;
\r
3015 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
\r
3019 $not = new NOTIFICATION($notify);
\r
3020 if (!$not->validAddresses())
\r
3021 $this->error(_ERROR_BADNOTIFY);
\r
3025 if (!isValidShortName($shortname))
\r
3026 $this->error(_ERROR_BADSHORTBLOGNAME);
\r
3028 if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
\r
3029 $this->error(_ERROR_DUPSHORTBLOGNAME);
\r
3031 // check if update file is writable
\r
3032 if ($updatefile && !is_writeable($updatefile))
\r
3033 $this->error(_ERROR_UPDATEFILE);
\r
3035 $blog->setName(trim(postVar('name')));
\r
3036 $blog->setShortName($shortname);
\r
3037 $blog->setNotifyAddress($notify);
\r
3038 $blog->setNotifyType($notifyType);
\r
3039 $blog->setMaxComments(postVar('maxcomments'));
\r
3040 $blog->setCommentsEnabled(postVar('comments'));
\r
3041 $blog->setTimeOffset(postVar('timeoffset'));
\r
3042 $blog->setUpdateFile($updatefile);
\r
3043 $blog->setURL(trim(postVar('url')));
\r
3044 $blog->setDefaultSkin(intPostVar('defskin'));
\r
3045 $blog->setDescription(trim(postVar('desc')));
\r
3046 $blog->setPublic(postVar('public'));
\r
3047 $blog->setConvertBreaks(intPostVar('convertbreaks'));
\r
3048 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
\r
3049 $blog->setDefaultCategory(intPostVar('defcat'));
\r
3050 $blog->setSearchable(intPostVar('searchable'));
\r
3051 $blog->setEmailRequired(intPostVar('reqemail'));
\r
3053 $blog->writeSettings();
\r
3055 // store plugin options
\r
3056 $aOptions = requestArray('plugoption');
\r
3057 NucleusPlugin::_applyPluginOptions($aOptions);
\r
3059 'context' => 'blog',
\r
3060 'blogid' => $blogid,
\r
3063 $manager->notify('PostPluginOptionsUpdate', $param);
\r
3066 $this->action_overview(_MSG_SETTINGSCHANGED);
\r
3070 * @todo document this
\r
3072 function action_deleteblog() {
\r
3073 global $member, $CONF, $manager;
\r
3075 $blogid = intRequestVar('blogid');
\r
3077 $member->blogAdminRights($blogid) or $this->disallow();
\r
3079 // check if blog is default blog
\r
3080 if ($CONF['DefaultBlog'] == $blogid)
\r
3081 $this->error(_ERROR_DELDEFBLOG);
\r
3083 $blog =& $manager->getBlog($blogid);
\r
3085 $this->pagehead();
\r
3087 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
3089 <p><?php echo _WARNINGTXT_BLOGDEL?>
\r
3093 <?php echo _CONFIRMTXT_BLOG?><b><?php echo htmlspecialchars($blog->getName())?></b>
\r
3096 <form method="post" action="index.php"><div>
\r
3097 <input type="hidden" name="action" value="deleteblogconfirm" />
\r
3098 <?php $manager->addTicketHidden() ?>
\r
3099 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
\r
3100 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
3103 $this->pagefoot();
\r
3107 * @todo document this
\r
3109 function action_deleteblogconfirm() {
\r
3110 global $member, $CONF, $manager;
\r
3112 $blogid = intRequestVar('blogid');
\r
3114 $param = array('blogid' => $blogid);
\r
3115 $manager->notify('PreDeleteBlog', $param);
\r
3117 $member->blogAdminRights($blogid) or $this->disallow();
\r
3119 // check if blog is default blog
\r
3120 if ($CONF['DefaultBlog'] == $blogid)
\r
3121 $this->error(_ERROR_DELDEFBLOG);
\r
3123 // delete all comments
\r
3124 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
\r
3125 sql_query($query);
\r
3127 // delete all items
\r
3128 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
\r
3129 sql_query($query);
\r
3131 // delete all team members
\r
3132 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
\r
3133 sql_query($query);
\r
3135 // delete all bans
\r
3136 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
\r
3137 sql_query($query);
\r
3139 // delete all categories
\r
3140 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
\r
3141 sql_query($query);
\r
3143 // delete all associated plugin options
\r
3144 NucleusPlugin::_deleteOptionValues('blog', $blogid);
\r
3146 // delete the blog itself
\r
3147 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
\r
3148 sql_query($query);
\r
3150 $param = array('blogid' => $blogid);
\r
3151 $manager->notify('PostDeleteBlog', $param);
\r
3153 $this->action_overview(_DELETED_BLOG);
\r
3157 * @todo document this
\r
3159 function action_memberdelete() {
\r
3160 global $member, $manager;
\r
3162 $memberid = intRequestVar('memberid');
\r
3164 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
\r
3166 $mem = MEMBER::createFromID($memberid);
\r
3168 $this->pagehead();
\r
3170 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
3172 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo htmlspecialchars($mem->getDisplayName()) ?></b>
\r
3176 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
\r
3179 <form method="post" action="index.php"><div>
\r
3180 <input type="hidden" name="action" value="memberdeleteconfirm" />
\r
3181 <?php $manager->addTicketHidden() ?>
\r
3182 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
\r
3183 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
3186 $this->pagefoot();
\r
3190 * @todo document this
\r
3192 function action_memberdeleteconfirm() {
\r
3195 $memberid = intRequestVar('memberid');
\r
3197 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
\r
3199 $error = $this->deleteOneMember($memberid);
\r
3201 $this->error($error);
\r
3203 if ($member->isAdmin())
\r
3204 $this->action_usermanagement();
\r
3206 $this->action_overview(_DELETED_MEMBER);
\r
3211 * @todo document this
\r
3213 function deleteOneMember($memberid) {
\r
3216 $memberid = intval($memberid);
\r
3217 $mem = MEMBER::createFromID($memberid);
\r
3219 if (!$mem->canBeDeleted())
\r
3220 return _ERROR_DELETEMEMBER;
\r
3222 $param = array('member' => &$mem);
\r
3223 $manager->notify('PreDeleteMember', $param);
\r
3225 /* unlink comments from memberid */
\r
3227 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())
\r
3228 .'" WHERE cmember='.$memberid;
\r
3229 sql_query($query);
\r
3232 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
\r
3233 sql_query($query);
\r
3235 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
\r
3236 sql_query($query);
\r
3238 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
\r
3239 sql_query($query);
\r
3241 // delete all associated plugin options
\r
3242 NucleusPlugin::_deleteOptionValues('member', $memberid);
\r
3244 $param = array('member' => &$mem);
\r
3245 $manager->notify('PostDeleteMember', $param);
\r
3251 * @todo document this
\r
3253 function action_createnewlog() {
\r
3254 global $member, $CONF, $manager;
\r
3256 // Only Super-Admins can do this
\r
3257 $member->isAdmin() or $this->disallow();
\r
3259 $this->pagehead();
\r
3261 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
3263 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
\r
3265 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
\r
3267 <p><?php echo _ADMIN_PLEASE_READ ?></p>
\r
3269 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
\r
3272 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
\r
3273 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
\r
3276 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
\r
3279 <?php echo _EBLOG_CREATE_TEXT?>
\r
3282 <form method="post" action="index.php"><div>
\r
3284 <input type="hidden" name="action" value="addnewlog" />
\r
3285 <?php $manager->addTicketHidden() ?>
\r
3289 <td><?php echo _EBLOG_NAME?></td>
\r
3290 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
\r
3292 <td><?php echo _EBLOG_SHORTNAME?>
\r
3293 <?php help('shortblogname'); ?>
\r
3295 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
\r
3297 <td><?php echo _EBLOG_DESC?></td>
\r
3298 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
\r
3300 <td><?php echo _EBLOG_DEFSKIN?>
\r
3301 <?php help('blogdefaultskin'); ?>
\r
3305 $query = 'SELECT sdname as text, sdnumber as value'
\r
3306 . ' FROM '.sql_table('skin_desc');
\r
3307 $template['name'] = 'defskin';
\r
3308 $template['tabindex'] = 50;
\r
3309 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
\r
3310 showlist($query,'select',$template);
\r
3314 <td><?php echo _EBLOG_OFFSET?>
\r
3315 <?php help('blogtimeoffset'); ?>
\r
3316 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
\r
3318 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
\r
3320 <td><?php echo _EBLOG_ADMIN?>
\r
3321 <?php help('teamadmin'); ?>
\r
3323 <td><?php echo _EBLOG_ADMIN_MSG?></td>
\r
3325 <td><?php echo _EBLOG_CREATE?></td>
\r
3326 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
\r
3331 $this->pagefoot();
\r
3335 * @todo document this
\r
3337 function action_addnewlog() {
\r
3338 global $member, $manager, $CONF;
\r
3340 // Only Super-Admins can do this
\r
3341 $member->isAdmin() or $this->disallow();
\r
3343 $bname = trim(postVar('name'));
\r
3344 $bshortname = trim(postVar('shortname'));
\r
3345 $btimeoffset = postVar('timeoffset');
\r
3346 $bdesc = trim(postVar('desc'));
\r
3347 $bdefskin = postVar('defskin');
\r
3349 if (!isValidShortName($bshortname))
\r
3350 $this->error(_ERROR_BADSHORTBLOGNAME);
\r
3352 if ($manager->existsBlog($bshortname))
\r
3353 $this->error(_ERROR_DUPSHORTBLOGNAME);
\r
3356 'name' => &$bname,
\r
3357 'shortname' => &$bshortname,
\r
3358 'timeoffset' => &$btimeoffset,
\r
3359 'description' => &$bdesc,
\r
3360 'defaultskin' => &$bdefskin
\r
3362 $manager->notify('PreAddBlog', $param);
\r
3365 // add slashes for sql queries
\r
3366 $bname = sql_real_escape_string($bname);
\r
3367 $bshortname = sql_real_escape_string($bshortname);
\r
3368 $btimeoffset = sql_real_escape_string($btimeoffset);
\r
3369 $bdesc = sql_real_escape_string($bdesc);
\r
3370 $bdefskin = sql_real_escape_string($bdefskin);
\r
3373 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
\r
3374 sql_query($query);
\r
3375 $blogid = sql_insert_id();
\r
3376 $blog =& $manager->getBlog($blogid);
\r
3378 // create new category
\r
3379 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
\r
3380 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
\r
3381 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
\r
3382 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
\r
3383 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
\r
3384 $catid = sql_insert_id();
\r
3386 // set as default category
\r
3387 $blog->setDefaultCategory($catid);
\r
3388 $blog->writeSettings();
\r
3390 // create team member
\r
3391 $memberid = $member->getID();
\r
3392 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
\r
3393 sql_query($query);
\r
3395 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
\r
3396 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
\r
3398 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
\r
3399 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
\r
3405 $manager->notify('PostAddBlog', $param);
\r
3409 'name' => _EBLOGDEFAULTCATEGORY_NAME,
\r
3410 'description' => _EBLOGDEFAULTCATEGORY_DESC,
\r
3413 $manager->notify('PostAddCategory', $param);
\r
3415 $this->pagehead();
\r
3417 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
\r
3419 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, htmlspecialchars($bname)) ?></p>
\r
3422 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, htmlspecialchars($bshortname)) ?></a></li>
\r
3423 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
\r
3426 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, htmlspecialchars($bshortname)) ?></a></h3>
\r
3428 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, htmlspecialchars($bshortname)) ?></p>
\r
3429 <pre><code><?php
\r
3430 include('./benchmark.inc');
\r
3432 $CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';
\r
3434 include('<i>./config.php</i>');
\r
3436 selectBlog('<b><?php echo htmlspecialchars($bshortname)?></b>');
\r
3439 ?></code></pre>
\r
3441 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
\r
3443 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
\r
3445 <form action="index.php" method="post"><div>
\r
3446 <input type="hidden" name="action" value="addnewlog2" />
\r
3447 <?php $manager->addTicketHidden() ?>
\r
3448 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
\r
3450 <td><?php echo _EBLOG_URL?></td>
\r
3451 <td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
\r
3453 <td><?php echo _EBLOG_CREATE?></td>
\r
3454 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
\r
3458 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
\r
3460 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
\r
3462 <form action="index.php" method="post"><div>
\r
3463 <input type="hidden" name="action" value="addnewlog2" />
\r
3464 <?php $manager->addTicketHidden() ?>
\r
3465 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
\r
3467 <td><?php echo _EBLOG_URL?></td>
\r
3468 <td><input name="url" maxlength="100" size="40" /></td>
\r
3470 <td><?php echo _EBLOG_CREATE?></td>
\r
3471 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
\r
3475 <?php $this->pagefoot();
\r
3480 * @todo document this
\r
3482 function action_addnewlog2() {
\r
3483 global $member, $manager;
\r
3485 $member->blogAdminRights($blogid) or $this->disallow();
\r
3487 $burl = requestVar('url');
\r
3488 $blogid = intRequestVar('blogid');
\r
3490 $blog =& $manager->getBlog($blogid);
\r
3491 $blog->setURL(trim($burl));
\r
3492 $blog->writeSettings();
\r
3494 $this->action_overview(_MSG_NEWBLOG);
\r
3498 * @todo document this
\r
3500 function action_skinieoverview() {
\r
3501 global $member, $DIR_LIBS, $manager;
\r
3503 $member->isAdmin() or $this->disallow();
\r
3505 // load skinie class
\r
3506 include_once($DIR_LIBS . 'skinie.php');
\r
3508 $this->pagehead();
\r
3510 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
3513 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
\r
3515 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
\r
3516 <?php global $DIR_SKINS;
\r
3518 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
\r
3520 if (sizeof($candidates) > 0) {
\r
3522 <form method="post" action="index.php"><div>
\r
3523 <input type="hidden" name="action" value="skinieimport" />
\r
3524 <?php $manager->addTicketHidden() ?>
\r
3525 <input type="hidden" name="mode" value="file" />
\r
3526 <select name="skinfile" id="skinie_import_local">
\r
3527 <?php foreach ($candidates as $skinname => $skinfile) {
\r
3528 $html = htmlspecialchars($skinfile);
\r
3529 echo '<option value="',$html,'">',$skinname,'</option>';
\r
3533 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
\r
3536 echo _SKINIE_NOCANDIDATES;
\r
3541 <p><em><?php echo _OR?></em></p>
\r
3543 <form method="post" action="index.php"><p>
\r
3544 <?php $manager->addTicketHidden() ?>
\r
3545 <input type="hidden" name="action" value="skinieimport" />
\r
3546 <input type="hidden" name="mode" value="url" />
\r
3547 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
\r
3548 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
\r
3549 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
\r
3553 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
\r
3554 <form method="post" action="index.php"><div>
\r
3555 <input type="hidden" name="action" value="skinieexport" />
\r
3556 <?php $manager->addTicketHidden() ?>
\r
3558 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
\r
3561 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
\r
3563 <?php // show list of skins
\r
3564 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
\r
3565 while ($skinObj = sql_fetch_object($res)) {
\r
3566 $id = 'skinexp' . $skinObj->sdnumber;
\r
3567 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
\r
3568 echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';
\r
3569 echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';
\r
3573 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
\r
3575 // show list of templates
\r
3576 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
\r
3577 while ($templateObj = sql_fetch_object($res)) {
\r
3578 $id = 'templateexp' . $templateObj->tdnumber;
\r
3579 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
\r
3580 echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';
\r
3581 echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';
\r
3586 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
\r
3588 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
\r
3590 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
\r
3592 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
\r
3597 $this->pagefoot();
\r
3602 * @todo document this
\r
3604 function action_skinieimport() {
\r
3605 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
\r
3607 $member->isAdmin() or $this->disallow();
\r
3609 // load skinie class
\r
3610 include_once($DIR_LIBS . 'skinie.php');
\r
3612 $skinFileRaw= postVar('skinfile');
\r
3613 $mode = postVar('mode');
\r
3615 $importer = new SKINIMPORT();
\r
3617 // get full filename
\r
3618 if ($mode == 'file')
\r
3620 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
\r
3622 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
\r
3623 if (!file_exists($skinFile))
\r
3624 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
\r
3626 $skinFile = $skinFileRaw;
\r
3629 // read only metadata
\r
3630 $error = $importer->readFile($skinFile, 1);
\r
3633 $skinNameClashes = $importer->checkSkinNameClashes();
\r
3634 $templateNameClashes = $importer->checkTemplateNameClashes();
\r
3635 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
\r
3637 if ($error) $this->error($error);
\r
3639 $this->pagehead();
\r
3641 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
\r
3643 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
\r
3646 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
\r
3647 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
\r
3648 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
\r
3650 if ($hasNameClashes)
\r
3653 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
\r
3654 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
\r
3656 } // if (hasNameClashes)
\r
3660 <form method="post" action="index.php"><div>
\r
3661 <input type="hidden" name="action" value="skiniedoimport" />
\r
3662 <?php $manager->addTicketHidden() ?>
\r
3663 <input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />
\r
3664 <input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />
\r
3665 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
\r
3667 if ($hasNameClashes)
\r
3671 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
\r
3673 } // if (hasNameClashes)
\r
3679 $this->pagefoot();
\r
3683 * @todo document this
\r
3685 function action_skiniedoimport() {
\r
3686 global $member, $DIR_LIBS, $DIR_SKINS;
\r
3688 $member->isAdmin() or $this->disallow();
\r
3690 // load skinie class
\r
3691 include_once($DIR_LIBS . 'skinie.php');
\r
3693 $skinFileRaw= postVar('skinfile');
\r
3694 $mode = postVar('mode');
\r
3696 $allowOverwrite = intPostVar('overwrite');
\r
3698 // get full filename
\r
3699 if ($mode == 'file')
\r
3701 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
\r
3703 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
\r
3704 if (!file_exists($skinFile))
\r
3705 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
\r
3708 $skinFile = $skinFileRaw;
\r
3711 $importer = new SKINIMPORT();
\r
3713 $error = $importer->readFile($skinFile);
\r
3716 $this->error($error);
\r
3718 $error = $importer->writeToDatabase($allowOverwrite);
\r
3721 $this->error($error);
\r
3723 $this->pagehead();
\r
3725 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
3727 <h2><?php echo _SKINIE_DONE?></h2>
\r
3730 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
\r
3731 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
\r
3732 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
\r
3735 <?php $this->pagefoot();
\r
3740 * @todo document this
\r
3742 function action_skinieexport() {
\r
3743 global $member, $DIR_LIBS;
\r
3745 $member->isAdmin() or $this->disallow();
\r
3747 // load skinie class
\r
3748 include_once($DIR_LIBS . 'skinie.php');
\r
3750 $aSkins = requestIntArray('skin');
\r
3751 $aTemplates = requestIntArray('template');
\r
3753 if (!is_array($aTemplates)) $aTemplates = array();
\r
3754 if (!is_array($aSkins)) $aSkins = array();
\r
3756 $skinList = array_keys($aSkins);
\r
3757 $templateList = array_keys($aTemplates);
\r
3759 $info = postVar('info');
\r
3761 $exporter = new SKINEXPORT();
\r
3762 foreach ($skinList as $skinId) {
\r
3763 $exporter->addSkin($skinId);
\r
3765 foreach ($templateList as $templateId) {
\r
3766 $exporter->addTemplate($templateId);
\r
3768 $exporter->setInfo($info);
\r
3770 $exporter->export();
\r
3774 * @todo document this
\r
3776 function action_templateoverview() {
\r
3777 global $member, $manager;
\r
3779 $member->isAdmin() or $this->disallow();
\r
3781 $this->pagehead();
\r
3783 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
3785 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
\r
3786 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
\r
3788 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
\r
3789 $template['content'] = 'templatelist';
\r
3790 $template['tabindex'] = 10;
\r
3791 showlist($query,'table',$template);
\r
3793 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
\r
3796 <form method="post" action="index.php"><div>
\r
3798 <input name="action" value="templatenew" type="hidden" />
\r
3799 <?php $manager->addTicketHidden() ?>
\r
3801 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
\r
3802 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
\r
3804 <td><?php echo _TEMPLATE_DESC?></td>
\r
3805 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
\r
3807 <td><?php echo _TEMPLATE_CREATE?></td>
\r
3808 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
\r
3814 $this->pagefoot();
\r
3818 * @todo document this
\r
3820 function action_templateedit($msg = '') {
\r
3821 global $member, $manager;
\r
3823 $templateid = intRequestVar('templateid');
\r
3825 $member->isAdmin() or $this->disallow();
\r
3827 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
\r
3828 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
\r
3830 $this->pagehead($extrahead);
\r
3832 $templatename = TEMPLATE::getNameFromId($templateid);
\r
3833 $templatedescription = TEMPLATE::getDesc($templateid);
\r
3834 $template =& $manager->getTemplate($templatename);
\r
3838 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
\r
3841 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo htmlspecialchars($templatename); ?>'</h2>
\r
3843 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
\r
3846 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
\r
3848 <form method="post" action="index.php">
\r
3851 <input type="hidden" name="action" value="templateupdate" />
\r
3852 <?php $manager->addTicketHidden() ?>
\r
3853 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
\r
3856 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
\r
3858 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
\r
3859 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo htmlspecialchars($templatename) ?>" /></td>
\r
3861 <td><?php echo _TEMPLATE_DESC?></td>
\r
3862 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo htmlspecialchars($templatedescription) ?>" /></td>
\r
3864 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
\r
3866 <td><?php echo _TEMPLATE_UPDATE?></td>
\r
3868 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
\r
3869 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
\r
3872 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
\r
3873 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
\r
3874 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
\r
3875 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
\r
3876 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
\r
3877 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
\r
3878 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
\r
3881 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
\r
3882 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
\r
3883 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
\r
3884 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
\r
3885 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
\r
3886 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
\r
3887 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
\r
3888 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
\r
3891 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
\r
3893 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
\r
3896 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
\r
3897 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
\r
3900 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
\r
3901 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
\r
3902 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
\r
3903 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
\r
3906 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
\r
3907 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
\r
3908 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
\r
3909 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
\r
3912 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
\r
3913 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
\r
3914 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
\r
3915 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
\r
3918 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
\r
3919 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
\r
3920 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
\r
3921 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
\r
3922 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
\r
3923 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
\r
3926 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
\r
3927 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
\r
3928 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
\r
3929 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
\r
3932 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
\r
3933 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
\r
3934 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
\r
3937 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
\r
3940 $pluginfields = array();
\r
3941 $param = array('fields'=>&$pluginfields);
\r
3942 $manager->notify('TemplateExtraFields', $param);
\r
3944 foreach ($pluginfields as $pfkey=>$pfvalue) {
\r
3945 echo "</tr><tr>\n";
\r
3946 echo '<th colspan="2">'.htmlentities($pfkey)."</th>\n";
\r
3947 foreach ($pfvalue as $pffield=>$pfdesc) {
\r
3948 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
\r
3953 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
\r
3955 <td><?php echo _TEMPLATE_UPDATE?></td>
\r
3957 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
\r
3958 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
\r
3965 $this->pagefoot();
\r
3969 * @todo document this
\r
3971 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
\r
3972 static $count = 1;
\r
3973 if (!isset($template[$name])) $template[$name] = '';
\r
3976 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
\r
3977 <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>
\r
3982 * @todo document this
\r
3984 function action_templateupdate() {
\r
3985 global $member, $manager;
\r
3987 $templateid = intRequestVar('templateid');
\r
3989 $member->isAdmin() or $this->disallow();
\r
3991 $name = postVar('tname');
\r
3992 $desc = postVar('tdesc');
\r
3994 if (!isValidTemplateName($name))
\r
3995 $this->error(_ERROR_BADTEMPLATENAME);
\r
3997 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
\r
3998 $this->error(_ERROR_DUPTEMPLATENAME);
\r
4001 $name = sql_real_escape_string($name);
\r
4002 $desc = sql_real_escape_string($desc);
\r
4004 // 1. Remove all template parts
\r
4005 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
\r
4006 sql_query($query);
\r
4008 // 2. Update description
\r
4009 $query = 'UPDATE '.sql_table('template_desc').' SET'
\r
4010 . " tdname='" . $name . "',"
\r
4011 . " tddesc='" . $desc . "'"
\r
4012 . " WHERE tdnumber=" . $templateid;
\r
4013 sql_query($query);
\r
4015 // 3. Add non-empty template parts
\r
4016 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
\r
4017 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
\r
4018 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
\r
4019 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
\r
4020 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
\r
4021 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
\r
4022 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
\r
4023 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
\r
4024 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
\r
4025 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
\r
4026 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
\r
4027 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
\r
4028 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
\r
4029 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
\r
4030 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
\r
4031 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
\r
4032 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
\r
4033 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
\r
4034 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
\r
4035 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
\r
4036 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
\r
4037 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
\r
4038 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
\r
4039 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
\r
4040 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
\r
4041 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
\r
4042 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
\r
4043 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
\r
4044 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
\r
4045 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
\r
4046 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
\r
4047 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
\r
4048 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
\r
4049 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
\r
4051 $pluginfields = array();
\r
4052 $param = array('fields'=>&$pluginfields);
\r
4053 $manager->notify('TemplateExtraFields', $param);
\r
4054 foreach ($pluginfields as $pfkey=>$pfvalue) {
\r
4055 foreach ($pfvalue as $pffield=>$pfdesc) {
\r
4056 $this->addToTemplate($templateid, $pffield, postVar($pffield));
\r
4060 // jump back to template edit
\r
4061 $this->action_templateedit(_TEMPLATE_UPDATED);
\r
4066 * @todo document this
\r
4068 function addToTemplate($id, $partname, $content) {
\r
4069 $partname = sql_real_escape_string($partname);
\r
4070 $content = sql_real_escape_string($content);
\r
4072 $id = intval($id);
\r
4074 // don't add empty parts:
\r
4075 if (!trim($content)) return -1;
\r
4077 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
\r
4078 . "VALUES ($id, '$partname', '$content')";
\r
4079 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
\r
4080 return sql_insert_id();
\r
4084 * @todo document this
\r
4086 function action_templatedelete() {
\r
4087 global $member, $manager;
\r
4089 $member->isAdmin() or $this->disallow();
\r
4091 $templateid = intRequestVar('templateid');
\r
4092 // TODO: check if template can be deleted
\r
4094 $this->pagehead();
\r
4096 $name = TEMPLATE::getNameFromId($templateid);
\r
4097 $desc = TEMPLATE::getDesc($templateid);
\r
4100 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
4103 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo htmlspecialchars($name)?></b> (<?php echo htmlspecialchars($desc) ?>)
\r
4106 <form method="post" action="index.php"><div>
\r
4107 <input type="hidden" name="action" value="templatedeleteconfirm" />
\r
4108 <?php $manager->addTicketHidden() ?>
\r
4109 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
\r
4110 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
4113 $this->pagefoot();
\r
4117 * @todo document this
\r
4119 function action_templatedeleteconfirm() {
\r
4120 global $member, $manager;
\r
4122 $templateid = intRequestVar('templateid');
\r
4124 $member->isAdmin() or $this->disallow();
\r
4126 $param = array('templateid' => $templateid);
\r
4127 $manager->notify('PreDeleteTemplate', $param);
\r
4129 // 1. delete description
\r
4130 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
\r
4132 // 2. delete parts
\r
4133 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
\r
4135 $param = array('templateid' => $templateid);
\r
4136 $manager->notify('PostDeleteTemplate', $param);
\r
4138 $this->action_templateoverview();
\r
4142 * @todo document this
\r
4144 function action_templatenew() {
\r
4147 $member->isAdmin() or $this->disallow();
\r
4149 $name = postVar('name');
\r
4150 $desc = postVar('desc');
\r
4152 if (!isValidTemplateName($name))
\r
4153 $this->error(_ERROR_BADTEMPLATENAME);
\r
4155 if (TEMPLATE::exists($name))
\r
4156 $this->error(_ERROR_DUPTEMPLATENAME);
\r
4158 $newTemplateId = TEMPLATE::createNew($name, $desc);
\r
4160 $this->action_templateoverview();
\r
4164 * @todo document this
\r
4166 function action_templateclone() {
\r
4169 $templateid = intRequestVar('templateid');
\r
4171 $member->isAdmin() or $this->disallow();
\r
4173 // 1. read old template
\r
4174 $name = TEMPLATE::getNameFromId($templateid);
\r
4175 $desc = TEMPLATE::getDesc($templateid);
\r
4177 // 2. create desc thing
\r
4178 $name = "cloned" . $name;
\r
4180 // if a template with that name already exists:
\r
4181 if (TEMPLATE::exists($name)) {
\r
4183 while (TEMPLATE::exists($name . $i))
\r
4188 $newid = TEMPLATE::createNew($name, $desc);
\r
4190 // 3. create clone
\r
4191 // go through parts of old template and add them to the new one
\r
4192 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
\r
4193 while ($o = sql_fetch_object($res)) {
\r
4194 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
\r
4197 $this->action_templateoverview();
\r
4201 * @todo document this
\r
4203 function action_skinoverview() {
\r
4204 global $member, $manager;
\r
4206 $member->isAdmin() or $this->disallow();
\r
4208 $this->pagehead();
\r
4210 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
4212 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
\r
4214 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
\r
4216 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
\r
4217 $template['content'] = 'skinlist';
\r
4218 $template['tabindex'] = 10;
\r
4219 showlist($query,'table',$template);
\r
4221 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
\r
4224 <form method="post" action="index.php">
\r
4227 <input name="action" value="skinnew" type="hidden" />
\r
4228 <?php $manager->addTicketHidden() ?>
\r
4230 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
\r
4231 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
\r
4233 <td><?php echo _SKIN_DESC?></td>
\r
4234 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
\r
4236 <td><?php echo _SKIN_CREATE?></td>
\r
4237 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
\r
4244 $this->pagefoot();
\r
4248 * @todo document this
\r
4250 function action_skinnew() {
\r
4253 $member->isAdmin() or $this->disallow();
\r
4255 $name = trim(postVar('name'));
\r
4256 $desc = trim(postVar('desc'));
\r
4258 if (!isValidSkinName($name))
\r
4259 $this->error(_ERROR_BADSKINNAME);
\r
4261 if (SKIN::exists($name))
\r
4262 $this->error(_ERROR_DUPSKINNAME);
\r
4264 $newId = SKIN::createNew($name, $desc);
\r
4266 $this->action_skinoverview();
\r
4270 * @todo document this
\r
4272 function action_skinedit() {
\r
4273 global $member, $manager;
\r
4275 $skinid = intRequestVar('skinid');
\r
4277 $member->isAdmin() or $this->disallow();
\r
4279 $skin = new SKIN($skinid);
\r
4281 $this->pagehead();
\r
4284 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
\r
4286 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
\r
4288 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
\r
4289 <?php echo _SKIN_PARTS_MSG?>
\r
4291 <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>
\r
4292 <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>
\r
4293 <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>
\r
4294 <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>
\r
4295 <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>
\r
4296 <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>
\r
4297 <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>
\r
4298 <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>
\r
4303 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
\r
4304 $res = sql_query($query);
\r
4306 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
\r
4307 echo '<form method="get" action="index.php">' . "\r\n";
\r
4308 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
\r
4309 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
\r
4310 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
\r
4311 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
\r
4312 echo '</form>' . "\r\n";
\r
4314 if ($res && sql_num_rows($res) > 0) {
\r
4318 while ($row = sql_fetch_assoc($res)) {
\r
4319 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . htmlspecialchars(strtolower($row['stype'])) . '">' . htmlspecialchars(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . htmlspecialchars(strtolower($row['stype'])) . '">'._LISTS_DELETE.'</a>)</li>';
\r
4327 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
\r
4328 <form method="post" action="index.php">
\r
4331 <input type="hidden" name="action" value="skineditgeneral" />
\r
4332 <?php $manager->addTicketHidden() ?>
\r
4333 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
\r
4335 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
\r
4336 <td><input name="name" tabindex="90" value="<?php echo htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>
\r
4338 <td><?php echo _SKIN_DESC?></td>
\r
4339 <td><input name="desc" tabindex="100" value="<?php echo htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
\r
4341 <td><?php echo _SKIN_TYPE?></td>
\r
4342 <td><input name="type" tabindex="110" value="<?php echo htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
\r
4344 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
\r
4345 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
\r
4347 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
\r
4348 <td><input name="inc_prefix" tabindex="130" value="<?php echo htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
\r
4350 <td><?php echo _SKIN_CHANGE?></td>
\r
4351 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
\r
4358 <?php $this->pagefoot();
\r
4362 * @todo document this
\r
4364 function action_skineditgeneral() {
\r
4367 $skinid = intRequestVar('skinid');
\r
4369 $member->isAdmin() or $this->disallow();
\r
4371 $name = postVar('name');
\r
4372 $desc = postVar('desc');
\r
4373 $type = postVar('type');
\r
4374 $inc_mode = postVar('inc_mode');
\r
4375 $inc_prefix = postVar('inc_prefix');
\r
4377 $skin = new SKIN($skinid);
\r
4380 if (!isValidSkinName($name))
\r
4381 $this->error(_ERROR_BADSKINNAME);
\r
4383 if (($skin->getName() != $name) && SKIN::exists($name))
\r
4384 $this->error(_ERROR_DUPSKINNAME);
\r
4386 if (!$type) $type = 'text/html';
\r
4387 if (!$inc_mode) $inc_mode = 'normal';
\r
4389 // 2. Update description
\r
4390 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
\r
4392 $this->action_skinedit();
\r
4397 * @todo document this
\r
4399 function action_skinedittype($msg = '') {
\r
4400 global $member, $manager;
\r
4402 $skinid = intRequestVar('skinid');
\r
4403 $type = requestVar('type');
\r
4405 $member->isAdmin() or $this->disallow();
\r
4407 $type = trim($type);
\r
4408 $type = strtolower($type);
\r
4410 if (!isValidShortName($type)) {
\r
4411 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
\r
4414 $skin = new SKIN($skinid);
\r
4416 $friendlyNames = SKIN::getFriendlyNames();
\r
4418 $this->pagehead();
\r
4420 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
\r
4422 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo htmlspecialchars($skin->getName()) ?>': <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
\r
4424 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
\r
4427 <div style="width:100%;">
\r
4428 <form method="post" action="index.php">
\r
4431 <input type="hidden" name="action" value="skinupdate" />
\r
4432 <?php $manager->addTicketHidden() ?>
\r
4433 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
\r
4434 <input type="hidden" name="type" value="<?php echo $type ?>" />
\r
4436 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
\r
4437 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
\r
4438 (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
\r
4439 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
\r
4440 help('skinpart' . $type);
\r
4442 help('skinpartspecial');
\r
4446 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo htmlspecialchars($skin->getContent($type)) ?></textarea>
\r
4449 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
\r
4450 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
\r
4451 (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
\r
4454 <?php echo _SKIN_ALLOWEDVARS?>
\r
4455 <?php $actions = SKIN::getAllowedActionsForType($type);
\r
4459 while ($current = array_shift($actions)) {
\r
4460 // skip deprecated vars
\r
4461 if ($current == 'ifcat') continue;
\r
4462 if ($current == 'imagetext') continue;
\r
4463 if ($current == 'vars') continue;
\r
4465 echo helplink('skinvar-' . $current) . "$current</a>";
\r
4466 if (count($actions) != 0) echo ", ";
\r
4468 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
\r
4469 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
\r
4470 showlist($query,'table',array('content'=>'shortblognames'));
\r
4471 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
\r
4472 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
\r
4473 showlist($query,'table',array('content'=>'shortnames'));
\r
4474 echo '</div></form></div>';
\r
4475 $this->pagefoot();
\r
4479 * @todo document this
\r
4481 function action_skinupdate() {
\r
4484 $skinid = intRequestVar('skinid');
\r
4485 $content = trim(postVar('content'));
\r
4486 $type = postVar('type');
\r
4488 $member->isAdmin() or $this->disallow();
\r
4490 $skin = new SKIN($skinid);
\r
4491 $skin->update($type, $content);
\r
4493 $this->action_skinedittype(_SKIN_UPDATED);
\r
4497 * @todo document this
\r
4499 function action_skindelete() {
\r
4500 global $member, $manager, $CONF;
\r
4502 $skinid = intRequestVar('skinid');
\r
4504 $member->isAdmin() or $this->disallow();
\r
4506 // don't allow default skin to be deleted
\r
4507 if ($skinid == $CONF['BaseSkin'])
\r
4508 $this->error(_ERROR_DEFAULTSKIN);
\r
4510 // don't allow deletion of default skins for blogs
\r
4511 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
\r
4512 $r = sql_query($query);
\r
4513 if ($o = sql_fetch_object($r))
\r
4514 $this->error(_ERROR_SKINDEFDELETE . htmlspecialchars($o->bname));
\r
4516 $this->pagehead();
\r
4518 $skin = new SKIN($skinid);
\r
4519 $name = $skin->getName();
\r
4520 $desc = $skin->getDescription();
\r
4523 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
4526 <?php echo _CONFIRMTXT_SKIN?><b><?php echo htmlspecialchars($name) ?></b> (<?php echo htmlspecialchars($desc)?>)
\r
4529 <form method="post" action="index.php"><div>
\r
4530 <input type="hidden" name="action" value="skindeleteconfirm" />
\r
4531 <?php $manager->addTicketHidden() ?>
\r
4532 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
\r
4533 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
4536 $this->pagefoot();
\r
4540 * @todo document this
\r
4542 function action_skindeleteconfirm() {
\r
4543 global $member, $CONF, $manager;
\r
4545 $skinid = intRequestVar('skinid');
\r
4547 $member->isAdmin() or $this->disallow();
\r
4549 // don't allow default skin to be deleted
\r
4550 if ($skinid == $CONF['BaseSkin'])
\r
4551 $this->error(_ERROR_DEFAULTSKIN);
\r
4553 // don't allow deletion of default skins for blogs
\r
4554 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
\r
4555 $r = sql_query($query);
\r
4556 if ($o = sql_fetch_object($r))
\r
4557 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
\r
4559 $param = array('skinid' => $skinid);
\r
4560 $manager->notify('PreDeleteSkin', $param);
\r
4562 // 1. delete description
\r
4563 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
\r
4565 // 2. delete parts
\r
4566 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
\r
4568 $param = array('skinid' => $skinid);
\r
4569 $manager->notify('PostDeleteSkin', $param);
\r
4571 $this->action_skinoverview();
\r
4575 * @todo document this
\r
4577 function action_skinremovetype() {
\r
4578 global $member, $manager, $CONF;
\r
4580 $skinid = intRequestVar('skinid');
\r
4581 $skintype = requestVar('type');
\r
4583 if (!isValidShortName($skintype)) {
\r
4584 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
\r
4587 $member->isAdmin() or $this->disallow();
\r
4589 // don't allow default skinparts to be deleted
\r
4590 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
\r
4591 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
\r
4594 $this->pagehead();
\r
4596 $skin = new SKIN($skinid);
\r
4597 $name = $skin->getName();
\r
4598 $desc = $skin->getDescription();
\r
4601 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
4604 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo htmlspecialchars($skintype); ?> (<?php echo htmlspecialchars($name); ?>)</b> (<?php echo htmlspecialchars($desc)?>)
\r
4607 <form method="post" action="index.php"><div>
\r
4608 <input type="hidden" name="action" value="skinremovetypeconfirm" />
\r
4609 <?php $manager->addTicketHidden() ?>
\r
4610 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
\r
4611 <input type="hidden" name="type" value="<?php echo htmlspecialchars($skintype); ?>" />
\r
4612 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
4615 $this->pagefoot();
\r
4619 * @todo document this
\r
4621 function action_skinremovetypeconfirm() {
\r
4622 global $member, $CONF, $manager;
\r
4624 $skinid = intRequestVar('skinid');
\r
4625 $skintype = requestVar('type');
\r
4627 if (!isValidShortName($skintype)) {
\r
4628 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
\r
4631 $member->isAdmin() or $this->disallow();
\r
4633 // don't allow default skinparts to be deleted
\r
4634 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
\r
4635 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
\r
4639 'skinid' => $skinid,
\r
4640 'skintype' => $skintype
\r
4642 $manager->notify('PreDeleteSkinPart', $param);
\r
4645 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
\r
4648 'skinid' => $skinid,
\r
4649 'skintype' => $skintype
\r
4651 $manager->notify('PostDeleteSkinPart', $param);
\r
4653 $this->action_skinedit();
\r
4657 * @todo document this
\r
4659 function action_skinclone() {
\r
4662 $skinid = intRequestVar('skinid');
\r
4664 $member->isAdmin() or $this->disallow();
\r
4666 // 1. read skin to clone
\r
4667 $skin = new SKIN($skinid);
\r
4669 $name = "clone_" . $skin->getName();
\r
4671 // if a skin with that name already exists:
\r
4672 if (SKIN::exists($name)) {
\r
4674 while (SKIN::exists($name . $i))
\r
4679 // 2. create skin desc
\r
4680 $newid = SKIN::createNew(
\r
4682 $skin->getDescription(),
\r
4683 $skin->getContentType(),
\r
4684 $skin->getIncludeMode(),
\r
4685 $skin->getIncludePrefix()
\r
4691 $this->skinclonetype($skin, $newid, 'index');
\r
4692 $this->skinclonetype($skin, $newid, 'item');
\r
4693 $this->skinclonetype($skin, $newid, 'archivelist');
\r
4694 $this->skinclonetype($skin, $newid, 'archive');
\r
4695 $this->skinclonetype($skin, $newid, 'search');
\r
4696 $this->skinclonetype($skin, $newid, 'error');
\r
4697 $this->skinclonetype($skin, $newid, 'member');
\r
4698 $this->skinclonetype($skin, $newid, 'imagepopup');
\r
4701 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
\r
4702 $res = sql_query($query);
\r
4703 while ($row = sql_fetch_assoc($res)) {
\r
4704 $this->skinclonetype($skin, $newid, $row['stype']);
\r
4707 $this->action_skinoverview();
\r
4712 * @todo document this
\r
4714 function skinclonetype($skin, $newid, $type) {
\r
4715 $newid = intval($newid);
\r
4716 $content = $skin->getContent($type);
\r
4718 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
\r
4719 sql_query($query);
\r
4724 * @todo document this
\r
4726 function action_settingsedit() {
\r
4727 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
\r
4729 $member->isAdmin() or $this->disallow();
\r
4731 $this->pagehead();
\r
4733 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
4736 <h2><?php echo _SETTINGS_TITLE?></h2>
\r
4738 <form action="index.php" method="post">
\r
4741 <input type="hidden" name="action" value="settingsupdate" />
\r
4742 <?php $manager->addTicketHidden() ?>
\r
4745 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
\r
4747 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
\r
4750 $query = 'SELECT bname as text, bnumber as value'
\r
4751 . ' FROM '.sql_table('blog');
\r
4752 $template['name'] = 'DefaultBlog';
\r
4753 $template['selected'] = $CONF['DefaultBlog'];
\r
4754 $template['tabindex'] = 10;
\r
4755 showlist($query,'select',$template);
\r
4759 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
\r
4762 $query = 'SELECT sdname as text, sdnumber as value'
\r
4763 . ' FROM '.sql_table('skin_desc');
\r
4764 $template['name'] = 'BaseSkin';
\r
4765 $template['selected'] = $CONF['BaseSkin'];
\r
4766 $template['tabindex'] = 1;
\r
4767 showlist($query,'select',$template);
\r
4771 <td><?php echo _SETTINGS_ADMINMAIL?></td>
\r
4772 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo htmlspecialchars($CONF['AdminEmail']) ?>" /></td>
\r
4774 <td><?php echo _SETTINGS_SITENAME?></td>
\r
4775 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo htmlspecialchars($CONF['SiteName']) ?>" /></td>
\r
4777 <td><?php echo _SETTINGS_SITEURL?></td>
\r
4778 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL']) ?>" /></td>
\r
4780 <td><?php echo _SETTINGS_ADMINURL?></td>
\r
4781 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo htmlspecialchars($CONF['AdminURL']) ?>" /></td>
\r
4783 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
\r
4784 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo htmlspecialchars($CONF['PluginURL']) ?>" /></td>
\r
4786 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
\r
4787 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo htmlspecialchars($CONF['SkinsURL']) ?>" /></td>
\r
4789 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
\r
4790 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo htmlspecialchars($CONF['ActionURL']) ?>" /></td>
\r
4792 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
\r
4796 <select name="Language" tabindex="10050">
\r
4797 <?php // show a dropdown list of all available languages
\r
4799 $dirhandle = opendir($DIR_LANG);
\r
4800 while ($filename = readdir($dirhandle) )
\r
4802 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
\r
4803 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
\r
4804 if (preg_match('#^(.*)\.php$#', $filename, $matches) )
\r
4806 $name = $matches[1];
\r
4807 echo "<option value=\"$name\"";
\r
4808 if ($name == $CONF['Language'])
\r
4810 echo " selected=\"selected\"";
\r
4812 echo ">$name</option>";
\r
4815 closedir($dirhandle);
\r
4822 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
\r
4824 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
\r
4826 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo htmlspecialchars($CONF['DisableSiteURL'])?>" />
\r
4829 <td><?php echo _SETTINGS_DIRS?></td>
\r
4830 <td><?php echo htmlspecialchars($DIR_NUCLEUS) ?>
\r
4831 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
\r
4833 <td><?php echo _SETTINGS_DBLOGIN?></td>
\r
4834 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
\r
4838 echo _SETTINGS_JSTOOLBAR
\r
4839 /* =_SETTINGS_DISABLEJS
\r
4841 I temporary changed the meaning of DisableJsTools, until I can find a good
\r
4842 way to select the javascript version to use
\r
4846 1 : all javascript disabled
\r
4847 2 : 'simpler' javascript (for mozilla/opera/mac)
\r
4851 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
\r
4852 <select name="DisableJsTools" tabindex="10075">
\r
4853 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
\r
4854 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
\r
4855 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
\r
4856 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
\r
4857 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
\r
4858 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
\r
4863 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
\r
4866 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
\r
4867 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
\r
4869 echo ' ', _SETTINGS_URLMODE_HELP;
\r
4875 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
\r
4878 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
\r
4884 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
\r
4887 if (!array_key_exists('DefaultListSize',$CONF)) {
\r
4888 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
\r
4889 $CONF['DefaultListSize'] = 10;
\r
4892 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo htmlspecialchars((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
\r
4895 <td><?php echo _SETTINGS_ADMINCSS?>
\r
4898 <select name="AdminCSS" tabindex="10080">
\r
4899 <?php // show a dropdown list of all available admin css files
\r
4900 global $DIR_NUCLEUS;
\r
4901 $dirhandle = opendir($DIR_NUCLEUS."styles/");
\r
4902 while ($filename = readdir($dirhandle) )
\r
4904 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
\r
4905 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
\r
4906 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
\r
4908 $name = $matches[1];
\r
4909 echo "<option value=\"$name\"";
\r
4910 if ($name == $CONF['AdminCSS'])
\r
4912 echo " selected=\"selected\"";
\r
4914 echo ">$name</option>";
\r
4917 closedir($dirhandle);
\r
4922 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
\r
4924 <td><?php echo _SETTINGS_MEDIADIR?></td>
\r
4925 <td><?php echo htmlspecialchars($DIR_MEDIA) ?>
\r
4926 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
\r
4927 <?php if (!is_dir($DIR_MEDIA))
\r
4928 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
\r
4929 if (!is_readable($DIR_MEDIA))
\r
4930 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
\r
4931 if (!is_writeable($DIR_MEDIA))
\r
4932 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
\r
4936 <td><?php echo _SETTINGS_MEDIAURL?></td>
\r
4938 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo htmlspecialchars($CONF['MediaURL']) ?>" />
\r
4941 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
\r
4942 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
\r
4944 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
\r
4946 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo htmlspecialchars($CONF['AllowedTypes']) ?>" />
\r
4949 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
\r
4951 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo htmlspecialchars($CONF['MaxUploadSize']) ?>" />
\r
4954 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
\r
4955 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
\r
4958 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
\r
4960 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
\r
4961 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
\r
4963 <td><?php echo _SETTINGS_ALLOWCREATE?>
\r
4964 <?php help('allowaccountcreation'); ?>
\r
4966 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
\r
4969 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
\r
4970 <br /><?php echo _SETTINGS_NEWLOGIN2?>
\r
4972 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
\r
4975 <td><?php echo _SETTINGS_MEMBERMSGS?>
\r
4976 <?php help('messageservice'); ?>
\r
4978 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
\r
4981 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
\r
4982 <?php help('messageservice'); ?>
\r
4984 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
\r
4987 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
\r
4988 <?php help('protectmemnames'); ?>
\r
4990 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
\r
4996 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
\r
4998 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
\r
4999 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo htmlspecialchars($CONF['CookiePrefix'])?>" /></td>
\r
5001 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
\r
5002 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo htmlspecialchars($CONF['CookieDomain'])?>" /></td>
\r
5004 <td><?php echo _SETTINGS_COOKIEPATH?></td>
\r
5005 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo htmlspecialchars($CONF['CookiePath'])?>" /></td>
\r
5007 <td><?php echo _SETTINGS_COOKIESECURE?></td>
\r
5008 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
\r
5010 <td><?php echo _SETTINGS_COOKIELIFE?></td>
\r
5011 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
\r
5012 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
\r
5015 <td><?php echo _SETTINGS_LASTVISIT?></td>
\r
5016 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
\r
5021 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
\r
5023 <td><?php echo _SETTINGS_UPDATE?></td>
\r
5024 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
\r
5031 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
\r
5034 $manager->notify('GeneralSettingsFormExtras', $param);
\r
5036 $this->pagefoot();
\r
5040 * @todo document this
\r
5042 function action_settingsupdate() {
\r
5043 global $member, $CONF;
\r
5045 $member->isAdmin() or $this->disallow();
\r
5047 // check if email address for admin is valid
\r
5048 if (!isValidMailAddress(postVar('AdminEmail')))
\r
5049 $this->error(_ERROR_BADMAILADDRESS);
\r
5053 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
\r
5054 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
\r
5055 $this->updateConfig('IndexURL', postVar('IndexURL'));
\r
5056 $this->updateConfig('AdminURL', postVar('AdminURL'));
\r
5057 $this->updateConfig('PluginURL', postVar('PluginURL'));
\r
5058 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
\r
5059 $this->updateConfig('ActionURL', postVar('ActionURL'));
\r
5060 $this->updateConfig('Language', postVar('Language'));
\r
5061 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
\r
5062 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
\r
5063 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
\r
5064 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
\r
5065 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
\r
5066 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
\r
5067 $this->updateConfig('SiteName', postVar('SiteName'));
\r
5068 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
\r
5069 $this->updateConfig('DisableSite', postVar('DisableSite'));
\r
5070 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
\r
5071 $this->updateConfig('LastVisit', postVar('LastVisit'));
\r
5072 $this->updateConfig('MediaURL', postVar('MediaURL'));
\r
5073 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
\r
5074 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
\r
5075 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
\r
5076 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
\r
5077 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
\r
5078 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
\r
5079 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
\r
5080 $this->updateConfig('CookiePath', postVar('CookiePath'));
\r
5081 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
\r
5082 $this->updateConfig('URLMode', postVar('URLMode'));
\r
5083 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
\r
5084 $this->updateConfig('DebugVars', postVar('DebugVars'));
\r
5085 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
\r
5086 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
\r
5088 // load new config and redirect (this way, the new language will be used is necessary)
\r
5089 // note that when changing cookie settings, this redirect might cause the user
\r
5090 // to have to log in again.
\r
5092 redirect($CONF['AdminURL'] . '?action=manage');
\r
5098 * Give an overview over the used system
\r
5100 function action_systemoverview() {
\r
5101 global $member, $nucleus, $CONF;
\r
5103 $this->pagehead();
\r
5105 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
\r
5107 if ($member->isLoggedIn() && $member->isAdmin()) {
\r
5109 // Information about the used PHP and MySQL installation
\r
5110 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";
\r
5112 // Version of PHP MySQL
\r
5115 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
\r
5116 echo "\t</tr><tr>\n";
\r
5117 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
\r
5118 echo "\t\t" . '<td>' . phpversion() . "</td>\n";
\r
5119 echo "\t</tr><tr>\n";
\r
5120 echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
\r
5121 echo "\t\t" . '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
\r
5123 echo "</table>\n";
\r
5125 // Important PHP settings
\r
5128 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
\r
5129 echo "\t</tr><tr>\n";
\r
5130 echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";
\r
5131 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
\r
5132 echo "\t\t" . '<td>' . $mqg . "</td>\n";
\r
5133 echo "\t</tr><tr>\n";
\r
5134 echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";
\r
5135 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
\r
5136 echo "\t\t" . '<td>' . $mqr . "</td>\n";
\r
5137 echo "\t</tr><tr>\n";
\r
5138 echo "\t\t" . '<td>register_globals' . "</td>\n";
\r
5139 $rg = ini_get('register_globals') ? 'On' : 'Off';
\r
5140 echo "\t\t" . '<td>' . $rg . "</td>\n";
\r
5142 echo "</table>\n";
\r
5144 // Information about GD library
\r
5145 $gdinfo = gd_info();
\r
5148 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
\r
5150 foreach ($gdinfo as $key=>$value) {
\r
5151 if (is_bool($value)) {
\r
5152 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
\r
5154 $value = htmlspecialchars($value, ENT_QUOTES);
\r
5157 echo "\t\t" . '<td width="50%">' . $key . "</td>\n";
\r
5158 echo "\t\t" . '<td>' . $value . "</td>\n";
\r
5161 echo "</table>\n";
\r
5163 // Check if special modules are loaded
\r
5165 phpinfo(INFO_MODULES);
\r
5166 $im = ob_get_contents();
\r
5170 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
\r
5171 echo "\t</tr><tr>\n";
\r
5172 echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";
\r
5173 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
\r
5174 _ADMIN_SYSTEMOVERVIEW_ENABLE :
\r
5175 _ADMIN_SYSTEMOVERVIEW_DISABLE;
\r
5176 echo "\t\t" . '<td>' . $modrewrite . "</td>\n";
\r
5178 echo "</table>\n";
\r
5180 // Information about the used Nucleus CMS
\r
5181 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
\r
5183 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
\r
5184 $np = getNucleusPatchLevel();
\r
5187 echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";
\r
5188 echo "\t</tr><tr>\n";
\r
5189 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
\r
5190 echo "\t\t" . '<td>' . $nv . "</td>\n";
\r
5191 echo "\t</tr><tr>\n";
\r
5192 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
\r
5193 echo "\t\t" . '<td>' . $np . "</td>\n";
\r
5195 echo "</table>\n";
\r
5197 // Important settings of the installation
\r
5200 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
\r
5201 echo "\t</tr><tr>\n";
\r
5202 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";
\r
5203 echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";
\r
5204 echo "\t</tr><tr>\n";
\r
5205 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";
\r
5206 echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";
\r
5207 echo "\t</tr><tr>\n";
\r
5208 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
\r
5209 $ohs = $CONF['alertOnHeadersSent'] ?
\r
5210 _ADMIN_SYSTEMOVERVIEW_ENABLE :
\r
5211 _ADMIN_SYSTEMOVERVIEW_DISABLE;
\r
5212 echo "\t\t" . '<td>' . $ohs . "</td>\n";
\r
5214 echo "</table>\n";
\r
5216 // Link to the online version test at the Nucleus CMS website
\r
5217 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
\r
5218 if ($nucleus['codename'] != '') {
\r
5219 $codenamestring = ' "' . $nucleus['codename'] . '"';
\r
5221 $codenamestring = '';
\r
5223 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
\r
5224 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
\r
5225 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
\r
5226 echo 'Nucleus CMS ' . $nv . $codenamestring;
\r
5231 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
\r
5234 $this->pagefoot();
\r
5238 * @todo document this
\r
5240 function updateConfig($name, $val) {
\r
5241 $name = sql_real_escape_string($name);
\r
5242 $val = trim(sql_real_escape_string($val));
\r
5244 $query = 'UPDATE '.sql_table('config')
\r
5245 . " SET value='$val'"
\r
5246 . " WHERE name='$name'";
\r
5248 sql_query($query) or die(_ADMIN_SQLDIE_QUERYERROR . sql_error());
\r
5249 return sql_insert_id();
\r
5254 * @param string $msg message that will be shown
\r
5256 function error($msg) {
\r
5257 $this->pagehead();
\r
5262 echo "<a href='index.php' onclick='history.back(); return false;'>"._BACK."</a>";
\r
5263 $this->pagefoot();
\r
5268 * @todo document this
\r
5270 function disallow() {
\r
5271 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
\r
5273 $this->error(_ERROR_DISALLOWED);
\r
5277 * @todo document this
\r
5279 function pagehead($extrahead = '') {
\r
5280 global $member, $nucleus, $CONF, $manager;
\r
5283 'extrahead' => &$extrahead,
\r
5284 'action' => $this->action
\r
5286 $manager->notify('AdminPrePageHead', $param);
\r
5288 $baseUrl = htmlspecialchars($CONF['AdminURL']);
\r
5289 if (!array_key_exists('AdminCSS',$CONF))
\r
5291 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'contemporary_jp')");
\r
5292 $CONF['AdminCSS'] = 'contemporary_jp';
\r
5296 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
5297 <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
\r
5299 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
\r
5300 <title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>
\r
5301 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin_<?php echo $CONF["AdminCSS"]?>.css" />
\r
5302 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
\r
5303 href="<?php echo $baseUrl?>styles/addedit.css" />
\r
5305 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
\r
5306 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
\r
5307 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
\r
5309 <meta http-equiv='Pragma' content='no-cache' />
\r
5310 <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
\r
5311 <meta http-equiv='Expires' content='-1' />
\r
5313 <?php echo $extrahead?>
\r
5316 <div id="adminwrapper">
\r
5317 <div class="header">
\r
5318 <h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>
\r
5320 <div id="container">
\r
5321 <div id="content">
\r
5322 <div class="loginname">
\r
5323 <?php if ($member->isLoggedIn())
\r
5324 echo _LOGGEDINAS . ' ' . $member->getDisplayName()
\r
5325 ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
\r
5326 . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
\r
5328 echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
\r
5330 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
\r
5334 $codenamestring = ($nucleus['codename']!='')? ' "'.$nucleus['codename'].'"':'';
\r
5336 if ($member->isLoggedIn() && $member->isAdmin()) {
\r
5337 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
\r
5338 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
\r
5339 $newestVersion = getLatestVersion();
\r
5340 $newestCompare = str_replace('/','.',$newestVersion);
\r
5341 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
\r
5342 $currentVersion = floatval($currentVersion);
\r
5343 if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {
\r
5344 echo '<br /><a style="color:red" href="'._ADMINPAGEFOOT_OFFICIALURL.'upgrade.php" title="'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE.'">'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.'</a>';
\r
5347 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
\r
5354 * @todo document this
\r
5356 function pagefoot() {
\r
5357 global $action, $member, $manager;
\r
5360 'action' => $this->action
\r
5362 $manager->notify('AdminPrePageFoot', $param);
\r
5364 if ($member->isLoggedIn() && ($action != 'showlogin')) {
\r
5366 <h2><?php echo _LOGOUT ?></h2>
\r
5368 <li><a href="index.php?action=overview"><?php echo _BACKHOME?></a></li>
\r
5369 <li><a href='index.php?action=logout'><?php echo _LOGOUT?></a></li>
\r
5373 <div class="foot">
\r
5374 <a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> © 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>
\r
5376 <a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>
\r
5379 </div><!-- content -->
\r
5381 <div id="quickmenu">
\r
5383 <?php // ---- user settings ----
\r
5384 if (($action != 'showlogin') && ($member->isLoggedIn())) {
\r
5386 echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
\r
5389 echo '<h2>',_QMENU_ADD,'</h2>';
\r
5390 echo '<form method="get" action="index.php"><div>';
\r
5391 echo '<input type="hidden" name="action" value="createitem" />';
\r
5393 $showAll = requestVar('showall');
\r
5394 if (($member->isAdmin()) && ($showAll == 'yes')) {
\r
5395 // Super-Admins have access to all blogs! (no add item support though)
\r
5396 $query = 'SELECT bnumber as value, bname as text'
\r
5397 . ' FROM ' . sql_table('blog')
\r
5398 . ' ORDER BY bname';
\r
5400 $query = 'SELECT bnumber as value, bname as text'
\r
5401 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
\r
5402 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
\r
5403 . ' ORDER BY bname';
\r
5405 $template['name'] = 'blogid';
\r
5406 $template['tabindex'] = 15000;
\r
5407 $template['extra'] = _QMENU_ADD_SELECT;
\r
5408 $template['selected'] = -1;
\r
5409 $template['shorten'] = 10;
\r
5410 $template['shortenel'] = '';
\r
5411 $template['javascript'] = 'onchange="return form.submit()"';
\r
5412 showlist($query,'select',$template);
\r
5414 echo '</div></form>';
\r
5416 echo '<h2>' . $member->getDisplayName(). '</h2>';
\r
5418 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';
\r
5419 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';
\r
5420 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';
\r
5426 // ---- general settings ----
\r
5427 if ($member->isAdmin()) {
\r
5429 echo '<h2>',_QMENU_MANAGE,'</h2>';
\r
5432 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';
\r
5433 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';
\r
5434 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';
\r
5435 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';
\r
5436 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';
\r
5437 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';
\r
5438 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';
\r
5441 echo '<h2>',_QMENU_LAYOUT,'</h2>';
\r
5443 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';
\r
5444 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';
\r
5445 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';
\r
5450 $aPluginExtras = array();
\r
5452 'options' => &$aPluginExtras
\r
5454 $manager->notify('QuickMenu', $param);
\r
5455 if (count($aPluginExtras) > 0)
\r
5457 echo '<h2>', _QMENU_PLUGINS, '</h2>';
\r
5459 foreach ($aPluginExtras as $aInfo)
\r
5461 echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';
\r
5466 } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
\r
5468 echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
\r
5470 // introduction text on login screen
\r
5471 echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
\r
5476 <!-- content / quickmenu container -->
\r
5477 <div class="clear"></div> <!-- new -->
\r
5480 <!-- adminwrapper --> <!-- new -->
\r
5481 </div> <!-- new -->
\r
5487 * @todo document this
\r
5489 function action_regfile() {
\r
5490 global $member, $CONF;
\r
5492 $blogid = intRequestVar('blogid');
\r
5494 $member->teamRights($blogid) or $this->disallow();
\r
5496 // header-code stolen from phpMyAdmin
\r
5497 // REGEDIT and bookmarklet code stolen from GreyMatter
\r
5499 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
\r
5500 $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
\r
5502 header('Content-Type: application/octetstream');
\r
5503 header('Content-Disposition: filename="nucleus.reg"');
\r
5504 header('Pragma: no-cache');
\r
5505 header('Expires: 0');
\r
5507 echo "REGEDIT4\n";
\r
5508 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
\r
5509 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
\r
5510 echo '"contexts"=hex:31';
\r
5514 * @todo document this
\r
5516 function action_bookmarklet() {
\r
5517 global $member, $manager;
\r
5519 $blogid = intRequestVar('blogid');
\r
5521 $member->teamRights($blogid) or $this->disallow();
\r
5523 $blog =& $manager->getBlog($blogid);
\r
5524 $bm = getBookmarklet($blogid);
\r
5526 $this->pagehead();
\r
5528 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
5532 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
\r
5535 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
\r
5538 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
\r
5540 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
\r
5543 <?php echo '<a href="' . htmlspecialchars($bm, ENT_QUOTES) . '">' . sprintf(_BOOKMARKLET_ANCHOR, htmlspecialchars($blog->getName(), ENT_QUOTES)) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
\r
5546 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
\r
5549 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
\r
5550 $url = $manager->addTicketToUrl($url);
\r
5552 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . htmlspecialchars($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
\r
5556 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
\r
5559 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
\r
5561 <?php echo _BOOKMARKLET_DELETEBAR ?>
\r
5565 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
\r
5569 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
\r
5570 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
\r
5571 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
\r
5572 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
\r
5573 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
\r
5577 $this->pagefoot();
\r
5582 * @todo document this
\r
5584 function action_actionlog() {
\r
5585 global $member, $manager;
\r
5587 $member->isAdmin() or $this->disallow();
\r
5589 $this->pagehead();
\r
5591 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
5593 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
\r
5596 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
\r
5597 <p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
\r
5599 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
\r
5601 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
\r
5602 $template['content'] = 'actionlist';
\r
5603 $amount = showlist($query,'table',$template);
\r
5605 $this->pagefoot();
\r
5610 * @todo document this
\r
5612 function action_banlist() {
\r
5613 global $member, $manager;
\r
5615 $blogid = intRequestVar('blogid');
\r
5617 $member->blogAdminRights($blogid) or $this->disallow();
\r
5619 $blog =& $manager->getBlog($blogid);
\r
5621 $this->pagehead();
\r
5623 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
\r
5625 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
\r
5627 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
\r
5628 $template['content'] = 'banlist';
\r
5629 $amount = showlist($query,'table',$template);
\r
5634 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
\r
5635 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
\r
5638 $this->pagefoot();
\r
5643 * @todo document this
\r
5645 function action_banlistdelete() {
\r
5646 global $member, $manager;
\r
5648 $blogid = intRequestVar('blogid');
\r
5649 $iprange = requestVar('iprange');
\r
5651 $member->blogAdminRights($blogid) or $this->disallow();
\r
5653 $blog =& $manager->getBlog($blogid);
\r
5654 $banBlogName = htmlspecialchars($blog->getName(), ENT_QUOTES);
\r
5656 $this->pagehead();
\r
5658 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
\r
5660 <form method="post" action="index.php">
\r
5662 <h3><?php echo _BAN_IPRANGE?></h3>
\r
5665 <?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>
\r
5666 <input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />
\r
5669 <h3><?php echo _BAN_BLOGS?></h3>
\r
5672 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
\r
5673 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
\r
5674 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
\r
5676 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
\r
5679 <h3><?php echo _BAN_DELETE_TITLE?></h3>
\r
5682 <?php $manager->addTicketHidden() ?>
\r
5683 <input type="hidden" name="action" value="banlistdeleteconfirm" />
\r
5684 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
5689 $this->pagefoot();
\r
5693 * @todo document this
\r
5695 function action_banlistdeleteconfirm() {
\r
5696 global $member, $manager;
\r
5698 $blogid = intPostVar('blogid');
\r
5699 $allblogs = postVar('allblogs');
\r
5700 $iprange = postVar('iprange');
\r
5702 $member->blogAdminRights($blogid) or $this->disallow();
\r
5704 $deleted = array();
\r
5707 if (BAN::removeBan($blogid, $iprange))
\r
5708 array_push($deleted, $blogid);
\r
5710 // get blogs fot which member has admin rights
\r
5711 $adminblogs = $member->getAdminBlogs();
\r
5712 foreach ($adminblogs as $blogje) {
\r
5713 if (BAN::removeBan($blogje, $iprange))
\r
5714 array_push($deleted, $blogje);
\r
5718 if (sizeof($deleted) == 0)
\r
5719 $this->error(_ERROR_DELETEBAN);
\r
5721 $this->pagehead();
\r
5723 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
\r
5724 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
\r
5725 echo "<p>"._BAN_REMOVED_TEXT."</p>";
\r
5728 foreach ($deleted as $delblog) {
\r
5729 $b =& $manager->getBlog($delblog);
\r
5730 echo "<li>" . htmlspecialchars($b->getName()). "</li>";
\r
5734 $this->pagefoot();
\r
5739 * @todo document this
\r
5741 function action_banlistnewfromitem() {
\r
5742 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
\r
5746 * @todo document this
\r
5748 function action_banlistnew($blogid = '') {
\r
5749 global $member, $manager;
\r
5751 if ($blogid == '')
\r
5752 $blogid = intRequestVar('blogid');
\r
5754 $ip = requestVar('ip');
\r
5756 $member->blogAdminRights($blogid) or $this->disallow();
\r
5758 $blog =& $manager->getBlog($blogid);
\r
5760 $this->pagehead();
\r
5762 <h2><?php echo _BAN_ADD_TITLE?></h2>
\r
5765 <form method="post" action="index.php">
\r
5767 <h3><?php echo _BAN_IPRANGE?></h3>
\r
5769 <p><?php echo _BAN_IPRANGE_TEXT?></p>
\r
5771 <div class="note">
\r
5772 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
\r
5773 <?php echo _BAN_EXAMPLE_TEXT ?>
\r
5779 $iprangeVal = htmlspecialchars($ip, ENT_QUOTES);
\r
5781 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
\r
5782 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
\r
5784 <input name="iprange" type="radio" value="custom" id="ip_custom" />
\r
5785 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
\r
5786 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
\r
5789 echo "<input name='iprange' value='custom' type='hidden' />";
\r
5790 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
\r
5795 <h3><?php echo _BAN_BLOGS?></h3>
\r
5797 <p><?php echo _BAN_BLOGS_TEXT?></p>
\r
5800 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
\r
5801 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>
\r
5803 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
\r
5806 <h3><?php echo _BAN_REASON_TITLE?></h3>
\r
5808 <p><?php echo _BAN_REASON_TEXT?></p>
\r
5810 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
\r
5812 <h3><?php echo _BAN_ADD_TITLE?></h3>
\r
5815 <input name="action" type="hidden" value="banlistadd" />
\r
5816 <?php $manager->addTicketHidden() ?>
\r
5817 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
\r
5822 <?php $this->pagefoot();
\r
5826 * @todo document this
\r
5828 function action_banlistadd() {
\r
5831 $blogid = intPostVar('blogid');
\r
5832 $allblogs = postVar('allblogs');
\r
5833 $iprange = postVar('iprange');
\r
5834 if ($iprange == "custom")
\r
5835 $iprange = postVar('customiprange');
\r
5836 $reason = postVar('reason');
\r
5838 $member->blogAdminRights($blogid) or $this->disallow();
\r
5840 // TODO: check IP range validity
\r
5843 if (!BAN::addBan($blogid, $iprange, $reason))
\r
5844 $this->error(_ERROR_ADDBAN);
\r
5846 // get blogs fot which member has admin rights
\r
5847 $adminblogs = $member->getAdminBlogs();
\r
5849 foreach ($adminblogs as $blogje) {
\r
5850 if (!BAN::addBan($blogje, $iprange, $reason))
\r
5854 $this->error(_ERROR_ADDBAN);
\r
5857 $this->action_banlist();
\r
5862 * @todo document this
\r
5864 function action_clearactionlog() {
\r
5867 $member->isAdmin() or $this->disallow();
\r
5869 ACTIONLOG::clear();
\r
5871 $this->action_manage(_MSG_ACTIONLOGCLEARED);
\r
5875 * @todo document this
\r
5877 function action_backupoverview() {
\r
5878 global $member, $manager;
\r
5880 $member->isAdmin() or $this->disallow();
\r
5882 $this->pagehead();
\r
5884 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
5886 <h2><?php echo _BACKUPS_TITLE?></h2>
\r
5888 <h3><?php echo _BACKUP_TITLE?></h3>
\r
5890 <p><?php echo _BACKUP_INTRO?></p>
\r
5892 <form method="post" action="index.php"><p>
\r
5893 <input type="hidden" name="action" value="backupcreate" />
\r
5894 <?php $manager->addTicketHidden() ?>
\r
5896 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
\r
5898 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
\r
5900 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
\r
5904 <div class="note"><?php echo _BACKUP_NOTE?></div>
\r
5907 <h3><?php echo _RESTORE_TITLE?></h3>
\r
5909 <div class="note"><?php echo _RESTORE_NOTE?></div>
\r
5911 <p><?php echo _RESTORE_INTRO?></p>
\r
5913 <form method="post" action="index.php" enctype="multipart/form-data"><p>
\r
5914 <input type="hidden" name="action" value="backuprestore" />
\r
5915 <?php $manager->addTicketHidden() ?>
\r
5916 <input name="backup_file" type="file" tabindex="30" />
\r
5918 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
\r
5919 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
\r
5920 <br /><?php echo _RESTORE_WARNING?>
\r
5923 <?php $this->pagefoot();
\r
5927 * @todo document this
\r
5929 function action_backupcreate() {
\r
5930 global $member, $DIR_LIBS;
\r
5932 $member->isAdmin() or $this->disallow();
\r
5934 // use compression ?
\r
5935 $useGzip = intval(postVar('gzip'));
\r
5937 include($DIR_LIBS . 'backup.php');
\r
5939 // try to extend time limit
\r
5940 // (creating/restoring dumps might take a while)
\r
5941 @set_time_limit(1200);
\r
5943 $bu = new Backup();
\r
5944 $bu->do_backup($useGzip);
\r
5949 * @todo document this
\r
5951 function action_backuprestore() {
\r
5952 global $member, $DIR_LIBS;
\r
5954 $member->isAdmin() or $this->disallow();
\r
5956 if (intPostVar('letsgo') != 1)
\r
5957 $this->error(_ERROR_BACKUP_NOTSURE);
\r
5959 include($DIR_LIBS . 'backup.php');
\r
5961 // try to extend time limit
\r
5962 // (creating/restoring dumps might take a while)
\r
5963 @set_time_limit(1200);
\r
5965 $bu = new Backup();
\r
5966 $message = $bu->do_restore();
\r
5967 if ($message != '')
\r
5968 $this->error($message);
\r
5970 $this->pagehead();
\r
5972 <h2><?php echo _RESTORE_COMPLETE?></h2>
\r
5973 <?php $this->pagefoot();
\r
5978 * @todo document this
\r
5980 function action_pluginlist() {
\r
5981 global $member, $manager;
\r
5983 // check if allowed
\r
5984 $member->isAdmin() or $this->disallow();
\r
5986 $this->pagehead();
\r
5988 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
\r
5990 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
\r
5992 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
\r
5995 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
\r
5997 $template['content'] = 'pluginlist';
\r
5998 $template['tabindex'] = 10;
\r
5999 showlist($query, 'table', $template);
\r
6002 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
\r
6004 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
\r
6006 <form method="post" action="index.php"><div>
\r
6007 <input type="hidden" name="action" value="pluginupdate" />
\r
6008 <?php $manager->addTicketHidden() ?>
\r
6009 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
\r
6012 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
\r
6015 // find a list of possibly non-installed plugins
\r
6016 $candidates = array();
\r
6017 global $DIR_PLUGINS;
\r
6018 $dirhandle = opendir($DIR_PLUGINS);
\r
6019 while ($filename = readdir($dirhandle) )
\r
6021 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
\r
6022 # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
\r
6023 if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
\r
6025 $name = $matches[1];
\r
6026 // only show in list when not yet installed
\r
6027 $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
\r
6028 if (sql_num_rows($res) == 0)
\r
6030 array_push($candidates, $name);
\r
6034 closedir($dirhandle);
\r
6036 if (sizeof($candidates) > 0)
\r
6040 <p><?php echo _PLUGS_ADD_TEXT?></p>
\r
6043 <form method='post' action='index.php'><div>
\r
6044 <input type='hidden' name='action' value='pluginadd' />
\r
6045 <?php $manager->addTicketHidden() ?>
\r
6046 <select name="filename" tabindex="30">
\r
6048 foreach($candidates as $name)
\r
6050 echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';
\r
6054 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
\r
6061 echo '<p>',_PLUGS_NOCANDIDATES,'</p>';
\r
6064 $this->pagefoot();
\r
6068 * @todo document this
\r
6070 function action_pluginhelp() {
\r
6071 global $member, $manager, $DIR_PLUGINS, $CONF;
\r
6073 // check if allowed
\r
6074 $member->isAdmin() or $this->disallow();
\r
6076 $plugid = intGetVar('plugid');
\r
6078 if (!$manager->pidInstalled($plugid))
\r
6079 $this->error(_ERROR_NOSUCHPLUGIN);
\r
6081 $plugName = getPluginNameFromPid($plugid);
\r
6083 $this->pagehead();
\r
6085 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
\r
6087 echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';
\r
6089 $plug =& $manager->getPlugin($plugName);
\r
6090 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
\r
6092 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
\r
6093 @readfile($helpFile);
\r
6095 echo '<p>' . _ERROR .': ', _ERROR_PLUGNOHELPFILE,'</p>';
\r
6096 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
\r
6100 $this->pagefoot();
\r
6104 * @todo document this
\r
6106 function action_pluginadd() {
\r
6107 global $member, $manager, $DIR_PLUGINS;
\r
6109 // check if allowed
\r
6110 $member->isAdmin() or $this->disallow();
\r
6112 $name = postVar('filename');
\r
6114 if ($manager->pluginInstalled($name))
\r
6115 $this->error(_ERROR_DUPPLUGIN);
\r
6116 if (!checkPlugin($name))
\r
6117 $this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');
\r
6119 // get number of currently installed plugins
\r
6120 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
\r
6121 $numCurrent = sql_num_rows($res);
\r
6123 // plugin will be added as last one in the list
\r
6124 $newOrder = $numCurrent + 1;
\r
6129 $manager->notify('PreAddPlugin', $param);
\r
6131 // do this before calling getPlugin (in case the plugin id is used there)
\r
6132 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
\r
6133 sql_query($query);
\r
6134 $iPid = sql_insert_id();
\r
6136 $manager->clearCachedInfo('installedPlugins');
\r
6138 // Load the plugin for condition checking and instalation
\r
6139 $plugin =& $manager->getPlugin($name);
\r
6141 // check if it got loaded (could have failed)
\r
6144 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
\r
6145 $manager->clearCachedInfo('installedPlugins');
\r
6146 $this->error(_ERROR_PLUGIN_LOAD);
\r
6149 // check if plugin needs a newer Nucleus version
\r
6150 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
\r
6152 // uninstall plugin again...
\r
6153 $this->deleteOnePlugin($plugin->getID());
\r
6155 // ...and show error
\r
6156 $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));
\r
6159 // check if plugin needs a newer Nucleus version
\r
6160 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
\r
6162 // uninstall plugin again...
\r
6163 $this->deleteOnePlugin($plugin->getID());
\r
6165 // ...and show error
\r
6166 $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
\r
6169 $pluginList = $plugin->getPluginDep();
\r
6170 foreach ($pluginList as $pluginName)
\r
6173 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
\r
6174 if (sql_num_rows($res) == 0)
\r
6176 // uninstall plugin again...
\r
6177 $this->deleteOnePlugin($plugin->getID());
\r
6179 $this->error(sprintf(_ERROR_INSREQPLUGIN, htmlspecialchars($pluginName, ENT_QUOTES)));
\r
6183 // call the install method of the plugin
\r
6184 $plugin->install();
\r
6187 'plugin' => &$plugin
\r
6189 $manager->notify('PostAddPlugin', $param);
\r
6191 // update all events
\r
6192 $this->action_pluginupdate();
\r
6196 * @todo document this
\r
6198 function action_pluginupdate() {
\r
6199 global $member, $manager, $CONF;
\r
6201 // check if allowed
\r
6202 $member->isAdmin() or $this->disallow();
\r
6204 // delete everything from plugin_events
\r
6205 sql_query('DELETE FROM '.sql_table('plugin_event'));
\r
6207 // loop over all installed plugins
\r
6208 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
\r
6209 while($o = sql_fetch_object($res)) {
\r
6211 $plug =& $manager->getPlugin($o->pfile);
\r
6214 $eventList = $plug->getEventList();
\r
6215 foreach ($eventList as $eventName)
\r
6216 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
\r
6220 redirect($CONF['AdminURL'] . '?action=pluginlist');
\r
6221 // $this->action_pluginlist();
\r
6225 * @todo document this
\r
6227 function action_plugindelete() {
\r
6228 global $member, $manager;
\r
6230 // check if allowed
\r
6231 $member->isAdmin() or $this->disallow();
\r
6233 $pid = intGetVar('plugid');
\r
6235 if (!$manager->pidInstalled($pid))
\r
6236 $this->error(_ERROR_NOSUCHPLUGIN);
\r
6238 $this->pagehead();
\r
6240 <h2><?php echo _DELETE_CONFIRM?></h2>
\r
6242 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
\r
6244 <form method="post" action="index.php"><div>
\r
6245 <?php $manager->addTicketHidden() ?>
\r
6246 <input type="hidden" name="action" value="plugindeleteconfirm" />
\r
6247 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
\r
6248 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
\r
6251 $this->pagefoot();
\r
6255 * @todo document this
\r
6257 function action_plugindeleteconfirm() {
\r
6258 global $member, $manager, $CONF;
\r
6260 // check if allowed
\r
6261 $member->isAdmin() or $this->disallow();
\r
6263 $pid = intPostVar('plugid');
\r
6265 $error = $this->deleteOnePlugin($pid, 1);
\r
6267 $this->error($error);
\r
6270 redirect($CONF['AdminURL'] . '?action=pluginlist');
\r
6271 // $this->action_pluginlist();
\r
6275 * @todo document this
\r
6277 function deleteOnePlugin($pid, $callUninstall = 0) {
\r
6280 $pid = intval($pid);
\r
6282 if (!$manager->pidInstalled($pid))
\r
6283 return _ERROR_NOSUCHPLUGIN;
\r
6285 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
\r
6287 /* // call the unInstall method of the plugin
\r
6288 if ($callUninstall) {
\r
6289 $plugin =& $manager->getPlugin($name);
\r
6290 if ($plugin) $plugin->unInstall();
\r
6293 // check dependency before delete
\r
6294 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
\r
6295 while($o = sql_fetch_object($res)) {
\r
6296 $plug =& $manager->getPlugin($o->pfile);
\r
6299 $depList = $plug->getPluginDep();
\r
6300 foreach ($depList as $depName)
\r
6302 if ($name == $depName)
\r
6304 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
\r
6310 $param = array('plugid' => $pid);
\r
6311 $manager->notify('PreDeletePlugin', $param);
\r
6313 // call the unInstall method of the plugin
\r
6314 if ($callUninstall) {
\r
6315 $plugin =& $manager->getPlugin($name);
\r
6316 if ($plugin) $plugin->unInstall();
\r
6319 // delete all subscriptions
\r
6320 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
\r
6322 // delete all options
\r
6323 // get OIDs from plugin_option_desc
\r
6324 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
\r
6326 while ($o = sql_fetch_object($res)) {
\r
6327 array_push($aOIDs, $o->oid);
\r
6330 // delete from plugin_option and plugin_option_desc
\r
6331 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
\r
6332 if (count($aOIDs) > 0)
\r
6333 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
\r
6335 // update order numbers
\r
6336 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
\r
6337 $o = sql_fetch_object($res);
\r
6338 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
\r
6341 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
\r
6343 $manager->clearCachedInfo('installedPlugins');
\r
6344 $param = array('plugid' => $pid);
\r
6345 $manager->notify('PostDeletePlugin', $param);
\r
6351 * @todo document this
\r
6353 function action_pluginup() {
\r
6354 global $member, $manager, $CONF;
\r
6356 // check if allowed
\r
6357 $member->isAdmin() or $this->disallow();
\r
6359 $plugid = intGetVar('plugid');
\r
6361 if (!$manager->pidInstalled($plugid))
\r
6362 $this->error(_ERROR_NOSUCHPLUGIN);
\r
6364 // 1. get old order number
\r
6365 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
\r
6366 $o = sql_fetch_object($res);
\r
6367 $oldOrder = $o->porder;
\r
6369 // 2. calculate new order number
\r
6370 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
\r
6372 // 3. update plug numbers
\r
6373 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
\r
6374 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
\r
6376 //$this->action_pluginlist();
\r
6377 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
\r
6378 redirect($CONF['AdminURL'] . '?action=pluginlist');
\r
6382 * @todo document this
\r
6384 function action_plugindown() {
\r
6385 global $member, $manager, $CONF;
\r
6387 // check if allowed
\r
6388 $member->isAdmin() or $this->disallow();
\r
6390 $plugid = intGetVar('plugid');
\r
6391 if (!$manager->pidInstalled($plugid))
\r
6392 $this->error(_ERROR_NOSUCHPLUGIN);
\r
6394 // 1. get old order number
\r
6395 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
\r
6396 $o = sql_fetch_object($res);
\r
6397 $oldOrder = $o->porder;
\r
6399 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
\r
6400 $maxOrder = sql_num_rows($res);
\r
6402 // 2. calculate new order number
\r
6403 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
\r
6405 // 3. update plug numbers
\r
6406 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
\r
6407 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
\r
6409 //$this->action_pluginlist();
\r
6410 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
\r
6411 redirect($CONF['AdminURL'] . '?action=pluginlist');
\r
6415 * @todo document this
\r
6417 function action_pluginoptions($message = '') {
\r
6418 global $member, $manager;
\r
6420 // check if allowed
\r
6421 $member->isAdmin() or $this->disallow();
\r
6423 $pid = intRequestVar('plugid');
\r
6424 if (!$manager->pidInstalled($pid))
\r
6425 $this->error(_ERROR_NOSUCHPLUGIN);
\r
6427 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
\r
6428 $pluginName = htmlspecialchars(getPluginNameFromPid($pid), ENT_QUOTES);
\r
6429 $this->pagehead($extrahead);
\r
6432 <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
\r
6434 <h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>
\r
6436 <?php if ($message) echo $message?>
\r
6438 <form action="index.php" method="post">
\r
6440 <input type="hidden" name="action" value="pluginoptionsupdate" />
\r
6441 <input type="hidden" name="plugid" value="<?php echo $pid?>" />
\r
6445 $manager->addTicketHidden();
\r
6447 $aOptions = array();
\r
6449 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
\r
6450 $r = sql_query($query);
\r
6451 while ($o = sql_fetch_object($r)) {
\r
6452 array_push($aOIDs, $o->oid);
\r
6453 $aOptions[$o->oid] = array(
\r
6455 'value' => $o->odef,
\r
6456 'name' => $o->oname,
\r
6457 'description' => $o->odesc,
\r
6458 'type' => $o->otype,
\r
6459 'typeinfo' => $o->oextra,
\r
6463 // fill out actual values
\r
6464 if (count($aOIDs) > 0) {
\r
6465 $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
\r
6466 while ($o = sql_fetch_object($r))
\r
6467 $aOptions[$o->oid]['value'] = $o->ovalue;
\r
6472 'context' => 'global',
\r
6474 'options' => &$aOptions
\r
6476 $manager->notify('PrePluginOptionsEdit', $param);
\r
6478 $template['content'] = 'plugoptionlist';
\r
6479 $amount = showlist($aOptions,'table',$template);
\r
6481 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
\r
6486 <?php $this->pagefoot();
\r
6493 * @todo document this
\r
6495 function action_pluginoptionsupdate() {
\r
6496 global $member, $manager;
\r
6498 // check if allowed
\r
6499 $member->isAdmin() or $this->disallow();
\r
6501 $pid = intRequestVar('plugid');
\r
6502 if (!$manager->pidInstalled($pid))
\r
6503 $this->error(_ERROR_NOSUCHPLUGIN);
\r
6505 $aOptions = requestArray('plugoption');
\r
6506 NucleusPlugin::_applyPluginOptions($aOptions);
\r
6509 'context' => 'global',
\r
6512 $manager->notify('PostPluginOptionsUpdate', $param);
\r
6514 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
\r
6519 * @todo document this
\r
6521 function _insertPluginOptions($context, $contextid = 0) {
\r
6522 // get all current values for this contextid
\r
6523 // (note: this might contain doubles for overlapping contextids)
\r
6524 $aIdToValue = array();
\r
6525 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
\r
6526 while ($o = sql_fetch_object($res)) {
\r
6527 $aIdToValue[$o->oid] = $o->ovalue;
\r
6530 // get list of oids per pid
\r
6531 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
\r
6532 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
\r
6533 $res = sql_query($query);
\r
6534 $aOptions = array();
\r
6535 while ($o = sql_fetch_object($res)) {
\r
6536 if (in_array($o->oid, array_keys($aIdToValue)))
\r
6537 $value = $aIdToValue[$o->oid];
\r
6539 $value = $o->odef;
\r
6541 array_push($aOptions, array(
\r
6543 'pfile' => $o->pfile,
\r
6545 'value' => $value,
\r
6546 'name' => $o->oname,
\r
6547 'description' => $o->odesc,
\r
6548 'type' => $o->otype,
\r
6549 'typeinfo' => $o->oextra,
\r
6550 'contextid' => $contextid,
\r
6557 'context' => $context,
\r
6558 'contextid' => $contextid,
\r
6559 'options' => &$aOptions
\r
6561 $manager->notify('PrePluginOptionsEdit', $param);
\r
6565 foreach ($aOptions as $aOption) {
\r
6568 if ($iPrevPid != $aOption['pid']) {
\r
6569 $iPrevPid = $aOption['pid'];
\r
6570 if (!defined('_PLUGIN_OPTIONS_TITLE')) {
\r
6571 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
\r
6573 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, htmlspecialchars($aOption['pfile'], ENT_QUOTES)).'</th></tr>';
\r
6576 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
\r
6577 if (@$meta['access'] != 'hidden') {
\r
6579 listplug_plugOptionRow($aOption);
\r
6586 * Helper functions to create option forms etc.
\r
6587 * @todo document parameters
\r
6589 function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
\r
6590 $id = htmlspecialchars($name);
\r
6591 $id = str_replace('[','-',$id);
\r
6592 $id = str_replace(']','-',$id);
\r
6593 $id1 = $id . htmlspecialchars($value1);
\r
6594 $id2 = $id . htmlspecialchars($value2);
\r
6596 if ($name=="admin") {
\r
6597 echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
\r
6599 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
\r
6602 if ($checkedval == $value1)
\r
6603 echo "tabindex='$tabindex' checked='checked'";
\r
6604 echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
\r
6606 if ($name=="admin") {
\r
6607 echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
\r
6609 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
\r
6611 if ($checkedval != $value1)
\r
6612 echo "tabindex='$tabindex' checked='checked'";
\r
6613 if ($isAdmin && $name=="canlogin")
\r
6614 echo ' disabled="disabled"';
\r
6615 echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';
\r