3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * The code for the Nucleus admin area
15 * @license http://nucleuscms.org/license.txt GNU General Public License
16 * @copyright Copyright (C) 2002-2009 The Nucleus Group
17 * @version $Id: ADMIN.php 1626 2012-01-09 15:46:54Z sakamocchi $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
28 private $xml_version_info = '1.0';
29 private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
30 private $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
31 private $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
33 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
47 * @param string $action action to be performed
49 function action($action) {
50 global $CONF, $manager;
52 // list of action aliases
54 'login' => 'overview',
58 if (isset($alias[$action]))
59 $action = $alias[$action];
61 $methodName = 'action_' . $action;
63 $this->action = strtolower($action);
65 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
66 // is an action that requires user interaction before something is actually done)
67 // all safe actions are in this array:
68 $aActionsNotToCheck = array(
120 // the rest of the actions needs to be checked
121 $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');
123 if (!in_array($this->action, $aActionsNotToCheck))
125 if (!$manager->checkTicket())
126 $this->error(_ERROR_BADTICKET);
129 if (method_exists($this, $methodName))
130 call_user_func(array(&$this, $methodName));
132 $this->error(_BADACTION . i18n::hsc(" ($action)"));
137 * @todo document this
139 function action_showlogin() {
141 $this->action_login($error);
145 * @todo document this
147 function action_login($msg = '', $passvars = 1) {
150 // skip to overview when allowed
151 if ($member->isLoggedIn() && $member->canLogin()) {
152 $this->action_overview();
158 echo '<h2>', _LOGIN ,'</h2>';
159 if ($msg) echo _MESSAGE , ': ', i18n::hsc($msg);
162 <form action="index.php" method="post"><p>
163 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
165 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
167 <input name="action" value="login" type="hidden" />
169 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
172 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
173 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
175 <?php // pass through vars
177 $oldaction = postVar('oldaction');
178 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
185 <?php $this->pagefoot();
190 * provides a screen with the overview of the actions available
191 * @todo document parameter
193 function action_overview($msg = '') {
199 echo _MESSAGE , ': ', $msg;
201 /* ---- add items ---- */
202 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
204 $showAll = requestVar('showall');
206 if (($member->isAdmin()) && ($showAll == 'yes')) {
207 // Super-Admins have access to all blogs! (no add item support though)
208 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
209 . ' FROM ' . sql_table('blog')
212 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
213 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
214 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
217 $template['content'] = 'bloglist';
218 $template['superadmin'] = $member->isAdmin();
219 $amount = showlist($query,'table',$template);
221 if (($showAll != 'yes') && ($member->isAdmin())) {
222 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
223 if ($total > $amount)
224 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
228 echo _OVERVIEW_NOBLOGS;
231 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
232 $query = 'SELECT ititle, inumber, bshortname'
233 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
234 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
235 $template['content'] = 'draftlist';
236 $amountdrafts = showlist($query, 'table', $template);
237 if ($amountdrafts == 0)
238 echo _OVERVIEW_NODRAFTS;
242 $yrBlogs = $member->getAdminBlogs();
243 if ($showAll != 'yes') {
245 foreach ($yrBlogs as $value) {
246 if ($member->isBlogAdmin(intval($value))) {
247 $admBlogs[] = intval($value);
250 $yrBlogs = $admBlogs;
253 if (count($yrBlogs) > 0) {
254 echo '<h2>' . _OVERVIEW_OTHER_DRAFTS . '</h2>';
255 $query = 'SELECT ititle, inumber, bshortname, mname'
256 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog'). ', ' . sql_table('member')
257 . ' WHERE iauthor<>'.$member->getID().' and iblog IN ('.implode(",",$yrBlogs).') and iblog=bnumber and iauthor=mnumber and idraft=1'
258 . ' ORDER BY iblog ASC';
259 $template['content'] = 'otherdraftlist';
260 $amountdrafts = showlist($query, 'table', $template);
261 if ($amountdrafts == 0)
262 echo _OVERVIEW_NODRAFTS;
266 /* ---- user settings ---- */
267 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
269 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
270 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
271 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
274 /* ---- general settings ---- */
275 if ($member->isAdmin()) {
276 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
278 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
287 * Returns a link to a weblog
290 function bloglink(&$blog) {
291 return '<a href="'.i18n::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. i18n::hsc( $blog->getName() ) .'</a>';
295 * @todo document this
297 function action_manage($msg = '') {
300 $member->isAdmin() or $this->disallow();
304 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
307 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
310 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
313 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
314 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
315 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
316 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
319 echo '<h2>' . _MANAGE_SKINS . '</h2>';
321 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
322 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
323 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
326 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
328 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
329 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
336 * @todo document this
338 function action_itemlist($blogid = '') {
339 global $member, $manager, $CONF;
342 $blogid = intRequestVar('blogid');
344 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
347 $blog =& $manager->getBlog($blogid);
349 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
350 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
353 if (postVar('start'))
354 $start = intPostVar('start');
359 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
361 // amount of items to show
362 if (postVar('amount'))
363 $amount = intPostVar('amount');
365 $amount = intval($CONF['DefaultListSize']);
370 $search = postVar('search'); // search through items
372 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
373 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
374 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
377 $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) . '%"))';
379 // non-blog-admins can only edit/delete their own items
380 if (!$member->blogAdminRights($blogid))
381 $query .= ' and iauthor=' . $member->getID();
384 $query .= ' ORDER BY itime DESC'
385 . " LIMIT $start,$amount";
387 $template['content'] = 'itemlist';
388 $template['now'] = $blog->getCorrectTime(time());
390 $manager->loadClass("ENCAPSULATE");
391 $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
392 $navList->showBatchList('item',$query,'table',$template);
399 * @todo document this
401 function action_batchitem() {
402 global $member, $manager;
404 // check if logged in
405 $member->isLoggedIn() or $this->disallow();
407 // more precise check will be done for each performed operation
409 // get array of itemids from request
410 $selected = requestIntArray('batch');
411 $action = requestVar('batchaction');
413 // Show error when no items were selected
414 if (!is_array($selected) || sizeof($selected) == 0)
415 $this->error(_BATCH_NOSELECTION);
417 // On move: when no destination blog/category chosen, show choice now
418 $destCatid = intRequestVar('destcatid');
419 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
420 $this->batchMoveSelectDestination('item',$selected);
422 // On delete: check if confirmation has been given
423 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
424 $this->batchAskDeleteConfirmation('item',$selected);
428 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
429 echo '<h2>',_BATCH_ITEMS,'</h2>';
430 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
434 // walk over all itemids and perform action
435 foreach ($selected as $itemid) {
436 $itemid = intval($itemid);
437 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
439 // perform action, display errors if needed
442 $error = $this->deleteOneItem($itemid);
445 $error = $this->moveOneItem($itemid, $destCatid);
448 $error = _BATCH_UNKNOWN . i18n::hsc($action);
451 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
456 echo '<b>',_BATCH_DONE,'</b>';
464 * @todo document this
466 function action_batchcomment() {
469 // check if logged in
470 $member->isLoggedIn() or $this->disallow();
472 // more precise check will be done for each performed operation
474 // get array of itemids from request
475 $selected = requestIntArray('batch');
476 $action = requestVar('batchaction');
478 // Show error when no items were selected
479 if (!is_array($selected) || sizeof($selected) == 0)
480 $this->error(_BATCH_NOSELECTION);
482 // On delete: check if confirmation has been given
483 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
484 $this->batchAskDeleteConfirmation('comment',$selected);
488 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
489 echo '<h2>',_BATCH_COMMENTS,'</h2>';
490 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
493 // walk over all itemids and perform action
494 foreach ($selected as $commentid) {
495 $commentid = intval($commentid);
496 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
498 // perform action, display errors if needed
501 $error = $this->deleteOneComment($commentid);
504 $error = _BATCH_UNKNOWN . i18n::hsc($action);
507 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
512 echo '<b>',_BATCH_DONE,'</b>';
520 * @todo document this
522 function action_batchmember() {
525 // check if logged in and admin
526 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
528 // get array of itemids from request
529 $selected = requestIntArray('batch');
530 $action = requestVar('batchaction');
532 // Show error when no members selected
533 if (!is_array($selected) || sizeof($selected) == 0)
534 $this->error(_BATCH_NOSELECTION);
536 // On delete: check if confirmation has been given
537 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
538 $this->batchAskDeleteConfirmation('member',$selected);
542 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
543 echo '<h2>',_BATCH_MEMBERS,'</h2>';
544 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
547 // walk over all itemids and perform action
548 foreach ($selected as $memberid) {
549 $memberid = intval($memberid);
550 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
552 // perform action, display errors if needed
555 $error = $this->deleteOneMember($memberid);
559 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
563 // there should always remain at least one super-admin
564 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
565 if (sql_num_rows($r) < 2)
566 $error = _ERROR_ATLEASTONEADMIN;
568 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
571 $error = _BATCH_UNKNOWN . i18n::hsc($action);
574 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
579 echo '<b>',_BATCH_DONE,'</b>';
587 * @todo document this
589 function action_batchteam() {
592 $blogid = intRequestVar('blogid');
594 // check if logged in and admin
595 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
597 // get array of itemids from request
598 $selected = requestIntArray('batch');
599 $action = requestVar('batchaction');
601 // Show error when no members selected
602 if (!is_array($selected) || sizeof($selected) == 0)
603 $this->error(_BATCH_NOSELECTION);
605 // On delete: check if confirmation has been given
606 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
607 $this->batchAskDeleteConfirmation('team',$selected);
611 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
613 echo '<h2>',_BATCH_TEAM,'</h2>';
614 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
617 // walk over all itemids and perform action
618 foreach ($selected as $memberid) {
619 $memberid = intval($memberid);
620 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
622 // perform action, display errors if needed
625 $error = $this->deleteOneTeamMember($blogid, $memberid);
629 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
633 // there should always remain at least one admin
634 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
635 if (sql_num_rows($r) < 2)
636 $error = _ERROR_ATLEASTONEBLOGADMIN;
638 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
641 $error = _BATCH_UNKNOWN . i18n::hsc($action);
644 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
649 echo '<b>',_BATCH_DONE,'</b>';
657 * @todo document this
659 function action_batchcategory() {
660 global $member, $manager;
662 // check if logged in
663 $member->isLoggedIn() or $this->disallow();
665 // more precise check will be done for each performed operation
667 // get array of itemids from request
668 $selected = requestIntArray('batch');
669 $action = requestVar('batchaction');
671 // Show error when no items were selected
672 if (!is_array($selected) || sizeof($selected) == 0)
673 $this->error(_BATCH_NOSELECTION);
675 // On move: when no destination blog chosen, show choice now
676 $destBlogId = intRequestVar('destblogid');
677 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
678 $this->batchMoveCategorySelectDestination('category',$selected);
680 // On delete: check if confirmation has been given
681 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
682 $this->batchAskDeleteConfirmation('category',$selected);
686 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
687 echo '<h2>',BATCH_CATEGORIES,'</h2>';
688 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
691 // walk over all itemids and perform action
692 foreach ($selected as $catid) {
693 $catid = intval($catid);
694 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
696 // perform action, display errors if needed
699 $error = $this->deleteOneCategory($catid);
702 $error = $this->moveOneCategory($catid, $destBlogId);
705 $error = _BATCH_UNKNOWN . i18n::hsc($action);
708 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
713 echo '<b>',_BATCH_DONE,'</b>';
720 * @todo document this
722 function batchMoveSelectDestination($type, $ids) {
726 <h2><?php echo _MOVE_TITLE?></h2>
727 <form method="post" action="index.php"><div>
729 <input type="hidden" name="action" value="batch<?php echo $type?>" />
730 <input type="hidden" name="batchaction" value="move" />
732 $manager->addTicketHidden();
734 // insert selected item numbers
736 foreach ($ids as $id)
737 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
739 // show blog/category selection list
740 $this->selectBlogCategory('destcatid');
745 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
748 <?php $this->pagefoot();
753 * @todo document this
755 function batchMoveCategorySelectDestination($type, $ids) {
759 <h2><?php echo _MOVECAT_TITLE?></h2>
760 <form method="post" action="index.php"><div>
762 <input type="hidden" name="action" value="batch<?php echo $type?>" />
763 <input type="hidden" name="batchaction" value="move" />
765 $manager->addTicketHidden();
767 // insert selected item numbers
769 foreach ($ids as $id)
770 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
772 // show blog/category selection list
773 $this->selectBlog('destblogid');
778 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
781 <?php $this->pagefoot();
786 * @todo document this
788 function batchAskDeleteConfirmation($type, $ids) {
793 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
794 <form method="post" action="index.php"><div>
796 <input type="hidden" name="action" value="batch<?php echo $type?>" />
797 <?php $manager->addTicketHidden() ?>
798 <input type="hidden" name="batchaction" value="delete" />
799 <input type="hidden" name="confirmation" value="yes" />
800 <?php // insert selected item numbers
802 foreach ($ids as $id)
803 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
805 // add hidden vars for team & comment
808 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
810 if ($type == 'comment')
812 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
817 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
820 <?php $this->pagefoot();
826 * Inserts a HTML select element with choices for all categories to which the current
828 * @see function selectBlog
830 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
831 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
835 * Inserts a HTML select element with choices for all blogs to which the user has access
836 * mode = 'blog' => shows blognames and values are blogids
837 * mode = 'category' => show category names and values are catids
839 * @param $iForcedBlogInclude
840 * ID of a blog that always needs to be included, without checking if the
841 * member is on the blog team (-1 = none)
842 * @todo document parameters
844 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
845 global $member, $CONF;
847 // 0. get IDs of blogs to which member can post items (+ forced blog)
849 if ($iForcedBlogInclude != -1)
850 $aBlogIds[] = intval($iForcedBlogInclude);
852 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
853 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
855 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
856 $rblogids = sql_query($queryBlogs);
857 while ($o = sql_fetch_object($rblogids))
858 if ($o->bnumber != $iForcedBlogInclude)
859 $aBlogIds[] = intval($o->bnumber);
861 if (count($aBlogIds) == 0)
864 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
866 // 1. select blogs (we'll create optiongroups)
867 // (only select those blogs that have the user on the team)
868 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
869 $blogs = sql_query($queryBlogs);
870 if ($mode == 'category') {
871 if (sql_num_rows($blogs) > 1)
874 while ($oBlog = sql_fetch_object($blogs)) {
876 echo '<optgroup label="',i18n::hsc($oBlog->bname),'">';
878 // show selection to create new category when allowed/wanted
880 // check if allowed to do so
881 if ($member->blogAdminRights($oBlog->bnumber))
882 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
885 // 2. for each category in that blog
886 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
887 while ($oCat = sql_fetch_object($categories)) {
888 if ($oCat->catid == $selected)
889 $selectText = ' selected="selected" ';
892 echo '<option value="',$oCat->catid,'" ', $selectText,'>',i18n::hsc($oCat->cname),'</option>';
900 while ($oBlog = sql_fetch_object($blogs)) {
901 echo '<option value="',$oBlog->bnumber,'"';
902 if ($oBlog->bnumber == $selected)
903 echo ' selected="selected"';
904 echo'>',i18n::hsc($oBlog->bname),'</option>';
912 * @todo document this
914 function action_browseownitems() {
915 global $member, $manager, $CONF;
919 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
920 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
923 if (postVar('start'))
924 $start = intPostVar('start');
928 // amount of items to show
929 if (postVar('amount'))
930 $amount = intPostVar('amount');
932 $amount = intval($CONF['DefaultListSize']);
937 $search = postVar('search'); // search through items
939 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
940 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
941 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
944 $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) . '%"))';
946 $query .= ' ORDER BY itime DESC'
947 . " LIMIT $start,$amount";
949 $template['content'] = 'itemlist';
950 $template['now'] = time();
952 $manager->loadClass("ENCAPSULATE");
953 $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
954 $navList->showBatchList('item',$query,'table',$template);
961 * Show all the comments for a given item
964 function action_itemcommentlist($itemid = '') {
965 global $member, $manager, $CONF;
968 $itemid = intRequestVar('itemid');
970 // only allow if user is allowed to alter item
971 $member->canAlterItem($itemid) or $this->disallow();
973 $blogid = getBlogIdFromItemId($itemid);
978 if (postVar('start'))
979 $start = intPostVar('start');
983 // amount of items to show
984 if (postVar('amount'))
985 $amount = intPostVar('amount');
987 $amount = intval($CONF['DefaultListSize']);
992 $search = postVar('search');
994 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
995 echo '<h2>',_COMMENTS,'</h2>';
997 $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;
1000 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1002 $query .= ' ORDER BY ctime ASC'
1003 . " LIMIT $start,$amount";
1005 $template['content'] = 'commentlist';
1006 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
1008 $manager->loadClass("ENCAPSULATE");
1009 $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
1010 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
1016 * Browse own comments
1018 function action_browseowncomments() {
1019 global $member, $manager, $CONF;
1022 if (postVar('start'))
1023 $start = intPostVar('start');
1027 // amount of items to show
1028 if (postVar('amount'))
1029 $amount = intPostVar('amount');
1031 $amount = intval($CONF['DefaultListSize']);
1036 $search = postVar('search');
1039 $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();
1042 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1044 $query .= ' ORDER BY ctime DESC'
1045 . " LIMIT $start,$amount";
1049 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1050 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
1052 $template['content'] = 'commentlist';
1053 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
1055 $manager->loadClass("ENCAPSULATE");
1056 $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
1057 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
1063 * Browse all comments for a weblog
1064 * @param int $blogid
1066 function action_blogcommentlist($blogid = '')
1068 global $member, $manager, $CONF;
1071 $blogid = intRequestVar('blogid');
1073 $blogid = intval($blogid);
1075 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
1078 if (postVar('start'))
1079 $start = intPostVar('start');
1083 // amount of items to show
1084 if (postVar('amount'))
1085 $amount = intPostVar('amount');
1087 $amount = intval($CONF['DefaultListSize']);
1092 $search = postVar('search'); // search through comments
1095 $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);
1098 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1101 $query .= ' ORDER BY ctime DESC'
1102 . " LIMIT $start,$amount";
1105 $blog =& $manager->getBlog($blogid);
1109 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1110 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1112 $template['content'] = 'commentlist';
1113 $template['canAddBan'] = $member->blogAdminRights($blogid);
1115 $manager->loadClass("ENCAPSULATE");
1116 $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1117 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1123 * Provide a page to item a new item to the given blog
1125 function action_createitem() {
1126 global $member, $manager;
1128 $blogid = intRequestVar('blogid');
1131 $member->teamRights($blogid) or $this->disallow();
1133 $memberid = $member->getID();
1135 $blog =& $manager->getBlog($blogid);
1139 // generate the add-item form
1140 $formfactory = new PAGEFACTORY($blogid);
1141 $formfactory->createAddForm('admin');
1147 * @todo document this
1149 function action_itemedit()
1151 global $member, $manager;
1153 $itemid = intRequestVar('itemid');
1155 // only allow if user is allowed to alter item
1156 $member->canAlterItem($itemid) or $this->disallow();
1158 $item =& $manager->getItem($itemid, 1, 1);
1159 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1161 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1163 if ($blog->convertBreaks())
1165 $item['body'] = removeBreaks($item['body']);
1166 $item['more'] = removeBreaks($item['more']);
1169 // form to edit blog items
1171 $formfactory = new PAGEFACTORY($blog->getID());
1172 $formfactory->createEditForm('admin', $item);
1177 * @todo document this
1179 function action_itemupdate() {
1180 global $member, $manager, $CONF;
1182 $itemid = intRequestVar('itemid');
1183 $catid = postVar('catid');
1185 // only allow if user is allowed to alter item
1186 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1188 $actiontype = postVar('actiontype');
1190 // delete actions are handled by itemdelete (which has confirmation)
1191 if ($actiontype == 'delete') {
1192 $this->action_itemdelete();
1196 $body = postVar('body');
1197 $title = postVar('title');
1198 $more = postVar('more');
1199 $closed = intPostVar('closed');
1200 $draftid = intPostVar('draftid');
1202 // default action = add now
1204 $actiontype='addnow';
1206 // create new category if needed
1207 if (strstr($catid,'newcat')) {
1209 list($blogid) = sscanf($catid,"newcat-%d");
1212 $blog =& $manager->getBlog($blogid);
1213 $catid = $blog->createNewCategory();
1215 // show error when sth goes wrong
1217 $this->doError(_ERROR_CATCREATEFAIL);
1221 set some variables based on actiontype
1224 draft items -> addnow, addfuture, adddraft, delete
1225 non-draft items -> edit, changedate, delete
1228 $timestamp: set to a nonzero value for future dates or date changes
1229 $wasdraft: set to 1 when the item used to be a draft item
1230 $publish: set to 1 when the edited item is not a draft
1232 $blogid = getBlogIDFromItemID($itemid);
1233 $blog =& $manager->getBlog($blogid);
1235 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1236 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1237 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1238 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1239 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1244 // edit the item for real
1245 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1247 $this->updateFuturePosted($blogid);
1250 // delete permission is checked inside ITEM::delete()
1251 ITEM::delete($draftid);
1254 // show category edit window when we created a new category
1255 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1256 if ($catid != intPostVar('catid')) {
1257 $this->action_categoryedit(
1260 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1263 // TODO: set start item correctly for itemlist
1264 $this->action_itemlist(getBlogIDFromItemID($itemid));
1269 * @todo document this
1271 function action_itemdelete() {
1272 global $member, $manager;
1274 $itemid = intRequestVar('itemid');
1276 // only allow if user is allowed to alter item
1277 $member->canAlterItem($itemid) or $this->disallow();
1279 if (!$manager->existsItem($itemid,1,1))
1280 $this->error(_ERROR_NOSUCHITEM);
1282 $item =& $manager->getItem($itemid,1,1);
1283 $title = i18n::hsc(strip_tags($item['title']));
1284 $body = strip_tags($item['body']);
1285 $body = i18n::hsc(shorten($body,300,'...'));
1289 <h2><?php echo _DELETE_CONFIRM?></h2>
1291 <p><?php echo _CONFIRMTXT_ITEM?></p>
1294 <b>"<?php echo $title ?>"</b>
1299 <form method="post" action="index.php"><div>
1300 <input type="hidden" name="action" value="itemdeleteconfirm" />
1301 <?php $manager->addTicketHidden() ?>
1302 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1303 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
1310 * @todo document this
1312 function action_itemdeleteconfirm() {
1315 $itemid = intRequestVar('itemid');
1317 // only allow if user is allowed to alter item
1318 $member->canAlterItem($itemid) or $this->disallow();
1321 $blogid = getBlogIdFromItemId($itemid);
1323 // delete item (note: some checks will be performed twice)
1324 $this->deleteOneItem($itemid);
1326 $this->action_itemlist($blogid);
1330 * Deletes one item and returns error if something goes wrong
1331 * @param int $itemid
1333 function deleteOneItem($itemid) {
1334 global $member, $manager;
1336 // only allow if user is allowed to alter item (also checks if itemid exists)
1337 if (!$member->canAlterItem($itemid))
1338 return _ERROR_DISALLOWED;
1340 // need to get blogid before the item is deleted
1341 $blogid = getBlogIDFromItemId($itemid);
1343 $manager->loadClass('ITEM');
1344 ITEM::delete($itemid);
1346 // update blog's futureposted
1347 $this->updateFuturePosted($blogid);
1351 * Update a blog's future posted flag
1352 * @param int $blogid
1354 function updateFuturePosted($blogid) {
1357 $blog =& $manager->getBlog($blogid);
1358 $currenttime = $blog->getCorrectTime(time());
1359 $result = sql_query("SELECT * FROM ".sql_table('item').
1360 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
1361 if (sql_num_rows($result) > 0) {
1362 $blog->setFuturePost();
1365 $blog->clearFuturePost();
1370 * @todo document this
1372 function action_itemmove() {
1373 global $member, $manager;
1375 $itemid = intRequestVar('itemid');
1377 // only allow if user is allowed to alter item
1378 $member->canAlterItem($itemid) or $this->disallow();
1380 $item =& $manager->getItem($itemid,1,1);
1384 <h2><?php echo _MOVE_TITLE?></h2>
1385 <form method="post" action="index.php"><div>
1386 <input type="hidden" name="action" value="itemmoveto" />
1387 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1391 $manager->addTicketHidden();
1392 $this->selectBlogCategory('catid',$item['catid'],10,1);
1395 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1402 * @todo document this
1404 function action_itemmoveto() {
1405 global $member, $manager;
1407 $itemid = intRequestVar('itemid');
1408 $catid = requestVar('catid');
1410 // create new category if needed
1411 if (strstr($catid,'newcat')) {
1413 list($blogid) = sscanf($catid,'newcat-%d');
1416 $blog =& $manager->getBlog($blogid);
1417 $catid = $blog->createNewCategory();
1419 // show error when sth goes wrong
1421 $this->doError(_ERROR_CATCREATEFAIL);
1424 // only allow if user is allowed to alter item
1425 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1427 $old_blogid = getBlogIDFromItemId($itemid);
1429 ITEM::move($itemid, $catid);
1431 // set the futurePosted flag on the blog
1432 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1434 // reset the futurePosted in case the item is moved from one blog to another
1435 $this->updateFuturePosted($old_blogid);
1437 if ($catid != intRequestVar('catid'))
1438 $this->action_categoryedit($catid, $blog->getID());
1440 $this->action_itemlist(getBlogIDFromCatID($catid));
1444 * Moves one item to a given category (category existance should be checked by caller)
1445 * errors are returned
1446 * @param int $itemid
1447 * @param int $destCatid category ID to which the item will be moved
1449 function moveOneItem($itemid, $destCatid) {
1452 // only allow if user is allowed to move item
1453 if (!$member->canUpdateItem($itemid, $destCatid))
1454 return _ERROR_DISALLOWED;
1456 ITEM::move($itemid, $destCatid);
1460 * Adds a item to the chosen blog
1462 function action_additem() {
1463 global $manager, $CONF;
1465 $manager->loadClass('ITEM');
1467 $result = ITEM::createFromRequest();
1469 if ($result['status'] == 'error')
1470 $this->error($result['message']);
1472 $blogid = getBlogIDFromItemID($result['itemid']);
1473 $blog =& $manager->getBlog($blogid);
1474 $btimestamp = $blog->getCorrectTime();
1475 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1477 if ($result['status'] == 'newcategory') {
1478 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1479 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1481 $methodName = 'action_itemList';
1482 call_user_func(array(&$this, $methodName), $blogid);
1487 * Allows to edit previously made comments
1489 function action_commentedit() {
1491 global $member, $manager;
1493 $commentid = intRequestVar('commentid');
1495 $member->canAlterComment($commentid) or $this->disallow();
1497 $comment = COMMENT::getComment($commentid);
1499 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1501 // change <br /> to \n
1502 $comment['body'] = str_replace('<br />', '', $comment['body']);
1504 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1505 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1507 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1512 <h2><?php echo _EDITC_TITLE?></h2>
1514 <form action="index.php" method="post"><div>
1516 <input type="hidden" name="action" value="commentupdate" />
1517 <?php $manager->addTicketHidden(); ?>
1518 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1520 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1522 <td><?php echo _EDITC_WHO?></td>
1524 <?php if ($comment['member'])
1525 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1527 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1531 <td><?php echo _EDITC_WHEN?></td>
1532 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1534 <td><?php echo _EDITC_HOST?></td>
1535 <td><?php echo $comment['host']; ?></td>
1538 <td><?php echo _EDITC_URL; ?></td>
1539 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1542 <td><?php echo _EDITC_EMAIL; ?></td>
1543 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1546 <td><?php echo _EDITC_TEXT?></td>
1548 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1549 echo $comment['body'];
1553 <td><?php echo _EDITC_EDIT?></td>
1554 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1563 * @todo document this
1565 function action_commentupdate() {
1566 global $member, $manager;
1568 $commentid = intRequestVar('commentid');
1570 $member->canAlterComment($commentid) or $this->disallow();
1572 $url = postVar('url');
1573 $email = postVar('email');
1574 $body = postVar('body');
1576 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1577 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1578 # important note that '\' must be matched with '\\\\' in preg* expressions
1580 // intercept words that are too long
1581 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1583 $this->error(_ERROR_COMMENT_LONGWORD);
1587 if (i18n::strlen($body) < 3)
1589 $this->error(_ERROR_COMMENT_NOCOMMENT);
1592 if (i18n::strlen($body) > 5000)
1594 $this->error(_ERROR_COMMENT_TOOLONG);
1598 $body = COMMENT::prepareBody($body);
1601 $manager->notify('PreUpdateComment',array('body' => &$body));
1603 $query = 'UPDATE ' . sql_table('comment')
1604 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1605 . " WHERE cnumber = " . $commentid;
1609 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1610 $o = sql_fetch_object($res);
1611 $itemid = $o->citem;
1613 if ($member->canAlterItem($itemid))
1614 $this->action_itemcommentlist($itemid);
1616 $this->action_browseowncomments();
1621 * @todo document this
1623 function action_commentdelete() {
1624 global $member, $manager;
1626 $commentid = intRequestVar('commentid');
1628 $member->canAlterComment($commentid) or $this->disallow();
1630 $comment = COMMENT::getComment($commentid);
1632 $body = strip_tags($comment['body']);
1633 $body = i18n::hsc(shorten($body, 300, '...'));
1635 if ($comment['member'])
1636 $author = $comment['member'];
1638 $author = $comment['user'];
1643 <h2><?php echo _DELETE_CONFIRM?></h2>
1645 <p><?php echo _CONFIRMTXT_COMMENT?></p>
1648 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
1650 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
1653 <form method="post" action="index.php"><div>
1654 <input type="hidden" name="action" value="commentdeleteconfirm" />
1655 <?php $manager->addTicketHidden() ?>
1656 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1657 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
1664 * @todo document this
1666 function action_commentdeleteconfirm() {
1669 $commentid = intRequestVar('commentid');
1671 // get item id first
1672 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1673 $o = sql_fetch_object($res);
1674 $itemid = $o->citem;
1676 $error = $this->deleteOneComment($commentid);
1678 $this->doError($error);
1680 if ($member->canAlterItem($itemid))
1681 $this->action_itemcommentlist($itemid);
1683 $this->action_browseowncomments();
1687 * @todo document this
1689 function deleteOneComment($commentid) {
1690 global $member, $manager;
1692 $commentid = intval($commentid);
1694 if (!$member->canAlterComment($commentid))
1695 return _ERROR_DISALLOWED;
1697 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1699 // delete the comments associated with the item
1700 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1703 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1709 * Usermanagement main
1711 function action_usermanagement() {
1712 global $member, $manager;
1715 $member->isAdmin() or $this->disallow();
1719 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1721 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1723 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1725 // show list of members with actions
1727 . ' FROM '.sql_table('member');
1728 $template['content'] = 'memberlist';
1729 $template['tabindex'] = 10;
1731 $manager->loadClass("ENCAPSULATE");
1732 $batch = new BATCH('member');
1733 $batch->showlist($query,'table',$template);
1735 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1737 <form method="post" action="index.php" name="memberedit"><div>
1739 <input type="hidden" name="action" value="memberadd" />
1740 <?php $manager->addTicketHidden() ?>
1744 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1746 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1747 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1749 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
1751 <td><?php echo _MEMBERS_REALNAME?></td>
1752 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1754 <td><?php echo _MEMBERS_PWD?></td>
1755 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1757 <td><?php echo _MEMBERS_REPPWD?></td>
1758 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1760 <td><?php echo _MEMBERS_EMAIL?></td>
1761 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1763 <td><?php echo _MEMBERS_URL?></td>
1764 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1766 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1767 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1769 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1770 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1772 <td><?php echo _MEMBERS_NOTES?></td>
1773 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1775 <td><?php echo _MEMBERS_NEW?></td>
1776 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1785 * Edit member settings
1787 function action_memberedit() {
1788 $this->action_editmembersettings(intRequestVar('memberid'));
1792 * @todo document this
1794 function action_editmembersettings($memberid = '') {
1795 global $member, $manager, $CONF;
1797 if ($memberid == '')
1799 $memberid = $member->getID();
1803 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1805 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1806 $this->pagehead($extrahead);
1808 // show message to go back to member overview (only for admins)
1809 if ($member->isAdmin())
1811 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1815 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1817 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1819 $mem = MEMBER::createFromID($memberid);
1821 <form method="post" action="index.php" name="memberedit"><div>
1823 <input type="hidden" name="action" value="changemembersettings" />
1824 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1825 <?php $manager->addTicketHidden() ?>
1828 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1830 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1831 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1834 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1835 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo i18n::hsc($mem->getDisplayName()); ?>" />
1837 echo i18n::hsc($member->getDisplayName());
1842 <td><?php echo _MEMBERS_REALNAME?></td>
1843 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo i18n::hsc($mem->getRealName()); ?>" /></td>
1845 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1846 <td><?php echo _MEMBERS_PWD?></td>
1847 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1849 <td><?php echo _MEMBERS_REPPWD?></td>
1850 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1853 <td><?php echo _MEMBERS_EMAIL?>
1854 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1856 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo i18n::hsc($mem->getEmail()); ?>" /></td>
1858 <td><?php echo _MEMBERS_URL?></td>
1859 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo i18n::hsc($mem->getURL()); ?>" /></td>
1860 <?php // only allow to change this by super-admins
1861 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1862 if ($member->isAdmin()) {
1865 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1866 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1868 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1869 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1872 <td><?php echo _MEMBERS_NOTES?></td>
1873 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo i18n::hsc($mem->getNotes()); ?>" /></td>
1875 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
1879 <select name="deflang" tabindex="85">
1881 $locales = i18n::get_available_locale_list();
1882 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
1884 echo "<option value=\"\" selected=\"selected\">" . i18n::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1888 echo "<option value=\"\">" . i18n::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1891 foreach( $locales as $locale )
1893 if( $locale == $mem->getLocale() )
1895 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
1899 echo "<option value=\"{$locale}\">{$locale}</option>\n";
1908 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
1909 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
1913 $this->_insertPluginOptions('member',$memberid);
1916 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1918 <td><?php echo _MEMBERS_EDIT?></td>
1919 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1925 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1928 'MemberSettingsFormExtras',
1937 * @todo document this
1939 function action_changemembersettings() {
1940 global $member, $CONF, $manager;
1942 $memberid = intRequestVar('memberid');
1945 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1947 $name = trim(strip_tags(postVar('name')));
1948 $realname = trim(strip_tags(postVar('realname')));
1949 $password = postVar('password');
1950 $repeatpassword = postVar('repeatpassword');
1951 $email = strip_tags(postVar('email'));
1952 $url = strip_tags(postVar('url'));
1954 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1955 # original eregi: !eregi("^https?://", $url)
1957 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
1958 if (!preg_match('#^https?://#', $url) )
1960 $url = 'http://' . $url;
1963 $admin = postVar('admin');
1964 $canlogin = postVar('canlogin');
1965 $notes = strip_tags(postVar('notes'));
1966 $locale = postVar('deflang');
1968 $mem = MEMBER::createFromID($memberid);
1970 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1972 if (!isValidDisplayName($name))
1973 $this->error(_ERROR_BADNAME);
1975 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1976 $this->error(_ERROR_NICKNAMEINUSE);
1978 if ($password != $repeatpassword)
1979 $this->error(_ERROR_PASSWORDMISMATCH);
1981 if ($password && (i18n::strlen($password) < 6))
1982 $this->error(_ERROR_PASSWORDTOOSHORT);
1987 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
1989 $this->error($pwderror);
1994 if ( !isValidMailAddress($email) )
1996 $this->error(_ERROR_BADMAILADDRESS);
2000 $this->error(_ERROR_REALNAMEMISSING);
2002 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2003 $this->error(_ERROR_NOSUCHLANGUAGE);
2005 // check if there will remain at least one site member with both the logon and admin rights
2006 // (check occurs when taking away one of these rights from such a member)
2007 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2008 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2011 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2012 if (sql_num_rows($r) < 2)
2013 $this->error(_ERROR_ATLEASTONEADMIN);
2016 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2017 $mem->setDisplayName($name);
2019 $mem->setPassword($password);
2022 $oldEmail = $mem->getEmail();
2024 $mem->setRealName($realname);
2025 $mem->setEmail($email);
2027 $mem->setNotes($notes);
2028 $mem->setLocale($locale);
2031 // only allow super-admins to make changes to the admin status
2032 if ($member->isAdmin()) {
2033 $mem->setAdmin($admin);
2034 $mem->setCanLogin($canlogin);
2037 $autosave = postVar ('autosave');
2038 $mem->setAutosave($autosave);
2042 // store plugin options
2043 $aOptions = requestArray('plugoption');
2044 NucleusPlugin::_applyPluginOptions($aOptions);
2045 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2047 // if email changed, generate new password
2048 if ($oldEmail != $mem->getEmail())
2050 $mem->sendActivationLink('addresschange', $oldEmail);
2052 $mem->newCookieKey();
2054 // only log out if the member being edited is the current member.
2055 if ($member->getID() == $memberid)
2057 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2062 if ( ( $mem->getID() == $member->getID() )
2063 && ( $mem->getDisplayName() != $member->getDisplayName() )
2065 $mem->newCookieKey();
2067 $this->action_login(_MSG_LOGINAGAIN, 0);
2069 $this->action_overview(_MSG_SETTINGSCHANGED);
2074 * @todo document this
2076 function action_memberadd() {
2077 global $member, $manager;
2080 $member->isAdmin() or $this->disallow();
2082 if (postVar('password') != postVar('repeatpassword'))
2083 $this->error(_ERROR_PASSWORDMISMATCH);
2084 if (i18n::strlen(postVar('password')) < 6)
2085 $this->error(_ERROR_PASSWORDTOOSHORT);
2087 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2091 // fire PostRegister event
2092 $newmem = new MEMBER();
2093 $newmem->readFromName(postVar('name'));
2094 $manager->notify('PostRegister',array('member' => &$newmem));
2096 $this->action_usermanagement();
2100 * Account activation
2104 function action_activate() {
2106 $key = getVar('key');
2107 $this->_showActivationPage($key);
2111 * @todo document this
2113 function _showActivationPage($key, $message = '')
2117 // clean up old activation keys
2118 MEMBER::cleanupActivationTable();
2120 // get activation info
2121 $info = MEMBER::getActivationInfo($key);
2124 $this->error(_ERROR_ACTIVATE);
2126 $mem = MEMBER::createFromId($info->vmember);
2129 $this->error(_ERROR_ACTIVATE);
2133 $bNeedsPasswordChange = true;
2135 switch ($info->vtype)
2138 $title = _ACTIVATE_FORGOT_TITLE;
2139 $text = _ACTIVATE_FORGOT_TEXT;
2142 $title = _ACTIVATE_REGISTER_TITLE;
2143 $text = _ACTIVATE_REGISTER_TEXT;
2145 case 'addresschange':
2146 $title = _ACTIVATE_CHANGE_TITLE;
2147 $text = _ACTIVATE_CHANGE_TEXT;
2148 $bNeedsPasswordChange = false;
2149 MEMBER::activate($key);
2154 'memberName' => i18n::hsc($mem->getDisplayName())
2156 $title = TEMPLATE::fill($title, $aVars);
2157 $text = TEMPLATE::fill($text, $aVars);
2161 echo '<h2>' , $title, '</h2>';
2162 echo '<p>' , $text, '</p>';
2166 echo '<p class="error">',$message,'</p>';
2169 if ($bNeedsPasswordChange)
2172 <div><form action="index.php" method="post">
2174 <input type="hidden" name="action" value="activatesetpwd" />
2175 <?php $manager->addTicketHidden() ?>
2176 <input type="hidden" name="key" value="<?php echo i18n::hsc($key) ?>" />
2179 <td><?php echo _MEMBERS_PWD?></td>
2180 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2182 <td><?php echo _MEMBERS_REPPWD?></td>
2183 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2187 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2191 <td><?php echo _MEMBERS_SETPWD ?></td>
2192 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2207 * Account activation - set password part
2211 function action_activatesetpwd() {
2213 $key = postVar('key');
2215 // clean up old activation keys
2216 MEMBER::cleanupActivationTable();
2218 // get activation info
2219 $info = MEMBER::getActivationInfo($key);
2221 if (!$info || ($info->type == 'addresschange'))
2222 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2224 $mem = MEMBER::createFromId($info->vmember);
2227 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2229 $password = postVar('password');
2230 $repeatpassword = postVar('repeatpassword');
2232 if ($password != $repeatpassword)
2233 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2235 if ($password && (i18n::strlen($password) < 6))
2236 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2242 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2244 return $this->_showActivationPage($key,$pwderror);
2250 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2252 return $this->_showActivationPage($key, $error);
2256 $mem->setPassword($password);
2259 // do the activation
2260 MEMBER::activate($key);
2263 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2264 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2271 function action_manageteam() {
2272 global $member, $manager;
2274 $blogid = intRequestVar('blogid');
2277 $member->blogAdminRights($blogid) or $this->disallow();
2281 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2283 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2285 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2289 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2290 . ' FROM '.sql_table('member').', '.sql_table('team')
2291 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2293 $template['content'] = 'teamlist';
2294 $template['tabindex'] = 10;
2296 $manager->loadClass("ENCAPSULATE");
2297 $batch = new BATCH('team');
2298 $batch->showlist($query, 'table', $template);
2301 <h3><?php echo _TEAM_ADDNEW?></h3>
2303 <form method='post' action='index.php'><div>
2305 <input type='hidden' name='action' value='teamaddmember' />
2306 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2307 <?php $manager->addTicketHidden() ?>
2310 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2311 <td><?php // TODO: try to make it so only non-team-members are listed
2312 $query = 'SELECT mname as text, mnumber as value'
2313 . ' FROM '.sql_table('member');
2315 $template['name'] = 'memberid';
2316 $template['tabindex'] = 10000;
2317 showlist($query,'select',$template);
2320 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2321 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2323 <td><?php echo _TEAM_ADD?></td>
2324 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2333 * Add member to team
2335 function action_teamaddmember() {
2336 global $member, $manager;
2338 $memberid = intPostVar('memberid');
2339 $blogid = intPostVar('blogid');
2340 $admin = intPostVar('admin');
2343 $member->blogAdminRights($blogid) or $this->disallow();
2345 $blog =& $manager->getBlog($blogid);
2346 if (!$blog->addTeamMember($memberid, $admin))
2347 $this->error(_ERROR_ALREADYONTEAM);
2349 $this->action_manageteam();
2354 * @todo document this
2356 function action_teamdelete() {
2357 global $member, $manager;
2359 $memberid = intRequestVar('memberid');
2360 $blogid = intRequestVar('blogid');
2363 $member->blogAdminRights($blogid) or $this->disallow();
2365 $teammem = MEMBER::createFromID($memberid);
2366 $blog =& $manager->getBlog($blogid);
2370 <h2><?php echo _DELETE_CONFIRM?></h2>
2372 <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo i18n::hsc($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo i18n::hsc(strip_tags($blog->getName())) ?></b>
2376 <form method="post" action="index.php"><div>
2377 <input type="hidden" name="action" value="teamdeleteconfirm" />
2378 <?php $manager->addTicketHidden() ?>
2379 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2380 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2381 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2388 * @todo document this
2390 function action_teamdeleteconfirm() {
2393 $memberid = intRequestVar('memberid');
2394 $blogid = intRequestVar('blogid');
2396 $error = $this->deleteOneTeamMember($blogid, $memberid);
2398 $this->error($error);
2401 $this->action_manageteam();
2405 * @todo document this
2407 function deleteOneTeamMember($blogid, $memberid) {
2408 global $member, $manager;
2410 $blogid = intval($blogid);
2411 $memberid = intval($memberid);
2414 if (!$member->blogAdminRights($blogid))
2415 return _ERROR_DISALLOWED;
2417 // check if: - there remains at least one blog admin
2418 // - (there remains at least one team member)
2419 $tmem = MEMBER::createFromID($memberid);
2421 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2423 if ($tmem->isBlogAdmin($blogid)) {
2424 // check if there are more blog members left and at least one admin
2425 // (check for at least two admins before deletion)
2426 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2427 $r = sql_query($query);
2428 if (sql_num_rows($r) < 2)
2429 return _ERROR_ATLEASTONEBLOGADMIN;
2432 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2435 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2441 * @todo document this
2443 function action_teamchangeadmin() {
2446 $blogid = intRequestVar('blogid');
2447 $memberid = intRequestVar('memberid');
2450 $member->blogAdminRights($blogid) or $this->disallow();
2452 $mem = MEMBER::createFromID($memberid);
2454 // don't allow when there is only one admin at this moment
2455 if ($mem->isBlogAdmin($blogid)) {
2456 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2457 if (sql_num_rows($r) == 1)
2458 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2461 if ($mem->isBlogAdmin($blogid))
2466 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2469 // only show manageteam if member did not change its own admin privileges
2470 if ($member->isBlogAdmin($blogid))
2471 $this->action_manageteam();
2473 $this->action_overview(_MSG_ADMINCHANGED);
2477 * @todo document this
2479 function action_blogsettings() {
2480 global $member, $manager;
2482 $blogid = intRequestVar('blogid');
2485 $member->blogAdminRights($blogid) or $this->disallow();
2487 $blog =& $manager->getBlog($blogid);
2489 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2490 $this->pagehead($extrahead);
2492 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2494 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2496 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2498 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
2500 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2501 $aMemberNames = array();
2502 while ($o = sql_fetch_object($res))
2503 array_push($aMemberNames, i18n::hsc($o->mname) . ' (' . i18n::hsc($o->mrealname). ')');
2504 echo implode(',', $aMemberNames);
2511 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2514 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2516 <form method="post" action="index.php"><div>
2518 <input type="hidden" name="action" value="blogsettingsupdate" />
2519 <?php $manager->addTicketHidden() ?>
2520 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2522 <td><?php echo _EBLOG_NAME?></td>
2523 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo i18n::hsc($blog->getName()) ?>" /></td>
2525 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2526 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2528 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo i18n::hsc($blog->getShortName()) ?>" /></td>
2530 <td><?php echo _EBLOG_DESC?></td>
2531 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo i18n::hsc($blog->getDescription()) ?>" /></td>
2533 <td><?php echo _EBLOG_URL?></td>
2534 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo i18n::hsc($blog->getURL()) ?>" /></td>
2536 <td><?php echo _EBLOG_DEFSKIN?>
2537 <?php help('blogdefaultskin'); ?>
2541 $query = 'SELECT sdname as text, sdnumber as value'
2542 . ' FROM '.sql_table('skin_desc');
2543 $template['name'] = 'defskin';
2544 $template['selected'] = $blog->getDefaultSkin();
2545 $template['tabindex'] = 50;
2546 showlist($query,'select',$template);
2551 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2553 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2555 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2557 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2559 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2561 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2563 <td><?php echo _EBLOG_ANONYMOUS?>
2565 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2567 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2569 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2571 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2572 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo i18n::hsc($blog->getNotifyAddress()); ?>" /></td>
2574 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2576 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2577 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2578 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2580 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2581 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2582 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2584 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2585 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2586 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2589 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2590 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo i18n::hsc($blog->getMaxComments()); ?>" /></td>
2592 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2593 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo i18n::hsc($blog->getUpdateFile()) ?>" /></td>
2595 <td><?php echo _EBLOG_DEFCAT?></td>
2598 $query = 'SELECT cname as text, catid as value'
2599 . ' FROM '.sql_table('category')
2600 . ' WHERE cblog=' . $blog->getID();
2601 $template['name'] = 'defcat';
2602 $template['selected'] = $blog->getDefaultCategory();
2603 $template['tabindex'] = 110;
2604 showlist($query,'select',$template);
2608 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2609 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
2610 <br /><?php echo _EBLOG_BTIME?> <b><?php echo i18n::strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2612 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo i18n::hsc($blog->getTimeOffset()); ?>" /></td>
2614 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2615 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2619 $this->_insertPluginOptions('blog',$blogid);
2622 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2624 <td><?php echo _EBLOG_CHANGE?></td>
2625 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2630 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2634 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2635 $template['content'] = 'categorylist';
2636 $template['tabindex'] = 200;
2638 $manager->loadClass("ENCAPSULATE");
2639 $batch = new BATCH('category');
2640 $batch->showlist($query,'table',$template);
2645 <form action="index.php" method="post"><div>
2646 <input name="action" value="categorynew" type="hidden" />
2647 <?php $manager->addTicketHidden() ?>
2648 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2651 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2653 <td><?php echo _EBLOG_CAT_NAME?></td>
2654 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2656 <td><?php echo _EBLOG_CAT_DESC?></td>
2657 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2659 <td><?php echo _EBLOG_CAT_CREATE?></td>
2660 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2667 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2670 'BlogSettingsFormExtras',
2680 * @todo document this
2682 function action_categorynew() {
2683 global $member, $manager;
2685 $blogid = intRequestVar('blogid');
2687 $member->blogAdminRights($blogid) or $this->disallow();
2689 $cname = postVar('cname');
2690 $cdesc = postVar('cdesc');
2692 if (!isValidCategoryName($cname))
2693 $this->error(_ERROR_BADCATEGORYNAME);
2695 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2696 $res = sql_query($query);
2697 if (sql_num_rows($res) > 0)
2698 $this->error(_ERROR_DUPCATEGORYNAME);
2700 $blog =& $manager->getBlog($blogid);
2701 $newCatID = $blog->createNewCategory($cname, $cdesc);
2703 $this->action_blogsettings();
2707 * @todo document this
2709 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2710 global $member, $manager;
2713 $blogid = intGetVar('blogid');
2715 $blogid = intval($blogid);
2717 $catid = intGetVar('catid');
2719 $catid = intval($catid);
2721 $member->blogAdminRights($blogid) or $this->disallow();
2723 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2724 $obj = sql_fetch_object($res);
2726 $cname = $obj->cname;
2727 $cdesc = $obj->cdesc;
2729 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2730 $this->pagehead($extrahead);
2732 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2735 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo i18n::hsc($cname)?>'</h2>
2736 <form method='post' action='index.php'><div>
2737 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2738 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2739 <input name="desturl" type="hidden" value="<?php echo i18n::hsc($desturl) ?>" />
2740 <input name="action" type="hidden" value="categoryupdate" />
2741 <?php $manager->addTicketHidden(); ?>
2744 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2746 <td><?php echo _EBLOG_CAT_NAME?></td>
2747 <td><input type="text" name="cname" value="<?php echo i18n::hsc($cname)?>" size="40" maxlength="40" /></td>
2749 <td><?php echo _EBLOG_CAT_DESC?></td>
2750 <td><input type="text" name="cdesc" value="<?php echo i18n::hsc($cdesc)?>" size="40" maxlength="200" /></td>
2753 // insert plugin options
2754 $this->_insertPluginOptions('category',$catid);
2757 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2759 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2760 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2769 * @todo document this
2771 function action_categoryupdate() {
2772 global $member, $manager;
2774 $blogid = intPostVar('blogid');
2775 $catid = intPostVar('catid');
2776 $cname = postVar('cname');
2777 $cdesc = postVar('cdesc');
2778 $desturl = postVar('desturl');
2780 $member->blogAdminRights($blogid) or $this->disallow();
2782 if (!isValidCategoryName($cname))
2783 $this->error(_ERROR_BADCATEGORYNAME);
2785 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2786 $res = sql_query($query);
2787 if (sql_num_rows($res) > 0)
2788 $this->error(_ERROR_DUPCATEGORYNAME);
2790 $query = 'UPDATE '.sql_table('category').' SET'
2791 . " cname='" . sql_real_escape_string($cname) . "',"
2792 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
2793 . " WHERE catid=" . $catid;
2797 // store plugin options
2798 $aOptions = requestArray('plugoption');
2799 NucleusPlugin::_applyPluginOptions($aOptions);
2800 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2807 $this->action_blogsettings();
2812 * @todo document this
2814 function action_categorydelete() {
2815 global $member, $manager;
2817 $blogid = intRequestVar('blogid');
2818 $catid = intRequestVar('catid');
2820 $member->blogAdminRights($blogid) or $this->disallow();
2822 $blog =& $manager->getBlog($blogid);
2824 // check if the category is valid
2825 if (!$blog->isValidCategory($catid))
2826 $this->error(_ERROR_NOSUCHCATEGORY);
2828 // don't allow deletion of default category
2829 if ($blog->getDefaultCategory() == $catid)
2830 $this->error(_ERROR_DELETEDEFCATEGORY);
2832 // check if catid is the only category left for blogid
2833 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2834 $res = sql_query($query);
2835 if (sql_num_rows($res) == 1)
2836 $this->error(_ERROR_DELETELASTCATEGORY);
2841 <h2><?php echo _DELETE_CONFIRM?></h2>
2844 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo i18n::hsc($blog->getCategoryName($catid))?></b>
2847 <form method="post" action="index.php"><div>
2848 <input type="hidden" name="action" value="categorydeleteconfirm" />
2849 <?php $manager->addTicketHidden() ?>
2850 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2851 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2852 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2859 * @todo document this
2861 function action_categorydeleteconfirm() {
2862 global $member, $manager;
2864 $blogid = intRequestVar('blogid');
2865 $catid = intRequestVar('catid');
2867 $member->blogAdminRights($blogid) or $this->disallow();
2869 $error = $this->deleteOneCategory($catid);
2871 $this->error($error);
2873 $this->action_blogsettings();
2877 * @todo document this
2879 function deleteOneCategory($catid) {
2880 global $manager, $member;
2882 $catid = intval($catid);
2884 $blogid = getBlogIDFromCatID($catid);
2886 if (!$member->blogAdminRights($blogid))
2887 return ERROR_DISALLOWED;
2890 $blog =& $manager->getBlog($blogid);
2892 // check if the category is valid
2893 if (!$blog || !$blog->isValidCategory($catid))
2894 return _ERROR_NOSUCHCATEGORY;
2896 $destcatid = $blog->getDefaultCategory();
2898 // don't allow deletion of default category
2899 if ($blog->getDefaultCategory() == $catid)
2900 return _ERROR_DELETEDEFCATEGORY;
2902 // check if catid is the only category left for blogid
2903 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2904 $res = sql_query($query);
2905 if (sql_num_rows($res) == 1)
2906 return _ERROR_DELETELASTCATEGORY;
2908 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2910 // change category for all items to the default category
2911 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2914 // delete all associated plugin options
2915 NucleusPlugin::_deleteOptionValues('category', $catid);
2918 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2921 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2926 * @todo document this
2928 function moveOneCategory($catid, $destblogid) {
2929 global $manager, $member;
2931 $catid = intval($catid);
2932 $destblogid = intval($destblogid);
2934 $blogid = getBlogIDFromCatID($catid);
2936 // mover should have admin rights on both blogs
2937 if (!$member->blogAdminRights($blogid))
2938 return _ERROR_DISALLOWED;
2939 if (!$member->blogAdminRights($destblogid))
2940 return _ERROR_DISALLOWED;
2942 // cannot move to self
2943 if ($blogid == $destblogid)
2944 return _ERROR_MOVETOSELF;
2947 $blog =& $manager->getBlog($blogid);
2948 $destblog =& $manager->getBlog($destblogid);
2950 // check if the category is valid
2951 if (!$blog || !$blog->isValidCategory($catid))
2952 return _ERROR_NOSUCHCATEGORY;
2954 // don't allow default category to be moved
2955 if ($blog->getDefaultCategory() == $catid)
2956 return _ERROR_MOVEDEFCATEGORY;
2962 'sourceblog' => &$blog,
2963 'destblog' => &$destblog
2967 // update comments table (cblog)
2968 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
2969 $items = sql_query($query);
2970 while ($oItem = sql_fetch_object($items)) {
2971 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
2974 // update items (iblog)
2975 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
2979 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
2986 'sourceblog' => &$blog,
2987 'destblog' => $destblog
2994 * @todo document this
2996 function action_blogsettingsupdate()
2998 global $member, $manager;
3000 $blogid = intRequestVar('blogid');
3002 $member->blogAdminRights($blogid) or $this->disallow();
3004 $blog =& $manager->getBlog($blogid);
3006 $notify = trim(postVar('notify'));
3007 $shortname = trim(postVar('shortname'));
3008 $updatefile = trim(postVar('update'));
3010 $notifyComment = intPostVar('notifyComment');
3011 $notifyVote = intPostVar('notifyVote');
3012 $notifyNewItem = intPostVar('notifyNewItem');
3014 if ($notifyComment == 0)
3018 if ($notifyVote == 0)
3022 if ($notifyNewItem == 0)
3026 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
3030 $not = new NOTIFICATION($notify);
3031 if (!$not->validAddresses())
3033 $this->error(_ERROR_BADNOTIFY);
3037 if (!isValidShortName($shortname))
3039 $this->error(_ERROR_BADSHORTBLOGNAME);
3042 if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
3044 $this->error(_ERROR_DUPSHORTBLOGNAME);
3046 // check if update file is writable
3047 if ($updatefile && !is_writeable($updatefile))
3049 $this->error(_ERROR_UPDATEFILE);
3052 $blog->setName(trim(postVar('name')));
3053 $blog->setShortName($shortname);
3054 $blog->setNotifyAddress($notify);
3055 $blog->setNotifyType($notifyType);
3056 $blog->setMaxComments(postVar('maxcomments'));
3057 $blog->setCommentsEnabled(postVar('comments'));
3058 $blog->setTimeOffset(postVar('timeoffset'));
3059 $blog->setUpdateFile($updatefile);
3060 $blog->setURL(trim(postVar('url')));
3061 $blog->setDefaultSkin(intPostVar('defskin'));
3062 $blog->setDescription(trim(postVar('desc')));
3063 $blog->setPublic(postVar('public'));
3064 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3065 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3066 $blog->setDefaultCategory(intPostVar('defcat'));
3067 $blog->setSearchable(intPostVar('searchable'));
3068 $blog->setEmailRequired(intPostVar('reqemail'));
3069 $blog->writeSettings();
3071 // store plugin options
3072 $aOptions = requestArray('plugoption');
3073 NucleusPlugin::_applyPluginOptions($aOptions);
3074 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3076 $this->action_overview(_MSG_SETTINGSCHANGED);
3080 * @todo document this
3082 function action_deleteblog() {
3083 global $member, $CONF, $manager;
3085 $blogid = intRequestVar('blogid');
3087 $member->blogAdminRights($blogid) or $this->disallow();
3089 // check if blog is default blog
3090 if ($CONF['DefaultBlog'] == $blogid)
3091 $this->error(_ERROR_DELDEFBLOG);
3093 $blog =& $manager->getBlog($blogid);
3097 <h2><?php echo _DELETE_CONFIRM?></h2>
3099 <p><?php echo _WARNINGTXT_BLOGDEL?>
3103 <?php echo _CONFIRMTXT_BLOG?><b><?php echo i18n::hsc($blog->getName())?></b>
3106 <form method="post" action="index.php"><div>
3107 <input type="hidden" name="action" value="deleteblogconfirm" />
3108 <?php $manager->addTicketHidden() ?>
3109 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3110 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3117 * @todo document this
3119 function action_deleteblogconfirm() {
3120 global $member, $CONF, $manager;
3122 $blogid = intRequestVar('blogid');
3124 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3126 $member->blogAdminRights($blogid) or $this->disallow();
3128 // check if blog is default blog
3129 if ($CONF['DefaultBlog'] == $blogid)
3130 $this->error(_ERROR_DELDEFBLOG);
3132 // delete all comments
3133 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3137 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3140 // delete all team members
3141 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3145 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3148 // delete all categories
3149 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3152 // delete all associated plugin options
3153 NucleusPlugin::_deleteOptionValues('blog', $blogid);
3155 // delete the blog itself
3156 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3159 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3161 $this->action_overview(_DELETED_BLOG);
3165 * @todo document this
3167 function action_memberdelete() {
3168 global $member, $manager;
3170 $memberid = intRequestVar('memberid');
3172 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3174 $mem = MEMBER::createFromID($memberid);
3178 <h2><?php echo _DELETE_CONFIRM?></h2>
3180 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo i18n::hsc($mem->getDisplayName()) ?></b>
3184 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3187 <form method="post" action="index.php"><div>
3188 <input type="hidden" name="action" value="memberdeleteconfirm" />
3189 <?php $manager->addTicketHidden() ?>
3190 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3191 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3198 * @todo document this
3200 function action_memberdeleteconfirm() {
3203 $memberid = intRequestVar('memberid');
3205 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3207 $error = $this->deleteOneMember($memberid);
3209 $this->error($error);
3211 if ($member->isAdmin())
3212 $this->action_usermanagement();
3214 $this->action_overview(_DELETED_MEMBER);
3219 * @todo document this
3221 function deleteOneMember($memberid) {
3224 $memberid = intval($memberid);
3225 $mem = MEMBER::createFromID($memberid);
3227 if (!$mem->canBeDeleted())
3228 return _ERROR_DELETEMEMBER;
3230 $manager->notify('PreDeleteMember', array('member' => &$mem));
3232 /* unlink comments from memberid */
3234 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())
3235 .'" WHERE cmember='.$memberid;
3239 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3242 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3245 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3248 // delete all associated plugin options
3249 NucleusPlugin::_deleteOptionValues('member', $memberid);
3251 $manager->notify('PostDeleteMember', array('member' => &$mem));
3257 * @todo document this
3259 function action_createnewlog() {
3260 global $member, $CONF, $manager;
3262 // Only Super-Admins can do this
3263 $member->isAdmin() or $this->disallow();
3267 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3269 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3271 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3273 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3275 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3278 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3279 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3282 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3285 <?php echo _EBLOG_CREATE_TEXT?>
3288 <form method="post" action="index.php"><div>
3290 <input type="hidden" name="action" value="addnewlog" />
3291 <?php $manager->addTicketHidden() ?>
3295 <td><?php echo _EBLOG_NAME?></td>
3296 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3298 <td><?php echo _EBLOG_SHORTNAME?>
3299 <?php help('shortblogname'); ?>
3301 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3303 <td><?php echo _EBLOG_DESC?></td>
3304 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3306 <td><?php echo _EBLOG_DEFSKIN?>
3307 <?php help('blogdefaultskin'); ?>
3311 $query = 'SELECT sdname as text, sdnumber as value'
3312 . ' FROM '.sql_table('skin_desc');
3313 $template['name'] = 'defskin';
3314 $template['tabindex'] = 50;
3315 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3316 showlist($query,'select',$template);
3320 <td><?php echo _EBLOG_OFFSET?>
3321 <?php help('blogtimeoffset'); ?>
3322 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
3324 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3326 <td><?php echo _EBLOG_ADMIN?>
3327 <?php help('teamadmin'); ?>
3329 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3331 <td><?php echo _EBLOG_CREATE?></td>
3332 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3341 * @todo document this
3343 function action_addnewlog() {
3344 global $member, $manager, $CONF;
3346 // Only Super-Admins can do this
3347 $member->isAdmin() or $this->disallow();
3349 $bname = trim(postVar('name'));
3350 $bshortname = trim(postVar('shortname'));
3351 $btimeoffset = postVar('timeoffset');
3352 $bdesc = trim(postVar('desc'));
3353 $bdefskin = postVar('defskin');
3355 if (!isValidShortName($bshortname))
3356 $this->error(_ERROR_BADSHORTBLOGNAME);
3358 if ($manager->existsBlog($bshortname))
3359 $this->error(_ERROR_DUPSHORTBLOGNAME);
3365 'shortname' => &$bshortname,
3366 'timeoffset' => &$btimeoffset,
3367 'description' => &$bdesc,
3368 'defaultskin' => &$bdefskin
3373 // add slashes for sql queries
3374 $bname = sql_real_escape_string($bname);
3375 $bshortname = sql_real_escape_string($bshortname);
3376 $btimeoffset = sql_real_escape_string($btimeoffset);
3377 $bdesc = sql_real_escape_string($bdesc);
3378 $bdefskin = sql_real_escape_string($bdefskin);
3381 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3383 $blogid = sql_insert_id();
3384 $blog =& $manager->getBlog($blogid);
3386 // create new category
3387 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3388 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3389 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3390 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3391 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3392 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3393 $catid = sql_insert_id();
3395 // set as default category
3396 $blog->setDefaultCategory($catid);
3397 $blog->writeSettings();
3399 // create team member
3400 $memberid = $member->getID();
3401 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3404 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3405 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3407 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3408 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3423 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3424 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3431 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3433 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, i18n::hsc($bname)) ?></p>
3436 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, i18n::hsc($bshortname)) ?></a></li>
3437 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3440 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, i18n::hsc($bshortname)) ?></a></h3>
3442 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, i18n::hsc($bshortname)) ?></p>
3445 $CONF['Self'] = '<b><?php echo i18n::hsc($bshortname)?>.php</b>';
3447 include('<i>./config.php</i>');
3449 selectBlog('<b><?php echo i18n::hsc($bshortname)?></b>');
3454 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3456 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3458 <form action="index.php" method="post"><div>
3459 <input type="hidden" name="action" value="addnewlog2" />
3460 <?php $manager->addTicketHidden() ?>
3461 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3463 <td><?php echo _EBLOG_URL?></td>
3464 <td><input name="url" maxlength="100" size="40" value="<?php echo i18n::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3466 <td><?php echo _EBLOG_CREATE?></td>
3467 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3471 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3473 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3475 <form action="index.php" method="post"><div>
3476 <input type="hidden" name="action" value="addnewlog2" />
3477 <?php $manager->addTicketHidden() ?>
3478 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3480 <td><?php echo _EBLOG_URL?></td>
3481 <td><input name="url" maxlength="100" size="40" /></td>
3483 <td><?php echo _EBLOG_CREATE?></td>
3484 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3488 <?php $this->pagefoot();
3493 * @todo document this
3495 function action_addnewlog2() {
3496 global $member, $manager;
3498 $member->blogAdminRights($blogid) or $this->disallow();
3500 $burl = requestVar('url');
3501 $blogid = intRequestVar('blogid');
3503 $blog =& $manager->getBlog($blogid);
3504 $blog->setURL(trim($burl));
3505 $blog->writeSettings();
3507 $this->action_overview(_MSG_NEWBLOG);
3511 * @todo document this
3513 function action_skinieoverview() {
3514 global $member, $DIR_LIBS, $manager;
3516 $member->isAdmin() or $this->disallow();
3518 // load skinie class
3519 include_once($DIR_LIBS . 'skinie.php');
3523 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3526 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3528 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3529 <?php global $DIR_SKINS;
3531 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3533 if (sizeof($candidates) > 0) {
3535 <form method="post" action="index.php"><div>
3536 <input type="hidden" name="action" value="skinieimport" />
3537 <?php $manager->addTicketHidden() ?>
3538 <input type="hidden" name="mode" value="file" />
3539 <select name="skinfile" id="skinie_import_local">
3540 <?php foreach ($candidates as $skinname => $skinfile) {
3541 $html = i18n::hsc($skinfile);
3542 echo '<option value="',$html,'">',$skinname,'</option>';
3546 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3549 echo _SKINIE_NOCANDIDATES;
3554 <p><em><?php echo _OR?></em></p>
3556 <form method="post" action="index.php"><p>
3557 <?php $manager->addTicketHidden() ?>
3558 <input type="hidden" name="action" value="skinieimport" />
3559 <input type="hidden" name="mode" value="url" />
3560 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3561 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3562 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3566 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3567 <form method="post" action="index.php"><div>
3568 <input type="hidden" name="action" value="skinieexport" />
3569 <?php $manager->addTicketHidden() ?>
3571 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3574 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3576 <?php // show list of skins
3577 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3578 while ($skinObj = sql_fetch_object($res)) {
3579 $id = 'skinexp' . $skinObj->sdnumber;
3580 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3581 echo '<label for="',$id,'">',i18n::hsc($skinObj->sdname),'</label></td>';
3582 echo '<td>',i18n::hsc($skinObj->sddesc),'</td>';
3586 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3588 // show list of templates
3589 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3590 while ($templateObj = sql_fetch_object($res)) {
3591 $id = 'templateexp' . $templateObj->tdnumber;
3592 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3593 echo '<label for="',$id,'">',i18n::hsc($templateObj->tdname),'</label></td>';
3594 echo '<td>',i18n::hsc($templateObj->tddesc),'</td>';
3599 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3601 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3603 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3605 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3615 * @todo document this
3617 function action_skinieimport() {
3618 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3620 $member->isAdmin() or $this->disallow();
3622 // load skinie class
3623 include_once($DIR_LIBS . 'skinie.php');
3625 $skinFileRaw= postVar('skinfile');
3626 $mode = postVar('mode');
3628 $importer = new SKINIMPORT();
3630 // get full filename
3631 if ($mode == 'file')
3633 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3635 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3636 if (!file_exists($skinFile))
3637 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3639 $skinFile = $skinFileRaw;
3642 // read only metadata
3643 $error = $importer->readFile($skinFile, 1);
3646 $skinNameClashes = $importer->checkSkinNameClashes();
3647 $templateNameClashes = $importer->checkTemplateNameClashes();
3648 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3650 if ($error) $this->error($error);
3654 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3656 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3659 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo i18n::hsc($importer->getInfo())?></p></li>
3660 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3661 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3663 if ($hasNameClashes)
3666 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3667 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3669 } // if (hasNameClashes)
3673 <form method="post" action="index.php"><div>
3674 <input type="hidden" name="action" value="skiniedoimport" />
3675 <?php $manager->addTicketHidden() ?>
3676 <input type="hidden" name="skinfile" value="<?php echo i18n::hsc(postVar('skinfile'))?>" />
3677 <input type="hidden" name="mode" value="<?php echo i18n::hsc($mode)?>" />
3678 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3680 if ($hasNameClashes)
3684 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3686 } // if (hasNameClashes)
3696 * @todo document this
3698 function action_skiniedoimport() {
3699 global $member, $DIR_LIBS, $DIR_SKINS;
3701 $member->isAdmin() or $this->disallow();
3703 // load skinie class
3704 include_once($DIR_LIBS . 'skinie.php');
3706 $skinFileRaw= postVar('skinfile');
3707 $mode = postVar('mode');
3709 $allowOverwrite = intPostVar('overwrite');
3711 // get full filename
3712 if ($mode == 'file')
3714 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3716 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3717 if (!file_exists($skinFile))
3718 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3721 $skinFile = $skinFileRaw;
3724 $importer = new SKINIMPORT();
3726 $error = $importer->readFile($skinFile);
3729 $this->error($error);
3731 $error = $importer->writeToDatabase($allowOverwrite);
3734 $this->error($error);
3738 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3740 <h2><?php echo _SKINIE_DONE?></h2>
3743 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo i18n::hsc($importer->getInfo())?></p></li>
3744 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3745 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3748 <?php $this->pagefoot();
3753 * @todo document this
3755 function action_skinieexport() {
3756 global $member, $DIR_LIBS;
3758 $member->isAdmin() or $this->disallow();
3760 // load skinie class
3761 include_once($DIR_LIBS . 'skinie.php');
3763 $aSkins = requestIntArray('skin');
3764 $aTemplates = requestIntArray('template');
3766 if (!is_array($aTemplates)) $aTemplates = array();
3767 if (!is_array($aSkins)) $aSkins = array();
3769 $skinList = array_keys($aSkins);
3770 $templateList = array_keys($aTemplates);
3772 $info = postVar('info');
3774 $exporter = new SKINEXPORT();
3775 foreach ($skinList as $skinId) {
3776 $exporter->addSkin($skinId);
3778 foreach ($templateList as $templateId) {
3779 $exporter->addTemplate($templateId);
3781 $exporter->setInfo($info);
3783 $exporter->export();
3787 * @todo document this
3789 function action_templateoverview() {
3790 global $member, $manager;
3792 $member->isAdmin() or $this->disallow();
3796 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3798 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3799 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3801 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3802 $template['content'] = 'templatelist';
3803 $template['tabindex'] = 10;
3804 showlist($query,'table',$template);
3806 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3809 <form method="post" action="index.php"><div>
3811 <input name="action" value="templatenew" type="hidden" />
3812 <?php $manager->addTicketHidden() ?>
3814 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3815 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3817 <td><?php echo _TEMPLATE_DESC?></td>
3818 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3820 <td><?php echo _TEMPLATE_CREATE?></td>
3821 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3831 * @todo document this
3833 function action_templateedit($msg = '') {
3834 global $member, $manager;
3836 $templateid = intRequestVar('templateid');
3838 $member->isAdmin() or $this->disallow();
3840 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3841 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
3843 $this->pagehead($extrahead);
3845 $templatename = TEMPLATE::getNameFromId($templateid);
3846 $templatedescription = TEMPLATE::getDesc($templateid);
3847 $template =& $manager->getTemplate($templatename);
3851 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3854 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo i18n::hsc($templatename); ?>'</h2>
3856 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3859 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3861 <form method="post" action="index.php">
3864 <input type="hidden" name="action" value="templateupdate" />
3865 <?php $manager->addTicketHidden() ?>
3866 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3869 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3871 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3872 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo i18n::hsc($templatename) ?>" /></td>
3874 <td><?php echo _TEMPLATE_DESC?></td>
3875 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo i18n::hsc($templatedescription) ?>" /></td>
3877 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3879 <td><?php echo _TEMPLATE_UPDATE?></td>
3881 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3882 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3885 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3886 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3887 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3888 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3889 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3890 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3891 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3894 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3895 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3896 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3897 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3898 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3899 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3900 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3901 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3904 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3906 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3909 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3910 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3913 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3914 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3915 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3916 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3919 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3920 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3921 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3922 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3925 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3926 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
3927 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
3928 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
3931 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3932 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
3933 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
3934 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
3935 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
3936 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
3939 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3940 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
3941 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
3942 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
3945 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3946 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
3947 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
3950 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
3953 $pluginfields = array();
3954 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
3956 foreach ($pluginfields as $pfkey=>$pfvalue) {
3958 echo '<th colspan="2">' . i18n::hen($pfkey) . "</th>\n";
3959 foreach ($pfvalue as $pffield=>$pfdesc) {
3960 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
3965 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3967 <td><?php echo _TEMPLATE_UPDATE?></td>
3969 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3970 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3981 * @todo document this
3983 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3985 if (!isset($template[$name])) $template[$name] = '';
3988 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3989 <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 i18n::hsc($template[$name]); ?></textarea></td>
3994 * @todo document this
3996 function action_templateupdate() {
3997 global $member,$manager;
3999 $templateid = intRequestVar('templateid');
4001 $member->isAdmin() or $this->disallow();
4003 $name = postVar('tname');
4004 $desc = postVar('tdesc');
4006 if (!isValidTemplateName($name))
4007 $this->error(_ERROR_BADTEMPLATENAME);
4009 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
4010 $this->error(_ERROR_DUPTEMPLATENAME);
4013 $name = sql_real_escape_string($name);
4014 $desc = sql_real_escape_string($desc);
4016 // 1. Remove all template parts
4017 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4020 // 2. Update description
4021 $query = 'UPDATE '.sql_table('template_desc').' SET'
4022 . " tdname='" . $name . "',"
4023 . " tddesc='" . $desc . "'"
4024 . " WHERE tdnumber=" . $templateid;
4027 // 3. Add non-empty template parts
4028 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4029 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4030 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4031 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4032 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4033 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4034 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4035 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4036 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4037 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4038 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4039 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4040 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4041 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4042 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4043 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4044 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4045 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4046 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4047 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4048 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4049 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4050 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4051 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4052 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4053 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4054 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4055 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4056 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4057 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4058 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4059 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4060 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4061 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4063 $pluginfields = array();
4064 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4065 foreach ($pluginfields as $pfkey=>$pfvalue) {
4066 foreach ($pfvalue as $pffield=>$pfdesc) {
4067 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4071 // jump back to template edit
4072 $this->action_templateedit(_TEMPLATE_UPDATED);
4077 * @todo document this
4079 function addToTemplate($id, $partname, $content) {
4080 $partname = sql_real_escape_string($partname);
4081 $content = sql_real_escape_string($content);
4085 // don't add empty parts:
4086 if (!trim($content)) return -1;
4088 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
4089 . "VALUES ($id, '$partname', '$content')";
4090 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4091 return sql_insert_id();
4095 * @todo document this
4097 function action_templatedelete() {
4098 global $member, $manager;
4100 $member->isAdmin() or $this->disallow();
4102 $templateid = intRequestVar('templateid');
4103 // TODO: check if template can be deleted
4107 $name = TEMPLATE::getNameFromId($templateid);
4108 $desc = TEMPLATE::getDesc($templateid);
4111 <h2><?php echo _DELETE_CONFIRM?></h2>
4114 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo i18n::hsc($name)?></b> (<?php echo i18n::hsc($desc) ?>)
4117 <form method="post" action="index.php"><div>
4118 <input type="hidden" name="action" value="templatedeleteconfirm" />
4119 <?php $manager->addTicketHidden() ?>
4120 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4121 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4128 * @todo document this
4130 function action_templatedeleteconfirm() {
4131 global $member, $manager;
4133 $templateid = intRequestVar('templateid');
4135 $member->isAdmin() or $this->disallow();
4137 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4139 // 1. delete description
4140 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4143 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4145 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4147 $this->action_templateoverview();
4151 * @todo document this
4153 function action_templatenew() {
4156 $member->isAdmin() or $this->disallow();
4158 $name = postVar('name');
4159 $desc = postVar('desc');
4161 if (!isValidTemplateName($name))
4162 $this->error(_ERROR_BADTEMPLATENAME);
4164 if (TEMPLATE::exists($name))
4165 $this->error(_ERROR_DUPTEMPLATENAME);
4167 $newTemplateId = TEMPLATE::createNew($name, $desc);
4169 $this->action_templateoverview();
4173 * @todo document this
4175 function action_templateclone() {
4178 $templateid = intRequestVar('templateid');
4180 $member->isAdmin() or $this->disallow();
4182 // 1. read old template
4183 $name = TEMPLATE::getNameFromId($templateid);
4184 $desc = TEMPLATE::getDesc($templateid);
4186 // 2. create desc thing
4187 $name = "cloned" . $name;
4189 // if a template with that name already exists:
4190 if (TEMPLATE::exists($name)) {
4192 while (TEMPLATE::exists($name . $i))
4197 $newid = TEMPLATE::createNew($name, $desc);
4200 // go through parts of old template and add them to the new one
4201 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4202 while ($o = sql_fetch_object($res)) {
4203 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4206 $this->action_templateoverview();
4210 * @todo document this
4212 function action_skinoverview() {
4213 global $member, $manager;
4215 $member->isAdmin() or $this->disallow();
4219 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4221 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4223 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4225 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4226 $template['content'] = 'skinlist';
4227 $template['tabindex'] = 10;
4228 showlist($query,'table',$template);
4230 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4233 <form method="post" action="index.php">
4236 <input name="action" value="skinnew" type="hidden" />
4237 <?php $manager->addTicketHidden() ?>
4239 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4240 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4242 <td><?php echo _SKIN_DESC?></td>
4243 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4245 <td><?php echo _SKIN_CREATE?></td>
4246 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4257 * @todo document this
4259 function action_skinnew() {
4262 $member->isAdmin() or $this->disallow();
4264 $name = trim(postVar('name'));
4265 $desc = trim(postVar('desc'));
4267 if (!isValidSkinName($name))
4268 $this->error(_ERROR_BADSKINNAME);
4270 if (SKIN::exists($name))
4271 $this->error(_ERROR_DUPSKINNAME);
4273 $newId = SKIN::createNew($name, $desc);
4275 $this->action_skinoverview();
4279 * @todo document this
4281 function action_skinedit() {
4282 global $member, $manager;
4284 $skinid = intRequestVar('skinid');
4286 $member->isAdmin() or $this->disallow();
4288 $skin = new SKIN($skinid);
4293 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4295 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4297 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4298 <?php echo _SKIN_PARTS_MSG?>
4300 <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>
4301 <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>
4302 <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>
4303 <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>
4304 <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>
4305 <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>
4306 <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>
4307 <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>
4312 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4313 $res = sql_query($query);
4315 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4316 echo '<form method="get" action="index.php">' . "\r\n";
4317 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4318 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4319 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4320 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4321 echo '</form>' . "\r\n";
4323 if ($res && sql_num_rows($res) > 0) {
4327 while ($row = sql_fetch_assoc($res)) {
4328 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . i18n::hsc(strtolower($row['stype'])) . '">' . i18n::hsc(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . i18n::hsc(strtolower($row['stype'])) . '">remove</a>)</li>';
4336 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4337 <form method="post" action="index.php">
4340 <input type="hidden" name="action" value="skineditgeneral" />
4341 <?php $manager->addTicketHidden() ?>
4342 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4344 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4345 <td><input name="name" tabindex="90" value="<?php echo i18n::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
4347 <td><?php echo _SKIN_DESC?></td>
4348 <td><input name="desc" tabindex="100" value="<?php echo i18n::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4350 <td><?php echo _SKIN_TYPE?></td>
4351 <td><input name="type" tabindex="110" value="<?php echo i18n::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4353 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4354 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4356 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4357 <td><input name="inc_prefix" tabindex="130" value="<?php echo i18n::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4359 <td><?php echo _SKIN_CHANGE?></td>
4360 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4367 <?php $this->pagefoot();
4371 * @todo document this
4373 function action_skineditgeneral() {
4376 $skinid = intRequestVar('skinid');
4378 $member->isAdmin() or $this->disallow();
4380 $name = postVar('name');
4381 $desc = postVar('desc');
4382 $type = postVar('type');
4383 $inc_mode = postVar('inc_mode');
4384 $inc_prefix = postVar('inc_prefix');
4386 $skin = new SKIN($skinid);
4389 if (!isValidSkinName($name))
4390 $this->error(_ERROR_BADSKINNAME);
4392 if (($skin->getName() != $name) && SKIN::exists($name))
4393 $this->error(_ERROR_DUPSKINNAME);
4395 if (!$type) $type = 'text/html';
4396 if (!$inc_mode) $inc_mode = 'normal';
4398 // 2. Update description
4399 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4401 $this->action_skinedit();
4406 * @todo document this
4408 function action_skinedittype($msg = '') {
4409 global $member, $manager;
4411 $skinid = intRequestVar('skinid');
4412 $type = requestVar('type');
4414 $member->isAdmin() or $this->disallow();
4416 $type = trim($type);
4417 $type = strtolower($type);
4419 if (!isValidShortName($type)) {
4420 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4423 $skin = new SKIN($skinid);
4425 $friendlyNames = SKIN::getFriendlyNames();
4429 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4431 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo i18n::hsc($skin->getName()) ?>': <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4433 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4437 <form method="post" action="index.php">
4440 <input type="hidden" name="action" value="skinupdate" />
4441 <?php $manager->addTicketHidden() ?>
4442 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4443 <input type="hidden" name="type" value="<?php echo $type ?>" />
4445 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4446 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4447 (skin type: <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4448 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4449 help('skinpart' . $type);
4451 help('skinpartspecial');
4455 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo i18n::hsc($skin->getContent($type)) ?></textarea>
4458 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4459 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4460 (skin type: <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4463 <?php echo _SKIN_ALLOWEDVARS?>
4464 <?php $actions = SKIN::getAllowedActionsForType($type);
4468 while ($current = array_shift($actions)) {
4469 // skip deprecated vars
4470 if ($current == 'ifcat') continue;
4471 if ($current == 'imagetext') continue;
4472 if ($current == 'vars') continue;
4474 echo helplink('skinvar-' . $current) . "$current</a>";
4475 if (count($actions) != 0) echo ", ";
4477 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
4478 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4479 showlist($query,'table',array('content'=>'shortblognames'));
4480 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
4481 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4482 showlist($query,'table',array('content'=>'shortnames'));
4483 echo '</div></form>';
4488 * @todo document this
4490 function action_skinupdate() {
4493 $skinid = intRequestVar('skinid');
4494 $content = trim(postVar('content'));
4495 $type = postVar('type');
4497 $member->isAdmin() or $this->disallow();
4499 $skin = new SKIN($skinid);
4500 $skin->update($type, $content);
4502 $this->action_skinedittype(_SKIN_UPDATED);
4506 * @todo document this
4508 function action_skindelete() {
4509 global $member, $manager, $CONF;
4511 $skinid = intRequestVar('skinid');
4513 $member->isAdmin() or $this->disallow();
4515 // don't allow default skin to be deleted
4516 if ($skinid == $CONF['BaseSkin'])
4517 $this->error(_ERROR_DEFAULTSKIN);
4519 // don't allow deletion of default skins for blogs
4520 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4521 $r = sql_query($query);
4522 if ($o = sql_fetch_object($r))
4523 $this->error(_ERROR_SKINDEFDELETE . i18n::hsc($o->bname));
4527 $skin = new SKIN($skinid);
4528 $name = $skin->getName();
4529 $desc = $skin->getDescription();
4532 <h2><?php echo _DELETE_CONFIRM?></h2>
4535 <?php echo _CONFIRMTXT_SKIN?><b><?php echo i18n::hsc($name) ?></b> (<?php echo i18n::hsc($desc)?>)
4538 <form method="post" action="index.php"><div>
4539 <input type="hidden" name="action" value="skindeleteconfirm" />
4540 <?php $manager->addTicketHidden() ?>
4541 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4542 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4549 * @todo document this
4551 function action_skindeleteconfirm() {
4552 global $member, $CONF, $manager;
4554 $skinid = intRequestVar('skinid');
4556 $member->isAdmin() or $this->disallow();
4558 // don't allow default skin to be deleted
4559 if ($skinid == $CONF['BaseSkin'])
4560 $this->error(_ERROR_DEFAULTSKIN);
4562 // don't allow deletion of default skins for blogs
4563 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4564 $r = sql_query($query);
4565 if ($o = sql_fetch_object($r))
4566 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4568 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4570 // 1. delete description
4571 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4574 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4576 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4578 $this->action_skinoverview();
4582 * @todo document this
4584 function action_skinremovetype() {
4585 global $member, $manager, $CONF;
4587 $skinid = intRequestVar('skinid');
4588 $skintype = requestVar('type');
4590 if (!isValidShortName($skintype)) {
4591 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4594 $member->isAdmin() or $this->disallow();
4596 // don't allow default skinparts to be deleted
4597 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4598 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4603 $skin = new SKIN($skinid);
4604 $name = $skin->getName();
4605 $desc = $skin->getDescription();
4608 <h2><?php echo _DELETE_CONFIRM?></h2>
4611 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo i18n::hsc($skintype); ?> (<?php echo i18n::hsc($name); ?>)</b> (<?php echo i18n::hsc($desc)?>)
4614 <form method="post" action="index.php"><div>
4615 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4616 <?php $manager->addTicketHidden() ?>
4617 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4618 <input type="hidden" name="type" value="<?php echo i18n::hsc($skintype); ?>" />
4619 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4626 * @todo document this
4628 function action_skinremovetypeconfirm() {
4629 global $member, $CONF, $manager;
4631 $skinid = intRequestVar('skinid');
4632 $skintype = requestVar('type');
4634 if (!isValidShortName($skintype)) {
4635 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4638 $member->isAdmin() or $this->disallow();
4640 // don't allow default skinparts to be deleted
4641 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4642 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4645 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4648 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4650 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4652 $this->action_skinedit();
4656 * @todo document this
4658 function action_skinclone() {
4661 $skinid = intRequestVar('skinid');
4663 $member->isAdmin() or $this->disallow();
4665 // 1. read skin to clone
4666 $skin = new SKIN($skinid);
4668 $name = "clone_" . $skin->getName();
4670 // if a skin with that name already exists:
4671 if (SKIN::exists($name)) {
4673 while (SKIN::exists($name . $i))
4678 // 2. create skin desc
4679 $newid = SKIN::createNew(
4681 $skin->getDescription(),
4682 $skin->getContentType(),
4683 $skin->getIncludeMode(),
4684 $skin->getIncludePrefix()
4690 $this->skinclonetype($skin, $newid, 'index');
4691 $this->skinclonetype($skin, $newid, 'item');
4692 $this->skinclonetype($skin, $newid, 'archivelist');
4693 $this->skinclonetype($skin, $newid, 'archive');
4694 $this->skinclonetype($skin, $newid, 'search');
4695 $this->skinclonetype($skin, $newid, 'error');
4696 $this->skinclonetype($skin, $newid, 'member');
4697 $this->skinclonetype($skin, $newid, 'imagepopup');
4700 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4701 $res = sql_query($query);
4702 while ($row = sql_fetch_assoc($res)) {
4703 $this->skinclonetype($skin, $newid, $row['stype']);
4706 $this->action_skinoverview();
4711 * @todo document this
4713 function skinclonetype($skin, $newid, $type) {
4714 $newid = intval($newid);
4715 $content = $skin->getContent($type);
4717 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
4723 * @todo document this
4725 function action_settingsedit() {
4726 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4728 $member->isAdmin() or $this->disallow();
4732 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4735 <h2><?php echo _SETTINGS_TITLE?></h2>
4737 <form action="index.php" method="post">
4740 <input type="hidden" name="action" value="settingsupdate" />
4741 <?php $manager->addTicketHidden() ?>
4744 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4746 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4749 $query = 'SELECT bname as text, bnumber as value'
4750 . ' FROM '.sql_table('blog');
4751 $template['name'] = 'DefaultBlog';
4752 $template['selected'] = $CONF['DefaultBlog'];
4753 $template['tabindex'] = 10;
4754 showlist($query,'select',$template);
4758 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4761 $query = 'SELECT sdname as text, sdnumber as value'
4762 . ' FROM '.sql_table('skin_desc');
4763 $template['name'] = 'BaseSkin';
4764 $template['selected'] = $CONF['BaseSkin'];
4765 $template['tabindex'] = 1;
4766 showlist($query,'select',$template);
4770 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4771 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo i18n::hsc($CONF['AdminEmail']) ?>" /></td>
4773 <td><?php echo _SETTINGS_SITENAME?></td>
4774 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo i18n::hsc($CONF['SiteName']) ?>" /></td>
4776 <td><?php echo _SETTINGS_SITEURL?></td>
4777 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo i18n::hsc($CONF['IndexURL']) ?>" /></td>
4779 <td><?php echo _SETTINGS_ADMINURL?></td>
4780 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo i18n::hsc($CONF['AdminURL']) ?>" /></td>
4782 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4783 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo i18n::hsc($CONF['PluginURL']) ?>" /></td>
4785 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4786 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo i18n::hsc($CONF['SkinsURL']) ?>" /></td>
4788 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4789 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo i18n::hsc($CONF['ActionURL']) ?>" /></td>
4791 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
4794 <select name="Language" tabindex="10050">
4796 $locales = i18n::get_available_locale_list();
4797 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4799 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4803 echo "<option value=\"\">en_Latn_US</option>\n";
4806 foreach ( $locales as $locale )
4808 if ( $locale == 'en_Latn_US' )
4812 if ( $locale == i18n::get_current_locale() )
4814 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4818 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4826 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4828 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4830 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo i18n::hsc($CONF['DisableSiteURL'])?>" />
4833 <td><?php echo _SETTINGS_DIRS?></td>
4834 <td><?php echo i18n::hsc($DIR_NUCLEUS) ?>
4835 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4837 <td><?php echo _SETTINGS_DBLOGIN?></td>
4838 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4842 echo _SETTINGS_JSTOOLBAR
4843 /* =_SETTINGS_DISABLEJS
4845 I temporary changed the meaning of DisableJsTools, until I can find a good
4846 way to select the javascript version to use
4850 1 : all javascript disabled
4851 2 : 'simpler' javascript (for mozilla/opera/mac)
4855 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4856 <select name="DisableJsTools" tabindex="10075">
4857 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4858 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4859 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4860 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4861 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4862 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4867 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4870 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4871 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4873 echo ' ', _SETTINGS_URLMODE_HELP;
4879 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
4882 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
4888 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
4891 if (!array_key_exists('DefaultListSize',$CONF)) {
4892 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
4893 $CONF['DefaultListSize'] = 10;
4896 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo i18n::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
4899 <td><?php echo _SETTINGS_ADMINCSS?>
4903 <select name="AdminCSS" tabindex="10080">
4904 <?php // show a dropdown list of all available admin css files
4905 global $DIR_NUCLEUS;
4907 $dirhandle = opendir($DIR_NUCLEUS."styles/");
4909 while ($filename = readdir($dirhandle) )
4912 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
4913 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
4915 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
4918 $name = $matches[1];
4919 echo "<option value=\"$name\"";
4921 if ($name == $CONF['AdminCSS'])
4923 echo " selected=\"selected\"";
4926 echo ">$name</option>";
4932 closedir($dirhandle);
4939 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4941 <td><?php echo _SETTINGS_MEDIADIR?></td>
4942 <td><?php echo i18n::hsc($DIR_MEDIA) ?>
4943 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4944 <?php if (!is_dir($DIR_MEDIA))
4945 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4946 if (!is_readable($DIR_MEDIA))
4947 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4948 if (!is_writeable($DIR_MEDIA))
4949 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4953 <td><?php echo _SETTINGS_MEDIAURL?></td>
4955 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo i18n::hsc($CONF['MediaURL']) ?>" />
4958 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4959 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4961 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4963 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo i18n::hsc($CONF['AllowedTypes']) ?>" />
4966 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4968 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo i18n::hsc($CONF['MaxUploadSize']) ?>" />
4971 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4972 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4975 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4977 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4978 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4980 <td><?php echo _SETTINGS_ALLOWCREATE?>
4981 <?php help('allowaccountcreation'); ?>
4983 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4986 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4987 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4989 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4992 <td><?php echo _SETTINGS_MEMBERMSGS?>
4993 <?php help('messageservice'); ?>
4995 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
4998 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
4999 <?php help('messageservice'); ?>
5001 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5004 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
5005 <?php help('protectmemnames'); ?>
5007 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5013 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
5015 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
5016 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo i18n::hsc($CONF['CookiePrefix'])?>" /></td>
5018 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
5019 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo i18n::hsc($CONF['CookieDomain'])?>" /></td>
5021 <td><?php echo _SETTINGS_COOKIEPATH?></td>
5022 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo i18n::hsc($CONF['CookiePath'])?>" /></td>
5024 <td><?php echo _SETTINGS_COOKIESECURE?></td>
5025 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5027 <td><?php echo _SETTINGS_COOKIELIFE?></td>
5028 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5029 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5032 <td><?php echo _SETTINGS_LASTVISIT?></td>
5033 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5038 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5040 <td><?php echo _SETTINGS_UPDATE?></td>
5041 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5048 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5051 'GeneralSettingsFormExtras',
5059 * @todo document this
5061 function action_settingsupdate() {
5062 global $member, $CONF;
5064 $member->isAdmin() or $this->disallow();
5066 // check if email address for admin is valid
5067 if ( !isValidMailAddress(postVar('AdminEmail')) )
5069 $this->error(_ERROR_BADMAILADDRESS);
5073 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5074 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5075 $this->updateConfig('IndexURL', postVar('IndexURL'));
5076 $this->updateConfig('AdminURL', postVar('AdminURL'));
5077 $this->updateConfig('PluginURL', postVar('PluginURL'));
5078 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5079 $this->updateConfig('ActionURL', postVar('ActionURL'));
5080 $this->updateConfig('Language', postVar('Language'));
5081 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5082 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5083 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5084 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5085 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5086 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5087 $this->updateConfig('SiteName', postVar('SiteName'));
5088 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5089 $this->updateConfig('DisableSite', postVar('DisableSite'));
5090 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5091 $this->updateConfig('LastVisit', postVar('LastVisit'));
5092 $this->updateConfig('MediaURL', postVar('MediaURL'));
5093 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5094 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5095 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5096 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5097 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5098 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5099 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5100 $this->updateConfig('CookiePath', postVar('CookiePath'));
5101 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5102 $this->updateConfig('URLMode', postVar('URLMode'));
5103 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5104 $this->updateConfig('DebugVars', postVar('DebugVars'));
5105 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5106 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5108 // load new config and redirect (this way, the new language will be used is necessary)
5109 // note that when changing cookie settings, this redirect might cause the user
5110 // to have to log in again.
5112 redirect($CONF['AdminURL'] . '?action=manage');
5117 * Give an overview over the used system
5119 function action_systemoverview() {
5120 global $member, $nucleus, $CONF;
5124 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5126 if ($member->isLoggedIn() && $member->isAdmin()) {
5128 // Information about the used PHP and MySQL installation
5129 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";
5131 // Version of PHP MySQL
5134 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5135 echo "\t</tr><tr>\n";
5136 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5137 echo "\t\t" . '<td>' . phpversion() . "</td>\n";
5138 echo "\t</tr><tr>\n";
5139 echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5140 echo "\t\t" . '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5144 // Important PHP settings
5147 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5148 echo "\t</tr><tr>\n";
5149 echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";
5150 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5151 echo "\t\t" . '<td>' . $mqg . "</td>\n";
5152 echo "\t</tr><tr>\n";
5153 echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";
5154 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5155 echo "\t\t" . '<td>' . $mqr . "</td>\n";
5156 echo "\t</tr><tr>\n";
5157 echo "\t\t" . '<td>register_globals' . "</td>\n";
5158 $rg = ini_get('register_globals') ? 'On' : 'Off';
5159 echo "\t\t" . '<td>' . $rg . "</td>\n";
5163 // Information about GD library
5164 $gdinfo = gd_info();
5167 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5169 foreach ($gdinfo as $key=>$value) {
5170 if (is_bool($value)) {
5171 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5173 $value = i18n::hsc($value);
5176 echo "\t\t" . '<td width="50%">' . $key . "</td>\n";
5177 echo "\t\t" . '<td>' . $value . "</td>\n";
5182 // Check if special modules are loaded
5184 phpinfo(INFO_MODULES);
5185 $im = ob_get_contents();
5189 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5190 echo "\t</tr><tr>\n";
5191 echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";
5192 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5193 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5194 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5195 echo "\t\t" . '<td>' . $modrewrite . "</td>\n";
5199 // Information about the used Nucleus CMS
5200 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5202 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5203 $np = getNucleusPatchLevel();
5206 echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";
5207 echo "\t</tr><tr>\n";
5208 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5209 echo "\t\t" . '<td>' . $nv . "</td>\n";
5210 echo "\t</tr><tr>\n";
5211 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5212 echo "\t\t" . '<td>' . $np . "</td>\n";
5216 // Important settings of the installation
5219 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5220 echo "\t</tr><tr>\n";
5221 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";
5222 echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";
5223 echo "\t</tr><tr>\n";
5224 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";
5225 echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";
5226 echo "\t</tr><tr>\n";
5227 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5228 $ohs = $CONF['alertOnHeadersSent'] ?
5229 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5230 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5231 echo "\t\t" . '<td>' . $ohs . "</td>\n";
5235 // Link to the online version test at the Nucleus CMS website
5236 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5237 if ($nucleus['codename'] != '') {
5238 $codenamestring = ' "' . $nucleus['codename'] . '"';
5240 $codenamestring = '';
5242 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5243 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5244 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5245 echo 'Nucleus CMS ' . $nv . $codenamestring;
5250 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5257 * @todo document this
5259 function updateConfig($name, $val) {
5260 $name = sql_real_escape_string($name);
5261 $val = trim(sql_real_escape_string($val));
5263 $query = 'UPDATE '.sql_table('config')
5264 . " SET value='$val'"
5265 . " WHERE name='$name'";
5267 sql_query($query) or die("Query error: " . sql_error());
5268 return sql_insert_id();
5273 * @param string $msg message that will be shown
5275 function error($msg) {
5281 echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
5287 * @todo document this
5289 function disallow() {
5290 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5292 $this->error(_ERROR_DISALLOWED);
5296 * @todo document this
5298 function pagehead($extrahead = '') {
5299 global $member, $nucleus, $CONF, $manager;
5304 'extrahead' => &$extrahead,
5305 'action' => $this->action
5309 $baseUrl = i18n::hsc($CONF['AdminURL']);
5310 if (!array_key_exists('AdminCSS',$CONF))
5312 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5313 $CONF['AdminCSS'] = 'original';
5316 $root_element = 'html';
5317 $charset = i18n::get_current_charset();
5318 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5320 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5321 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5322 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5325 <title><?php echo i18n::hsc($CONF['SiteName'])?> - Admin</title>
5326 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin_<?php echo $CONF["AdminCSS"]?>.css" />
5327 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
5328 href="<?php echo $baseUrl?>styles/addedit.css" />
5330 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
5331 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
5332 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
5334 <meta http-equiv='Pragma' content='no-cache' />
5335 <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
5336 <meta http-equiv='Expires' content='-1' />
5338 <?php echo $extrahead?>
5341 <div id="adminwrapper">
5342 <div class="header">
5343 <h1><?php echo i18n::hsc($CONF['SiteName'])?></h1>
5345 <div id="container">
5347 <div class="loginname">
5348 <?php if ($member->isLoggedIn())
5349 echo _LOGGEDINAS . ' ' . $member->getDisplayName()
5350 ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
5351 . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5353 echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
5355 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
5359 $codenamestring = ($nucleus['codename']!='')? ' "'.$nucleus['codename'].'"':'';
5361 if ($member->isLoggedIn() && $member->isAdmin()) {
5362 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5363 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5364 $newestVersion = getLatestVersion();
5365 $newestCompare = str_replace('/','.',$newestVersion);
5366 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5367 if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {
5368 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE.'">'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.'</a>';
5371 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5378 * @todo document this
5380 function pagefoot() {
5381 global $action, $member, $manager;
5386 'action' => $this->action
5390 if ($member->isLoggedIn() && ($action != 'showlogin')) {
5392 <h2><?php echo _LOGOUT ?></h2>
5394 <li><a href="index.php?action=overview"><?php echo _BACKHOME?></a></li>
5395 <li><a href='index.php?action=logout'><?php echo _LOGOUT?></a></li>
5400 <a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> © 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>
5402 <a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>
5405 </div><!-- content -->
5407 <div id="quickmenu">
5409 <?php // ---- user settings ----
5410 if (($action != 'showlogin') && ($member->isLoggedIn())) {
5412 echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
5415 echo '<h2>',_QMENU_ADD,'</h2>';
5416 echo '<form method="get" action="index.php"><div>';
5417 echo '<input type="hidden" name="action" value="createitem" />';
5419 $showAll = requestVar('showall');
5420 if (($member->isAdmin()) && ($showAll == 'yes')) {
5421 // Super-Admins have access to all blogs! (no add item support though)
5422 $query = 'SELECT bnumber as value, bname as text'
5423 . ' FROM ' . sql_table('blog')
5424 . ' ORDER BY bname';
5426 $query = 'SELECT bnumber as value, bname as text'
5427 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5428 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5429 . ' ORDER BY bname';
5431 $template['name'] = 'blogid';
5432 $template['tabindex'] = 15000;
5433 $template['extra'] = _QMENU_ADD_SELECT;
5434 $template['selected'] = -1;
5435 $template['shorten'] = 10;
5436 $template['shortenel'] = '';
5437 $template['javascript'] = 'onchange="return form.submit()"';
5438 showlist($query,'select',$template);
5440 echo '</div></form>';
5442 echo '<h2>' . $member->getDisplayName(). '</h2>';
5444 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';
5445 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';
5446 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';
5452 // ---- general settings ----
5453 if ($member->isAdmin()) {
5455 echo '<h2>',_QMENU_MANAGE,'</h2>';
5458 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';
5459 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';
5460 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';
5461 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';
5462 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';
5463 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';
5464 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';
5467 echo '<h2>',_QMENU_LAYOUT,'</h2>';
5469 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';
5470 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';
5471 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';
5476 $aPluginExtras = array();
5480 'options' => &$aPluginExtras
5483 if (count($aPluginExtras) > 0)
5485 echo '<h2>', _QMENU_PLUGINS, '</h2>';
5487 foreach ($aPluginExtras as $aInfo)
5489 echo '<li><a href="'.i18n::hsc($aInfo['url']).'" title="'.i18n::hsc($aInfo['tooltip']).'">'.i18n::hsc($aInfo['title']).'</a></li>';
5494 } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
5496 echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
5498 // introduction text on login screen
5499 echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
5504 <!-- content / quickmenu container -->
5505 <div class="clear"></div> <!-- new -->
5508 <!-- adminwrapper --> <!-- new -->
5515 * @todo document this
5517 function action_regfile() {
5518 global $member, $CONF;
5520 $blogid = intRequestVar('blogid');
5522 $member->teamRights($blogid) or $this->disallow();
5524 // header-code stolen from phpMyAdmin
5525 // REGEDIT and bookmarklet code stolen from GreyMatter
5527 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5530 header('Content-Type: application/octetstream');
5531 header('Content-Disposition: filename="nucleus.reg"');
5532 header('Pragma: no-cache');
5533 header('Expires: 0');
5536 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5537 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5538 echo '"contexts"=hex:31';
5542 * @todo document this
5544 function action_bookmarklet() {
5545 global $member, $manager;
5547 $blogid = intRequestVar('blogid');
5549 $member->teamRights($blogid) or $this->disallow();
5551 $blog =& $manager->getBlog($blogid);
5552 $bm = getBookmarklet($blogid);
5556 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5560 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
5563 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
5566 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
5568 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
5571 <?php echo '<a href="' . i18n::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, i18n::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
5574 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
5577 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5578 $url = $manager->addTicketToUrl($url);
5580 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . i18n::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
5584 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
5587 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
5589 <?php echo _BOOKMARKLET_DELETEBAR ?>
5593 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
5597 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
5598 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
5599 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
5600 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
5601 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
5610 * @todo document this
5612 function action_actionlog() {
5613 global $member, $manager;
5615 $member->isAdmin() or $this->disallow();
5619 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5621 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5624 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5625 <p><a href="<?php echo i18n::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5627 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5629 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5630 $template['content'] = 'actionlist';
5631 $amount = showlist($query,'table',$template);
5638 * @todo document this
5640 function action_banlist() {
5641 global $member, $manager;
5643 $blogid = intRequestVar('blogid');
5645 $member->blogAdminRights($blogid) or $this->disallow();
5647 $blog =& $manager->getBlog($blogid);
5651 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5653 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5655 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5656 $template['content'] = 'banlist';
5657 $amount = showlist($query,'table',$template);
5662 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5663 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5671 * @todo document this
5673 function action_banlistdelete() {
5674 global $member, $manager;
5676 $blogid = intRequestVar('blogid');
5677 $iprange = requestVar('iprange');
5679 $member->blogAdminRights($blogid) or $this->disallow();
5681 $blog =& $manager->getBlog($blogid);
5682 $banBlogName = i18n::hsc($blog->getName());
5686 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5688 <form method="post" action="index.php">
5690 <h3><?php echo _BAN_IPRANGE?></h3>
5693 <?php echo _CONFIRMTXT_BAN?> <?php echo i18n::hsc($iprange) ?>
5694 <input name="iprange" type="hidden" value="<?php echo i18n::hsc($iprange)?>" />
5697 <h3><?php echo _BAN_BLOGS?></h3>
5700 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5701 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
5702 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
5704 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5707 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5710 <?php $manager->addTicketHidden() ?>
5711 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5712 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5721 * @todo document this
5723 function action_banlistdeleteconfirm() {
5724 global $member, $manager;
5726 $blogid = intPostVar('blogid');
5727 $allblogs = postVar('allblogs');
5728 $iprange = postVar('iprange');
5730 $member->blogAdminRights($blogid) or $this->disallow();
5735 if (BAN::removeBan($blogid, $iprange))
5736 array_push($deleted, $blogid);
5738 // get blogs fot which member has admin rights
5739 $adminblogs = $member->getAdminBlogs();
5740 foreach ($adminblogs as $blogje) {
5741 if (BAN::removeBan($blogje, $iprange))
5742 array_push($deleted, $blogje);
5746 if (sizeof($deleted) == 0)
5747 $this->error(_ERROR_DELETEBAN);
5751 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5752 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5753 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5756 foreach ($deleted as $delblog) {
5757 $b =& $manager->getBlog($delblog);
5758 echo "<li>" . i18n::hsc($b->getName()). "</li>";
5767 * @todo document this
5769 function action_banlistnewfromitem() {
5770 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5774 * @todo document this
5776 function action_banlistnew($blogid = '') {
5777 global $member, $manager;
5780 $blogid = intRequestVar('blogid');
5782 $ip = requestVar('ip');
5784 $member->blogAdminRights($blogid) or $this->disallow();
5786 $blog =& $manager->getBlog($blogid);
5790 <h2><?php echo _BAN_ADD_TITLE?></h2>
5793 <form method="post" action="index.php">
5795 <h3><?php echo _BAN_IPRANGE?></h3>
5797 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5800 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
5801 <?php echo _BAN_EXAMPLE_TEXT ?>
5807 $iprangeVal = i18n::hsc($ip);
5809 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
5810 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
5812 <input name="iprange" type="radio" value="custom" id="ip_custom" />
5813 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
5814 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
5817 echo "<input name='iprange' value='custom' type='hidden' />";
5818 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5823 <h3><?php echo _BAN_BLOGS?></h3>
5825 <p><?php echo _BAN_BLOGS_TEXT?></p>
5828 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5829 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo i18n::hsc($blog->getName())?>'</label>
5831 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5834 <h3><?php echo _BAN_REASON_TITLE?></h3>
5836 <p><?php echo _BAN_REASON_TEXT?></p>
5838 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5840 <h3><?php echo _BAN_ADD_TITLE?></h3>
5843 <input name="action" type="hidden" value="banlistadd" />
5844 <?php $manager->addTicketHidden() ?>
5845 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5850 <?php $this->pagefoot();
5854 * @todo document this
5856 function action_banlistadd() {
5859 $blogid = intPostVar('blogid');
5860 $allblogs = postVar('allblogs');
5861 $iprange = postVar('iprange');
5862 if ($iprange == "custom")
5863 $iprange = postVar('customiprange');
5864 $reason = postVar('reason');
5866 $member->blogAdminRights($blogid) or $this->disallow();
5868 // TODO: check IP range validity
5871 if (!BAN::addBan($blogid, $iprange, $reason))
5872 $this->error(_ERROR_ADDBAN);
5874 // get blogs fot which member has admin rights
5875 $adminblogs = $member->getAdminBlogs();
5877 foreach ($adminblogs as $blogje) {
5878 if (!BAN::addBan($blogje, $iprange, $reason))
5882 $this->error(_ERROR_ADDBAN);
5885 $this->action_banlist();
5890 * @todo document this
5892 function action_clearactionlog() {
5895 $member->isAdmin() or $this->disallow();
5899 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5903 * @todo document this
5905 function action_backupoverview() {
5906 global $member, $manager;
5908 $member->isAdmin() or $this->disallow();
5912 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5914 <h2><?php echo _BACKUPS_TITLE?></h2>
5916 <h3><?php echo _BACKUP_TITLE?></h3>
5918 <p><?php echo _BACKUP_INTRO?></p>
5920 <form method="post" action="index.php"><p>
5921 <input type="hidden" name="action" value="backupcreate" />
5922 <?php $manager->addTicketHidden() ?>
5924 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
5926 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
5928 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
5932 <div class="note"><?php echo _BACKUP_NOTE?></div>
5935 <h3><?php echo _RESTORE_TITLE?></h3>
5937 <div class="note"><?php echo _RESTORE_NOTE?></div>
5939 <p><?php echo _RESTORE_INTRO?></p>
5941 <form method="post" action="index.php" enctype="multipart/form-data"><p>
5942 <input type="hidden" name="action" value="backuprestore" />
5943 <?php $manager->addTicketHidden() ?>
5944 <input name="backup_file" type="file" tabindex="30" />
5946 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
5947 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
5948 <br /><?php echo _RESTORE_WARNING?>
5951 <?php $this->pagefoot();
5955 * @todo document this
5957 function action_backupcreate() {
5958 global $member, $DIR_LIBS;
5960 $member->isAdmin() or $this->disallow();
5962 // use compression ?
5963 $useGzip = intval(postVar('gzip'));
5965 include($DIR_LIBS . 'backup.php');
5967 // try to extend time limit
5968 // (creating/restoring dumps might take a while)
5969 @set_time_limit(1200);
5972 $bu->do_backup($useGzip);
5977 * @todo document this
5979 function action_backuprestore() {
5980 global $member, $DIR_LIBS;
5982 $member->isAdmin() or $this->disallow();
5984 if (intPostVar('letsgo') != 1)
5985 $this->error(_ERROR_BACKUP_NOTSURE);
5987 include($DIR_LIBS . 'backup.php');
5989 // try to extend time limit
5990 // (creating/restoring dumps might take a while)
5991 @set_time_limit(1200);
5994 $message = $bu->do_restore();
5996 $this->error($message);
6000 <h2><?php echo _RESTORE_COMPLETE?></h2>
6001 <?php $this->pagefoot();
6006 * @todo document this
6008 function action_pluginlist() {
6009 global $member, $manager;
6012 $member->isAdmin() or $this->disallow();
6016 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6018 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6020 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6023 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6025 $template['content'] = 'pluginlist';
6026 $template['tabindex'] = 10;
6027 showlist($query, 'table', $template);
6030 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
6032 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
6034 <form method="post" action="index.php"><div>
6035 <input type="hidden" name="action" value="pluginupdate" />
6036 <?php $manager->addTicketHidden() ?>
6037 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
6040 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
6043 // find a list of possibly non-installed plugins
6044 $candidates = array();
6046 global $DIR_PLUGINS;
6048 $dirhandle = opendir($DIR_PLUGINS);
6050 while ($filename = readdir($dirhandle) )
6053 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
6054 # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
6056 if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6059 $name = $matches[1];
6060 // only show in list when not yet installed
6061 $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
6063 if (sql_num_rows($res) == 0)
6065 array_push($candidates, $name);
6072 closedir($dirhandle);
6074 if (sizeof($candidates) > 0)
6077 <p><?php echo _PLUGS_ADD_TEXT?></p>
6079 <form method='post' action='index.php'><div>
6080 <input type='hidden' name='action' value='pluginadd' />
6081 <?php $manager->addTicketHidden() ?>
6082 <select name="filename" tabindex="30">
6084 foreach($candidates as $name)
6086 echo '<option value="NP_',$name,'">',i18n::hsc($name),'</option>';
6090 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
6097 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6105 * @todo document this
6107 function action_pluginhelp() {
6108 global $member, $manager, $DIR_PLUGINS, $CONF;
6111 $member->isAdmin() or $this->disallow();
6113 $plugid = intGetVar('plugid');
6115 if (!$manager->pidInstalled($plugid))
6116 $this->error(_ERROR_NOSUCHPLUGIN);
6118 $plugName = getPluginNameFromPid($plugid);
6122 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6124 echo '<h2>',_PLUGS_HELP_TITLE,': ',i18n::hsc($plugName),'</h2>';
6126 $plug =& $manager->getPlugin($plugName);
6127 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6129 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6130 @readfile($helpFile);
6132 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6133 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6141 * @todo document this
6143 function action_pluginadd() {
6144 global $member, $manager, $DIR_PLUGINS;
6147 $member->isAdmin() or $this->disallow();
6149 $name = postVar('filename');
6151 if ($manager->pluginInstalled($name))
6152 $this->error(_ERROR_DUPPLUGIN);
6153 if (!checkPlugin($name))
6154 $this->error(_ERROR_PLUGFILEERROR . ' (' . i18n::hsc($name) . ')');
6156 // get number of currently installed plugins
6157 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6158 $numCurrent = sql_num_rows($res);
6160 // plugin will be added as last one in the list
6161 $newOrder = $numCurrent + 1;
6170 // do this before calling getPlugin (in case the plugin id is used there)
6171 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6173 $iPid = sql_insert_id();
6175 $manager->clearCachedInfo('installedPlugins');
6177 // Load the plugin for condition checking and instalation
6178 $plugin =& $manager->getPlugin($name);
6180 // check if it got loaded (could have failed)
6183 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6184 $manager->clearCachedInfo('installedPlugins');
6185 $this->error(_ERROR_PLUGIN_LOAD);
6188 // check if plugin needs a newer Nucleus version
6189 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
6191 // uninstall plugin again...
6192 $this->deleteOnePlugin($plugin->getID());
6194 // ...and show error
6195 $this->error(_ERROR_NUCLEUSVERSIONREQ . i18n::hsc($plugin->getMinNucleusVersion()));
6198 // check if plugin needs a newer Nucleus version
6199 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
6201 // uninstall plugin again...
6202 $this->deleteOnePlugin($plugin->getID());
6204 // ...and show error
6205 $this->error(_ERROR_NUCLEUSVERSIONREQ . i18n::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6208 $pluginList = $plugin->getPluginDep();
6209 foreach ($pluginList as $pluginName)
6212 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6213 if (sql_num_rows($res) == 0)
6215 // uninstall plugin again...
6216 $this->deleteOnePlugin($plugin->getID());
6218 $this->error(sprintf(_ERROR_INSREQPLUGIN, i18n::hsc($pluginName)));
6222 // call the install method of the plugin
6228 'plugin' => &$plugin
6232 // update all events
6233 $this->action_pluginupdate();
6237 * @todo document this
6239 function action_pluginupdate() {
6240 global $member, $manager, $CONF;
6243 $member->isAdmin() or $this->disallow();
6245 // delete everything from plugin_events
6246 sql_query('DELETE FROM '.sql_table('plugin_event'));
6248 // loop over all installed plugins
6249 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6250 while($o = sql_fetch_object($res)) {
6252 $plug =& $manager->getPlugin($o->pfile);
6255 $eventList = $plug->getEventList();
6256 foreach ($eventList as $eventName)
6257 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
6261 redirect($CONF['AdminURL'] . '?action=pluginlist');
6262 // $this->action_pluginlist();
6266 * @todo document this
6268 function action_plugindelete() {
6269 global $member, $manager;
6272 $member->isAdmin() or $this->disallow();
6274 $pid = intGetVar('plugid');
6276 if (!$manager->pidInstalled($pid))
6277 $this->error(_ERROR_NOSUCHPLUGIN);
6281 <h2><?php echo _DELETE_CONFIRM?></h2>
6283 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6285 <form method="post" action="index.php"><div>
6286 <?php $manager->addTicketHidden() ?>
6287 <input type="hidden" name="action" value="plugindeleteconfirm" />
6288 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6289 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6296 * @todo document this
6298 function action_plugindeleteconfirm() {
6299 global $member, $manager, $CONF;
6302 $member->isAdmin() or $this->disallow();
6304 $pid = intPostVar('plugid');
6306 $error = $this->deleteOnePlugin($pid, 1);
6308 $this->error($error);
6311 redirect($CONF['AdminURL'] . '?action=pluginlist');
6312 // $this->action_pluginlist();
6316 * @todo document this
6318 function deleteOnePlugin($pid, $callUninstall = 0) {
6321 $pid = intval($pid);
6323 if (!$manager->pidInstalled($pid))
6324 return _ERROR_NOSUCHPLUGIN;
6326 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6328 /* // call the unInstall method of the plugin
6329 if ($callUninstall) {
6330 $plugin =& $manager->getPlugin($name);
6331 if ($plugin) $plugin->unInstall();
6334 // check dependency before delete
6335 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6336 while($o = sql_fetch_object($res)) {
6337 $plug =& $manager->getPlugin($o->pfile);
6340 $depList = $plug->getPluginDep();
6341 foreach ($depList as $depName)
6343 if ($name == $depName)
6345 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6351 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6353 // call the unInstall method of the plugin
6354 if ($callUninstall) {
6355 $plugin =& $manager->getPlugin($name);
6356 if ($plugin) $plugin->unInstall();
6359 // delete all subscriptions
6360 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6362 // delete all options
6363 // get OIDs from plugin_option_desc
6364 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6366 while ($o = sql_fetch_object($res)) {
6367 array_push($aOIDs, $o->oid);
6370 // delete from plugin_option and plugin_option_desc
6371 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6372 if (count($aOIDs) > 0)
6373 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6375 // update order numbers
6376 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6377 $o = sql_fetch_object($res);
6378 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6381 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6383 $manager->clearCachedInfo('installedPlugins');
6384 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6390 * @todo document this
6392 function action_pluginup() {
6393 global $member, $manager, $CONF;
6396 $member->isAdmin() or $this->disallow();
6398 $plugid = intGetVar('plugid');
6400 if (!$manager->pidInstalled($plugid))
6401 $this->error(_ERROR_NOSUCHPLUGIN);
6403 // 1. get old order number
6404 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6405 $o = sql_fetch_object($res);
6406 $oldOrder = $o->porder;
6408 // 2. calculate new order number
6409 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6411 // 3. update plug numbers
6412 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6413 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6415 //$this->action_pluginlist();
6416 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6417 redirect($CONF['AdminURL'] . '?action=pluginlist');
6421 * @todo document this
6423 function action_plugindown() {
6424 global $member, $manager, $CONF;
6427 $member->isAdmin() or $this->disallow();
6429 $plugid = intGetVar('plugid');
6430 if (!$manager->pidInstalled($plugid))
6431 $this->error(_ERROR_NOSUCHPLUGIN);
6433 // 1. get old order number
6434 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6435 $o = sql_fetch_object($res);
6436 $oldOrder = $o->porder;
6438 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6439 $maxOrder = sql_num_rows($res);
6441 // 2. calculate new order number
6442 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6444 // 3. update plug numbers
6445 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6446 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6448 //$this->action_pluginlist();
6449 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6450 redirect($CONF['AdminURL'] . '?action=pluginlist');
6454 * @todo document this
6456 function action_pluginoptions($message = '') {
6457 global $member, $manager;
6460 $member->isAdmin() or $this->disallow();
6462 $pid = intRequestVar('plugid');
6463 if (!$manager->pidInstalled($pid))
6464 $this->error(_ERROR_NOSUCHPLUGIN);
6466 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
6467 $pluginName = i18n::hsc(getPluginNameFromPid($pid));
6468 $this->pagehead($extrahead);
6471 <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
6473 <h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>
6475 <?php if ($message) echo $message?>
6477 <form action="index.php" method="post">
6479 <input type="hidden" name="action" value="pluginoptionsupdate" />
6480 <input type="hidden" name="plugid" value="<?php echo $pid?>" />
6484 $manager->addTicketHidden();
6486 $aOptions = array();
6488 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
6489 $r = sql_query($query);
6490 while ($o = sql_fetch_object($r)) {
6491 array_push($aOIDs, $o->oid);
6492 $aOptions[$o->oid] = array(
6494 'value' => $o->odef,
6495 'name' => $o->oname,
6496 'description' => $o->odesc,
6497 'type' => $o->otype,
6498 'typeinfo' => $o->oextra,
6502 // fill out actual values
6503 if (count($aOIDs) > 0) {
6504 $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
6505 while ($o = sql_fetch_object($r))
6506 $aOptions[$o->oid]['value'] = $o->ovalue;
6510 $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
6512 $template['content'] = 'plugoptionlist';
6513 $amount = showlist($aOptions,'table',$template);
6515 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6520 <?php $this->pagefoot();
6527 * @todo document this
6529 function action_pluginoptionsupdate() {
6530 global $member, $manager;
6533 $member->isAdmin() or $this->disallow();
6535 $pid = intRequestVar('plugid');
6536 if (!$manager->pidInstalled($pid))
6537 $this->error(_ERROR_NOSUCHPLUGIN);
6539 $aOptions = requestArray('plugoption');
6540 NucleusPlugin::_applyPluginOptions($aOptions);
6542 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6544 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6549 * @todo document this
6551 function _insertPluginOptions($context, $contextid = 0) {
6552 // get all current values for this contextid
6553 // (note: this might contain doubles for overlapping contextids)
6554 $aIdToValue = array();
6555 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6556 while ($o = sql_fetch_object($res)) {
6557 $aIdToValue[$o->oid] = $o->ovalue;
6560 // get list of oids per pid
6561 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6562 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
6563 $res = sql_query($query);
6564 $aOptions = array();
6565 while ($o = sql_fetch_object($res)) {
6566 if (in_array($o->oid, array_keys($aIdToValue)))
6567 $value = $aIdToValue[$o->oid];
6571 array_push($aOptions, array(
6573 'pfile' => $o->pfile,
6576 'name' => $o->oname,
6577 'description' => $o->odesc,
6578 'type' => $o->otype,
6579 'typeinfo' => $o->oextra,
6580 'contextid' => $contextid,
6586 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6590 foreach ($aOptions as $aOption) {
6593 if ($iPrevPid != $aOption['pid']) {
6594 $iPrevPid = $aOption['pid'];
6595 if (!defined('_PLUGIN_OPTIONS_TITLE')) {
6596 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
6598 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, i18n::hsc($aOption['pfile'])).'</th></tr>';
6601 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
6602 if (@$meta['access'] != 'hidden') {
6604 listplug_plugOptionRow($aOption);
6614 * ADMIN::input_yesno()
6615 * Output input elements with radio attribute for yes/no options
6617 * @param string $name name attribute
6618 * @param string $value_current current value attribute
6619 * @param integer $tabindex tab index
6620 * @param string $value_yes value attribute for yes option
6621 * @param string $value_no value attribute for no option
6622 * @param string $text_yes child text element for yes option
6623 * @param string $text_no child text element for no option
6624 * @param boolean $isAdmin have admin right or not
6627 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
6629 $id = preg_replace('#\[|\]#', '-', $name);
6630 $id_yes = $id . $value_yes;
6631 $id_no = $id . $value_no;
6634 echo '<input type="radio" id="' . i18n::hsc($id_yes) . '" name="' . i18n::hsc($name) . '" value="' . i18n::hsc($value_yes) . '"';
6635 if ( $name=="admin" )
6637 echo ' onclick="selectCanLogin(true);"';
6639 if ( $value_current == $value_yes )
6641 echo " tabindex='$tabindex' checked='checked'";
6644 echo '<label for="' . i18n::hsc($id_yes) . '">' . i18n::hsc($text_yes) . "</label>\n";
6647 echo '<input type="radio" id="' . i18n::hsc($id_no) . '" name="' . i18n::hsc($name) . '" value="' . i18n::hsc($value_no) . '"';
6648 if ( $name=="admin" )
6650 echo ' onclick="selectCanLogin(false);"';
6652 if ( $value_current != $value_yes )
6654 echo " tabindex='$tabindex' checked='checked'";
6656 if ($isAdmin && $name=="canlogin")
6658 echo ' disabled="disabled"';
6661 echo '<label for="' . i18n::hsc($id_no) . '">' . i18n::hsc($text_no) . "</label>\n";