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
30 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
44 * @param string $action action to be performed
46 function action($action) {
47 global $CONF, $manager;
49 // list of action aliases
51 'login' => 'overview',
55 if (isset($alias[$action]))
56 $action = $alias[$action];
58 $methodName = 'action_' . $action;
60 $this->action = strtolower($action);
62 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
63 // is an action that requires user interaction before something is actually done)
64 // all safe actions are in this array:
65 $aActionsNotToCheck = array(
117 // the rest of the actions needs to be checked
118 $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
120 if (!in_array($this->action, $aActionsNotToCheck))
122 if (!$manager->checkTicket())
123 $this->error(_ERROR_BADTICKET);
126 if (method_exists($this, $methodName))
127 call_user_func(array(&$this, $methodName));
129 $this->error(_BADACTION . i18n::hsc(" ($action)"));
134 * @todo document this
136 function action_showlogin() {
138 $this->action_login($error);
142 * @todo document this
144 function action_login($msg = '', $passvars = 1) {
147 // skip to overview when allowed
148 if ($member->isLoggedIn() && $member->canLogin()) {
149 $this->action_overview();
155 echo '<h2>', _LOGIN ,'</h2>';
156 if ($msg) echo _MESSAGE , ': ', i18n::hsc($msg);
159 <form action="index.php" method="post"><p>
160 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
162 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
164 <input name="action" value="login" type="hidden" />
166 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
169 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
170 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
172 <?php // pass through vars
174 $oldaction = postVar('oldaction');
175 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
182 <?php $this->pagefoot();
187 * provides a screen with the overview of the actions available
188 * @todo document parameter
190 function action_overview($msg = '') {
196 echo _MESSAGE , ': ', $msg;
198 /* ---- add items ---- */
199 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
201 $showAll = requestVar('showall');
203 if (($member->isAdmin()) && ($showAll == 'yes')) {
204 // Super-Admins have access to all blogs! (no add item support though)
205 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
206 . ' FROM ' . sql_table('blog')
209 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
210 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
211 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
214 $template['content'] = 'bloglist';
215 $template['superadmin'] = $member->isAdmin();
216 $amount = showlist($query,'table',$template);
218 if (($showAll != 'yes') && ($member->isAdmin())) {
219 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
220 if ($total > $amount)
221 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
225 echo _OVERVIEW_NOBLOGS;
228 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
229 $query = 'SELECT ititle, inumber, bshortname'
230 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
231 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
232 $template['content'] = 'draftlist';
233 $amountdrafts = showlist($query, 'table', $template);
234 if ($amountdrafts == 0)
235 echo _OVERVIEW_NODRAFTS;
239 $yrBlogs = $member->getAdminBlogs();
240 if ($showAll != 'yes') {
242 foreach ($yrBlogs as $value) {
243 if ($member->isBlogAdmin(intval($value))) {
244 $admBlogs[] = intval($value);
247 $yrBlogs = $admBlogs;
250 if (count($yrBlogs) > 0) {
251 echo '<h2>' . _OVERVIEW_OTHER_DRAFTS . '</h2>';
252 $query = 'SELECT ititle, inumber, bshortname, mname'
253 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog'). ', ' . sql_table('member')
254 . ' WHERE iauthor<>'.$member->getID().' and iblog IN ('.implode(",",$yrBlogs).') and iblog=bnumber and iauthor=mnumber and idraft=1'
255 . ' ORDER BY iblog ASC';
256 $template['content'] = 'otherdraftlist';
257 $amountdrafts = showlist($query, 'table', $template);
258 if ($amountdrafts == 0)
259 echo _OVERVIEW_NODRAFTS;
263 /* ---- user settings ---- */
264 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
266 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
267 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
268 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
271 /* ---- general settings ---- */
272 if ($member->isAdmin()) {
273 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
275 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
284 * Returns a link to a weblog
287 function bloglink(&$blog) {
288 return '<a href="'.i18n::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. i18n::hsc( $blog->getName() ) .'</a>';
292 * @todo document this
294 function action_manage($msg = '') {
297 $member->isAdmin() or $this->disallow();
301 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
304 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
307 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
310 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
311 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
312 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
313 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
316 echo '<h2>' . _MANAGE_SKINS . '</h2>';
318 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
319 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
320 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
323 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
325 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
326 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
333 * @todo document this
335 function action_itemlist($blogid = '') {
336 global $member, $manager, $CONF;
339 $blogid = intRequestVar('blogid');
341 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
344 $blog =& $manager->getBlog($blogid);
346 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
347 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
350 if (postVar('start'))
351 $start = intPostVar('start');
356 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
358 // amount of items to show
359 if (postVar('amount'))
360 $amount = intPostVar('amount');
362 $amount = intval($CONF['DefaultListSize']);
367 $search = postVar('search'); // search through items
369 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
370 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
371 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
374 $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) . '%"))';
376 // non-blog-admins can only edit/delete their own items
377 if (!$member->blogAdminRights($blogid))
378 $query .= ' and iauthor=' . $member->getID();
381 $query .= ' ORDER BY itime DESC'
382 . " LIMIT $start,$amount";
384 $template['content'] = 'itemlist';
385 $template['now'] = $blog->getCorrectTime(time());
387 $manager->loadClass("ENCAPSULATE");
388 $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
389 $navList->showBatchList('item',$query,'table',$template);
396 * @todo document this
398 function action_batchitem() {
399 global $member, $manager;
401 // check if logged in
402 $member->isLoggedIn() or $this->disallow();
404 // more precise check will be done for each performed operation
406 // get array of itemids from request
407 $selected = requestIntArray('batch');
408 $action = requestVar('batchaction');
410 // Show error when no items were selected
411 if (!is_array($selected) || sizeof($selected) == 0)
412 $this->error(_BATCH_NOSELECTION);
414 // On move: when no destination blog/category chosen, show choice now
415 $destCatid = intRequestVar('destcatid');
416 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
417 $this->batchMoveSelectDestination('item',$selected);
419 // On delete: check if confirmation has been given
420 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
421 $this->batchAskDeleteConfirmation('item',$selected);
425 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
426 echo '<h2>',_BATCH_ITEMS,'</h2>';
427 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
431 // walk over all itemids and perform action
432 foreach ($selected as $itemid) {
433 $itemid = intval($itemid);
434 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
436 // perform action, display errors if needed
439 $error = $this->deleteOneItem($itemid);
442 $error = $this->moveOneItem($itemid, $destCatid);
445 $error = _BATCH_UNKNOWN . i18n::hsc($action);
448 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
453 echo '<b>',_BATCH_DONE,'</b>';
461 * @todo document this
463 function action_batchcomment() {
466 // check if logged in
467 $member->isLoggedIn() or $this->disallow();
469 // more precise check will be done for each performed operation
471 // get array of itemids from request
472 $selected = requestIntArray('batch');
473 $action = requestVar('batchaction');
475 // Show error when no items were selected
476 if (!is_array($selected) || sizeof($selected) == 0)
477 $this->error(_BATCH_NOSELECTION);
479 // On delete: check if confirmation has been given
480 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
481 $this->batchAskDeleteConfirmation('comment',$selected);
485 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
486 echo '<h2>',_BATCH_COMMENTS,'</h2>';
487 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
490 // walk over all itemids and perform action
491 foreach ($selected as $commentid) {
492 $commentid = intval($commentid);
493 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
495 // perform action, display errors if needed
498 $error = $this->deleteOneComment($commentid);
501 $error = _BATCH_UNKNOWN . i18n::hsc($action);
504 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
509 echo '<b>',_BATCH_DONE,'</b>';
517 * @todo document this
519 function action_batchmember() {
522 // check if logged in and admin
523 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
525 // get array of itemids from request
526 $selected = requestIntArray('batch');
527 $action = requestVar('batchaction');
529 // Show error when no members selected
530 if (!is_array($selected) || sizeof($selected) == 0)
531 $this->error(_BATCH_NOSELECTION);
533 // On delete: check if confirmation has been given
534 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
535 $this->batchAskDeleteConfirmation('member',$selected);
539 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
540 echo '<h2>',_BATCH_MEMBERS,'</h2>';
541 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
544 // walk over all itemids and perform action
545 foreach ($selected as $memberid) {
546 $memberid = intval($memberid);
547 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
549 // perform action, display errors if needed
552 $error = $this->deleteOneMember($memberid);
556 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
560 // there should always remain at least one super-admin
561 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
562 if (sql_num_rows($r) < 2)
563 $error = _ERROR_ATLEASTONEADMIN;
565 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
568 $error = _BATCH_UNKNOWN . i18n::hsc($action);
571 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
576 echo '<b>',_BATCH_DONE,'</b>';
584 * @todo document this
586 function action_batchteam() {
589 $blogid = intRequestVar('blogid');
591 // check if logged in and admin
592 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
594 // get array of itemids from request
595 $selected = requestIntArray('batch');
596 $action = requestVar('batchaction');
598 // Show error when no members selected
599 if (!is_array($selected) || sizeof($selected) == 0)
600 $this->error(_BATCH_NOSELECTION);
602 // On delete: check if confirmation has been given
603 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
604 $this->batchAskDeleteConfirmation('team',$selected);
608 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
610 echo '<h2>',_BATCH_TEAM,'</h2>';
611 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
614 // walk over all itemids and perform action
615 foreach ($selected as $memberid) {
616 $memberid = intval($memberid);
617 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
619 // perform action, display errors if needed
622 $error = $this->deleteOneTeamMember($blogid, $memberid);
626 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
630 // there should always remain at least one admin
631 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
632 if (sql_num_rows($r) < 2)
633 $error = _ERROR_ATLEASTONEBLOGADMIN;
635 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
638 $error = _BATCH_UNKNOWN . i18n::hsc($action);
641 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
646 echo '<b>',_BATCH_DONE,'</b>';
654 * @todo document this
656 function action_batchcategory() {
657 global $member, $manager;
659 // check if logged in
660 $member->isLoggedIn() or $this->disallow();
662 // more precise check will be done for each performed operation
664 // get array of itemids from request
665 $selected = requestIntArray('batch');
666 $action = requestVar('batchaction');
668 // Show error when no items were selected
669 if (!is_array($selected) || sizeof($selected) == 0)
670 $this->error(_BATCH_NOSELECTION);
672 // On move: when no destination blog chosen, show choice now
673 $destBlogId = intRequestVar('destblogid');
674 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
675 $this->batchMoveCategorySelectDestination('category',$selected);
677 // On delete: check if confirmation has been given
678 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
679 $this->batchAskDeleteConfirmation('category',$selected);
683 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
684 echo '<h2>',BATCH_CATEGORIES,'</h2>';
685 echo '<p>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b></p>';
688 // walk over all itemids and perform action
689 foreach ($selected as $catid) {
690 $catid = intval($catid);
691 echo '<li>',_BATCH_EXECUTING,' <b>',i18n::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
693 // perform action, display errors if needed
696 $error = $this->deleteOneCategory($catid);
699 $error = $this->moveOneCategory($catid, $destBlogId);
702 $error = _BATCH_UNKNOWN . i18n::hsc($action);
705 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
710 echo '<b>',_BATCH_DONE,'</b>';
717 * @todo document this
719 function batchMoveSelectDestination($type, $ids) {
723 <h2><?php echo _MOVE_TITLE?></h2>
724 <form method="post" action="index.php"><div>
726 <input type="hidden" name="action" value="batch<?php echo $type?>" />
727 <input type="hidden" name="batchaction" value="move" />
729 $manager->addTicketHidden();
731 // insert selected item numbers
733 foreach ($ids as $id)
734 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
736 // show blog/category selection list
737 $this->selectBlogCategory('destcatid');
742 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
745 <?php $this->pagefoot();
750 * @todo document this
752 function batchMoveCategorySelectDestination($type, $ids) {
756 <h2><?php echo _MOVECAT_TITLE?></h2>
757 <form method="post" action="index.php"><div>
759 <input type="hidden" name="action" value="batch<?php echo $type?>" />
760 <input type="hidden" name="batchaction" value="move" />
762 $manager->addTicketHidden();
764 // insert selected item numbers
766 foreach ($ids as $id)
767 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
769 // show blog/category selection list
770 $this->selectBlog('destblogid');
775 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
778 <?php $this->pagefoot();
783 * @todo document this
785 function batchAskDeleteConfirmation($type, $ids) {
790 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
791 <form method="post" action="index.php"><div>
793 <input type="hidden" name="action" value="batch<?php echo $type?>" />
794 <?php $manager->addTicketHidden() ?>
795 <input type="hidden" name="batchaction" value="delete" />
796 <input type="hidden" name="confirmation" value="yes" />
797 <?php // insert selected item numbers
799 foreach ($ids as $id)
800 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
802 // add hidden vars for team & comment
805 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
807 if ($type == 'comment')
809 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
814 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
817 <?php $this->pagefoot();
823 * Inserts a HTML select element with choices for all categories to which the current
825 * @see function selectBlog
827 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
828 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
832 * Inserts a HTML select element with choices for all blogs to which the user has access
833 * mode = 'blog' => shows blognames and values are blogids
834 * mode = 'category' => show category names and values are catids
836 * @param $iForcedBlogInclude
837 * ID of a blog that always needs to be included, without checking if the
838 * member is on the blog team (-1 = none)
839 * @todo document parameters
841 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
842 global $member, $CONF;
844 // 0. get IDs of blogs to which member can post items (+ forced blog)
846 if ($iForcedBlogInclude != -1)
847 $aBlogIds[] = intval($iForcedBlogInclude);
849 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
850 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
852 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
853 $rblogids = sql_query($queryBlogs);
854 while ($o = sql_fetch_object($rblogids))
855 if ($o->bnumber != $iForcedBlogInclude)
856 $aBlogIds[] = intval($o->bnumber);
858 if (count($aBlogIds) == 0)
861 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
863 // 1. select blogs (we'll create optiongroups)
864 // (only select those blogs that have the user on the team)
865 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
866 $blogs = sql_query($queryBlogs);
867 if ($mode == 'category') {
868 if (sql_num_rows($blogs) > 1)
871 while ($oBlog = sql_fetch_object($blogs)) {
873 echo '<optgroup label="',i18n::hsc($oBlog->bname),'">';
875 // show selection to create new category when allowed/wanted
877 // check if allowed to do so
878 if ($member->blogAdminRights($oBlog->bnumber))
879 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
882 // 2. for each category in that blog
883 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
884 while ($oCat = sql_fetch_object($categories)) {
885 if ($oCat->catid == $selected)
886 $selectText = ' selected="selected" ';
889 echo '<option value="',$oCat->catid,'" ', $selectText,'>',i18n::hsc($oCat->cname),'</option>';
897 while ($oBlog = sql_fetch_object($blogs)) {
898 echo '<option value="',$oBlog->bnumber,'"';
899 if ($oBlog->bnumber == $selected)
900 echo ' selected="selected"';
901 echo'>',i18n::hsc($oBlog->bname),'</option>';
909 * @todo document this
911 function action_browseownitems() {
912 global $member, $manager, $CONF;
916 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
917 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
920 if (postVar('start'))
921 $start = intPostVar('start');
925 // amount of items to show
926 if (postVar('amount'))
927 $amount = intPostVar('amount');
929 $amount = intval($CONF['DefaultListSize']);
934 $search = postVar('search'); // search through items
936 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
937 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
938 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
941 $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) . '%"))';
943 $query .= ' ORDER BY itime DESC'
944 . " LIMIT $start,$amount";
946 $template['content'] = 'itemlist';
947 $template['now'] = time();
949 $manager->loadClass("ENCAPSULATE");
950 $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
951 $navList->showBatchList('item',$query,'table',$template);
958 * Show all the comments for a given item
961 function action_itemcommentlist($itemid = '') {
962 global $member, $manager, $CONF;
965 $itemid = intRequestVar('itemid');
967 // only allow if user is allowed to alter item
968 $member->canAlterItem($itemid) or $this->disallow();
970 $blogid = getBlogIdFromItemId($itemid);
975 if (postVar('start'))
976 $start = intPostVar('start');
980 // amount of items to show
981 if (postVar('amount'))
982 $amount = intPostVar('amount');
984 $amount = intval($CONF['DefaultListSize']);
989 $search = postVar('search');
991 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
992 echo '<h2>',_COMMENTS,'</h2>';
994 $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;
997 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
999 $query .= ' ORDER BY ctime ASC'
1000 . " LIMIT $start,$amount";
1002 $template['content'] = 'commentlist';
1003 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
1005 $manager->loadClass("ENCAPSULATE");
1006 $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
1007 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
1013 * Browse own comments
1015 function action_browseowncomments() {
1016 global $member, $manager, $CONF;
1019 if (postVar('start'))
1020 $start = intPostVar('start');
1024 // amount of items to show
1025 if (postVar('amount'))
1026 $amount = intPostVar('amount');
1028 $amount = intval($CONF['DefaultListSize']);
1033 $search = postVar('search');
1036 $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();
1039 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1041 $query .= ' ORDER BY ctime DESC'
1042 . " LIMIT $start,$amount";
1046 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1047 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
1049 $template['content'] = 'commentlist';
1050 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
1052 $manager->loadClass("ENCAPSULATE");
1053 $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
1054 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
1060 * Browse all comments for a weblog
1061 * @param int $blogid
1063 function action_blogcommentlist($blogid = '')
1065 global $member, $manager, $CONF;
1068 $blogid = intRequestVar('blogid');
1070 $blogid = intval($blogid);
1072 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
1075 if (postVar('start'))
1076 $start = intPostVar('start');
1080 // amount of items to show
1081 if (postVar('amount'))
1082 $amount = intPostVar('amount');
1084 $amount = intval($CONF['DefaultListSize']);
1089 $search = postVar('search'); // search through comments
1092 $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);
1095 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1098 $query .= ' ORDER BY ctime DESC'
1099 . " LIMIT $start,$amount";
1102 $blog =& $manager->getBlog($blogid);
1106 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1107 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1109 $template['content'] = 'commentlist';
1110 $template['canAddBan'] = $member->blogAdminRights($blogid);
1112 $manager->loadClass("ENCAPSULATE");
1113 $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1114 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1120 * Provide a page to item a new item to the given blog
1122 function action_createitem() {
1123 global $member, $manager;
1125 $blogid = intRequestVar('blogid');
1128 $member->teamRights($blogid) or $this->disallow();
1130 $memberid = $member->getID();
1132 $blog =& $manager->getBlog($blogid);
1136 // generate the add-item form
1137 $formfactory = new PAGEFACTORY($blogid);
1138 $formfactory->createAddForm('admin');
1144 * @todo document this
1146 function action_itemedit()
1148 global $member, $manager;
1150 $itemid = intRequestVar('itemid');
1152 // only allow if user is allowed to alter item
1153 $member->canAlterItem($itemid) or $this->disallow();
1155 $item =& $manager->getItem($itemid, 1, 1);
1156 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1158 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1160 if ($blog->convertBreaks())
1162 $item['body'] = removeBreaks($item['body']);
1163 $item['more'] = removeBreaks($item['more']);
1166 // form to edit blog items
1168 $formfactory = new PAGEFACTORY($blog->getID());
1169 $formfactory->createEditForm('admin', $item);
1174 * @todo document this
1176 function action_itemupdate() {
1177 global $member, $manager, $CONF;
1179 $itemid = intRequestVar('itemid');
1180 $catid = postVar('catid');
1182 // only allow if user is allowed to alter item
1183 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1185 $actiontype = postVar('actiontype');
1187 // delete actions are handled by itemdelete (which has confirmation)
1188 if ($actiontype == 'delete') {
1189 $this->action_itemdelete();
1193 $body = postVar('body');
1194 $title = postVar('title');
1195 $more = postVar('more');
1196 $closed = intPostVar('closed');
1197 $draftid = intPostVar('draftid');
1199 // default action = add now
1201 $actiontype='addnow';
1203 // create new category if needed
1204 if (strstr($catid,'newcat')) {
1206 list($blogid) = sscanf($catid,"newcat-%d");
1209 $blog =& $manager->getBlog($blogid);
1210 $catid = $blog->createNewCategory();
1212 // show error when sth goes wrong
1214 $this->doError(_ERROR_CATCREATEFAIL);
1218 set some variables based on actiontype
1221 draft items -> addnow, addfuture, adddraft, delete
1222 non-draft items -> edit, changedate, delete
1225 $timestamp: set to a nonzero value for future dates or date changes
1226 $wasdraft: set to 1 when the item used to be a draft item
1227 $publish: set to 1 when the edited item is not a draft
1229 $blogid = getBlogIDFromItemID($itemid);
1230 $blog =& $manager->getBlog($blogid);
1232 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1233 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1234 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1235 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1236 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1241 // edit the item for real
1242 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1244 $this->updateFuturePosted($blogid);
1247 // delete permission is checked inside ITEM::delete()
1248 ITEM::delete($draftid);
1251 // show category edit window when we created a new category
1252 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1253 if ($catid != intPostVar('catid')) {
1254 $this->action_categoryedit(
1257 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1260 // TODO: set start item correctly for itemlist
1261 $this->action_itemlist(getBlogIDFromItemID($itemid));
1266 * @todo document this
1268 function action_itemdelete() {
1269 global $member, $manager;
1271 $itemid = intRequestVar('itemid');
1273 // only allow if user is allowed to alter item
1274 $member->canAlterItem($itemid) or $this->disallow();
1276 if (!$manager->existsItem($itemid,1,1))
1277 $this->error(_ERROR_NOSUCHITEM);
1279 $item =& $manager->getItem($itemid,1,1);
1280 $title = i18n::hsc(strip_tags($item['title']));
1281 $body = strip_tags($item['body']);
1282 $body = i18n::hsc(shorten($body,300,'...'));
1286 <h2><?php echo _DELETE_CONFIRM?></h2>
1288 <p><?php echo _CONFIRMTXT_ITEM?></p>
1291 <b>"<?php echo $title ?>"</b>
1296 <form method="post" action="index.php"><div>
1297 <input type="hidden" name="action" value="itemdeleteconfirm" />
1298 <?php $manager->addTicketHidden() ?>
1299 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1300 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
1307 * @todo document this
1309 function action_itemdeleteconfirm() {
1312 $itemid = intRequestVar('itemid');
1314 // only allow if user is allowed to alter item
1315 $member->canAlterItem($itemid) or $this->disallow();
1318 $blogid = getBlogIdFromItemId($itemid);
1320 // delete item (note: some checks will be performed twice)
1321 $this->deleteOneItem($itemid);
1323 $this->action_itemlist($blogid);
1327 * Deletes one item and returns error if something goes wrong
1328 * @param int $itemid
1330 function deleteOneItem($itemid) {
1331 global $member, $manager;
1333 // only allow if user is allowed to alter item (also checks if itemid exists)
1334 if (!$member->canAlterItem($itemid))
1335 return _ERROR_DISALLOWED;
1337 // need to get blogid before the item is deleted
1338 $blogid = getBlogIDFromItemId($itemid);
1340 $manager->loadClass('ITEM');
1341 ITEM::delete($itemid);
1343 // update blog's futureposted
1344 $this->updateFuturePosted($blogid);
1348 * Update a blog's future posted flag
1349 * @param int $blogid
1351 function updateFuturePosted($blogid) {
1354 $blog =& $manager->getBlog($blogid);
1355 $currenttime = $blog->getCorrectTime(time());
1356 $result = sql_query("SELECT * FROM ".sql_table('item').
1357 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
1358 if (sql_num_rows($result) > 0) {
1359 $blog->setFuturePost();
1362 $blog->clearFuturePost();
1367 * @todo document this
1369 function action_itemmove() {
1370 global $member, $manager;
1372 $itemid = intRequestVar('itemid');
1374 // only allow if user is allowed to alter item
1375 $member->canAlterItem($itemid) or $this->disallow();
1377 $item =& $manager->getItem($itemid,1,1);
1381 <h2><?php echo _MOVE_TITLE?></h2>
1382 <form method="post" action="index.php"><div>
1383 <input type="hidden" name="action" value="itemmoveto" />
1384 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1388 $manager->addTicketHidden();
1389 $this->selectBlogCategory('catid',$item['catid'],10,1);
1392 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1399 * @todo document this
1401 function action_itemmoveto() {
1402 global $member, $manager;
1404 $itemid = intRequestVar('itemid');
1405 $catid = requestVar('catid');
1407 // create new category if needed
1408 if (strstr($catid,'newcat')) {
1410 list($blogid) = sscanf($catid,'newcat-%d');
1413 $blog =& $manager->getBlog($blogid);
1414 $catid = $blog->createNewCategory();
1416 // show error when sth goes wrong
1418 $this->doError(_ERROR_CATCREATEFAIL);
1421 // only allow if user is allowed to alter item
1422 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1424 $old_blogid = getBlogIDFromItemId($itemid);
1426 ITEM::move($itemid, $catid);
1428 // set the futurePosted flag on the blog
1429 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1431 // reset the futurePosted in case the item is moved from one blog to another
1432 $this->updateFuturePosted($old_blogid);
1434 if ($catid != intRequestVar('catid'))
1435 $this->action_categoryedit($catid, $blog->getID());
1437 $this->action_itemlist(getBlogIDFromCatID($catid));
1441 * Moves one item to a given category (category existance should be checked by caller)
1442 * errors are returned
1443 * @param int $itemid
1444 * @param int $destCatid category ID to which the item will be moved
1446 function moveOneItem($itemid, $destCatid) {
1449 // only allow if user is allowed to move item
1450 if (!$member->canUpdateItem($itemid, $destCatid))
1451 return _ERROR_DISALLOWED;
1453 ITEM::move($itemid, $destCatid);
1457 * Adds a item to the chosen blog
1459 function action_additem() {
1460 global $manager, $CONF;
1462 $manager->loadClass('ITEM');
1464 $result = ITEM::createFromRequest();
1466 if ($result['status'] == 'error')
1467 $this->error($result['message']);
1469 $blogid = getBlogIDFromItemID($result['itemid']);
1470 $blog =& $manager->getBlog($blogid);
1471 $btimestamp = $blog->getCorrectTime();
1472 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1474 if ($result['status'] == 'newcategory') {
1475 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1476 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1478 $methodName = 'action_itemList';
1479 call_user_func(array(&$this, $methodName), $blogid);
1484 * Allows to edit previously made comments
1486 function action_commentedit() {
1488 global $member, $manager;
1490 $commentid = intRequestVar('commentid');
1492 $member->canAlterComment($commentid) or $this->disallow();
1494 $comment = COMMENT::getComment($commentid);
1496 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1498 // change <br /> to \n
1499 $comment['body'] = str_replace('<br />', '', $comment['body']);
1501 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1502 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1504 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1509 <h2><?php echo _EDITC_TITLE?></h2>
1511 <form action="index.php" method="post"><div>
1513 <input type="hidden" name="action" value="commentupdate" />
1514 <?php $manager->addTicketHidden(); ?>
1515 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1517 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1519 <td><?php echo _EDITC_WHO?></td>
1521 <?php if ($comment['member'])
1522 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1524 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1528 <td><?php echo _EDITC_WHEN?></td>
1529 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1531 <td><?php echo _EDITC_HOST?></td>
1532 <td><?php echo $comment['host']; ?></td>
1535 <td><?php echo _EDITC_URL; ?></td>
1536 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1539 <td><?php echo _EDITC_EMAIL; ?></td>
1540 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1543 <td><?php echo _EDITC_TEXT?></td>
1545 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1546 echo $comment['body'];
1550 <td><?php echo _EDITC_EDIT?></td>
1551 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1560 * @todo document this
1562 function action_commentupdate() {
1563 global $member, $manager;
1565 $commentid = intRequestVar('commentid');
1567 $member->canAlterComment($commentid) or $this->disallow();
1569 $url = postVar('url');
1570 $email = postVar('email');
1571 $body = postVar('body');
1573 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1574 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1575 # important note that '\' must be matched with '\\\\' in preg* expressions
1577 // intercept words that are too long
1578 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1580 $this->error(_ERROR_COMMENT_LONGWORD);
1584 if (i18n::strlen($body) < 3)
1586 $this->error(_ERROR_COMMENT_NOCOMMENT);
1589 if (i18n::strlen($body) > 5000)
1591 $this->error(_ERROR_COMMENT_TOOLONG);
1595 $body = COMMENT::prepareBody($body);
1598 $manager->notify('PreUpdateComment',array('body' => &$body));
1600 $query = 'UPDATE ' . sql_table('comment')
1601 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1602 . " WHERE cnumber = " . $commentid;
1606 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1607 $o = sql_fetch_object($res);
1608 $itemid = $o->citem;
1610 if ($member->canAlterItem($itemid))
1611 $this->action_itemcommentlist($itemid);
1613 $this->action_browseowncomments();
1618 * @todo document this
1620 function action_commentdelete() {
1621 global $member, $manager;
1623 $commentid = intRequestVar('commentid');
1625 $member->canAlterComment($commentid) or $this->disallow();
1627 $comment = COMMENT::getComment($commentid);
1629 $body = strip_tags($comment['body']);
1630 $body = i18n::hsc(shorten($body, 300, '...'));
1632 if ($comment['member'])
1633 $author = $comment['member'];
1635 $author = $comment['user'];
1640 <h2><?php echo _DELETE_CONFIRM?></h2>
1642 <p><?php echo _CONFIRMTXT_COMMENT?></p>
1645 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
1647 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
1650 <form method="post" action="index.php"><div>
1651 <input type="hidden" name="action" value="commentdeleteconfirm" />
1652 <?php $manager->addTicketHidden() ?>
1653 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1654 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
1661 * @todo document this
1663 function action_commentdeleteconfirm() {
1666 $commentid = intRequestVar('commentid');
1668 // get item id first
1669 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1670 $o = sql_fetch_object($res);
1671 $itemid = $o->citem;
1673 $error = $this->deleteOneComment($commentid);
1675 $this->doError($error);
1677 if ($member->canAlterItem($itemid))
1678 $this->action_itemcommentlist($itemid);
1680 $this->action_browseowncomments();
1684 * @todo document this
1686 function deleteOneComment($commentid) {
1687 global $member, $manager;
1689 $commentid = intval($commentid);
1691 if (!$member->canAlterComment($commentid))
1692 return _ERROR_DISALLOWED;
1694 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1696 // delete the comments associated with the item
1697 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1700 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1706 * Usermanagement main
1708 function action_usermanagement() {
1709 global $member, $manager;
1712 $member->isAdmin() or $this->disallow();
1716 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1718 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1720 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1722 // show list of members with actions
1724 . ' FROM '.sql_table('member');
1725 $template['content'] = 'memberlist';
1726 $template['tabindex'] = 10;
1728 $manager->loadClass("ENCAPSULATE");
1729 $batch = new BATCH('member');
1730 $batch->showlist($query,'table',$template);
1732 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1734 <form method="post" action="index.php" name="memberedit"><div>
1736 <input type="hidden" name="action" value="memberadd" />
1737 <?php $manager->addTicketHidden() ?>
1741 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1743 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1744 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1746 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
1748 <td><?php echo _MEMBERS_REALNAME?></td>
1749 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1751 <td><?php echo _MEMBERS_PWD?></td>
1752 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1754 <td><?php echo _MEMBERS_REPPWD?></td>
1755 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1757 <td><?php echo _MEMBERS_EMAIL?></td>
1758 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1760 <td><?php echo _MEMBERS_URL?></td>
1761 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1763 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1764 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1766 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1767 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1769 <td><?php echo _MEMBERS_NOTES?></td>
1770 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1772 <td><?php echo _MEMBERS_NEW?></td>
1773 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1782 * Edit member settings
1784 function action_memberedit() {
1785 $this->action_editmembersettings(intRequestVar('memberid'));
1789 * @todo document this
1791 function action_editmembersettings($memberid = '') {
1792 global $member, $manager, $CONF;
1794 if ($memberid == '')
1796 $memberid = $member->getID();
1800 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1802 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1803 $this->pagehead($extrahead);
1805 // show message to go back to member overview (only for admins)
1806 if ($member->isAdmin())
1808 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1812 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1814 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1816 $mem = MEMBER::createFromID($memberid);
1818 <form method="post" action="index.php" name="memberedit"><div>
1820 <input type="hidden" name="action" value="changemembersettings" />
1821 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1822 <?php $manager->addTicketHidden() ?>
1825 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1827 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1828 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1831 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1832 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo i18n::hsc($mem->getDisplayName()); ?>" />
1834 echo i18n::hsc($member->getDisplayName());
1839 <td><?php echo _MEMBERS_REALNAME?></td>
1840 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo i18n::hsc($mem->getRealName()); ?>" /></td>
1842 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1843 <td><?php echo _MEMBERS_PWD?></td>
1844 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1846 <td><?php echo _MEMBERS_REPPWD?></td>
1847 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1850 <td><?php echo _MEMBERS_EMAIL?>
1851 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1853 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo i18n::hsc($mem->getEmail()); ?>" /></td>
1855 <td><?php echo _MEMBERS_URL?></td>
1856 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo i18n::hsc($mem->getURL()); ?>" /></td>
1857 <?php // only allow to change this by super-admins
1858 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1859 if ($member->isAdmin()) {
1862 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1863 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1865 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1866 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1869 <td><?php echo _MEMBERS_NOTES?></td>
1870 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo i18n::hsc($mem->getNotes()); ?>" /></td>
1872 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
1876 <select name="deflang" tabindex="85">
1878 $locales = i18n::get_available_locale_list();
1879 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
1881 echo "<option value=\"\" selected=\"selected\">" . i18n::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1885 echo "<option value=\"\">" . i18n::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1888 foreach( $locales as $locale )
1890 if( $locale == $mem->getLocale() )
1892 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
1896 echo "<option value=\"{$locale}\">{$locale}</option>\n";
1905 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
1906 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
1910 $this->_insertPluginOptions('member',$memberid);
1913 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1915 <td><?php echo _MEMBERS_EDIT?></td>
1916 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1922 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1925 'MemberSettingsFormExtras',
1934 * @todo document this
1936 function action_changemembersettings() {
1937 global $member, $CONF, $manager;
1939 $memberid = intRequestVar('memberid');
1942 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1944 $name = trim(strip_tags(postVar('name')));
1945 $realname = trim(strip_tags(postVar('realname')));
1946 $password = postVar('password');
1947 $repeatpassword = postVar('repeatpassword');
1948 $email = strip_tags(postVar('email'));
1949 $url = strip_tags(postVar('url'));
1951 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1952 # original eregi: !eregi("^https?://", $url)
1954 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
1955 if (!preg_match('#^https?://#', $url) )
1957 $url = 'http://' . $url;
1960 $admin = postVar('admin');
1961 $canlogin = postVar('canlogin');
1962 $notes = strip_tags(postVar('notes'));
1963 $locale = postVar('deflang');
1965 $mem = MEMBER::createFromID($memberid);
1967 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1969 if (!isValidDisplayName($name))
1970 $this->error(_ERROR_BADNAME);
1972 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1973 $this->error(_ERROR_NICKNAMEINUSE);
1975 if ($password != $repeatpassword)
1976 $this->error(_ERROR_PASSWORDMISMATCH);
1978 if ($password && (i18n::strlen($password) < 6))
1979 $this->error(_ERROR_PASSWORDTOOSHORT);
1984 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
1986 $this->error($pwderror);
1991 if ( !isValidMailAddress($email) )
1993 $this->error(_ERROR_BADMAILADDRESS);
1997 $this->error(_ERROR_REALNAMEMISSING);
1999 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2000 $this->error(_ERROR_NOSUCHLANGUAGE);
2002 // check if there will remain at least one site member with both the logon and admin rights
2003 // (check occurs when taking away one of these rights from such a member)
2004 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2005 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2008 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2009 if (sql_num_rows($r) < 2)
2010 $this->error(_ERROR_ATLEASTONEADMIN);
2013 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2014 $mem->setDisplayName($name);
2016 $mem->setPassword($password);
2019 $oldEmail = $mem->getEmail();
2021 $mem->setRealName($realname);
2022 $mem->setEmail($email);
2024 $mem->setNotes($notes);
2025 $mem->setLocale($locale);
2028 // only allow super-admins to make changes to the admin status
2029 if ($member->isAdmin()) {
2030 $mem->setAdmin($admin);
2031 $mem->setCanLogin($canlogin);
2034 $autosave = postVar ('autosave');
2035 $mem->setAutosave($autosave);
2039 // store plugin options
2040 $aOptions = requestArray('plugoption');
2041 NucleusPlugin::_applyPluginOptions($aOptions);
2042 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2044 // if email changed, generate new password
2045 if ($oldEmail != $mem->getEmail())
2047 $mem->sendActivationLink('addresschange', $oldEmail);
2049 $mem->newCookieKey();
2051 // only log out if the member being edited is the current member.
2052 if ($member->getID() == $memberid)
2054 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2059 if ( ( $mem->getID() == $member->getID() )
2060 && ( $mem->getDisplayName() != $member->getDisplayName() )
2062 $mem->newCookieKey();
2064 $this->action_login(_MSG_LOGINAGAIN, 0);
2066 $this->action_overview(_MSG_SETTINGSCHANGED);
2071 * @todo document this
2073 function action_memberadd() {
2074 global $member, $manager;
2077 $member->isAdmin() or $this->disallow();
2079 if (postVar('password') != postVar('repeatpassword'))
2080 $this->error(_ERROR_PASSWORDMISMATCH);
2081 if (i18n::strlen(postVar('password')) < 6)
2082 $this->error(_ERROR_PASSWORDTOOSHORT);
2084 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2088 // fire PostRegister event
2089 $newmem = new MEMBER();
2090 $newmem->readFromName(postVar('name'));
2091 $manager->notify('PostRegister',array('member' => &$newmem));
2093 $this->action_usermanagement();
2097 * Account activation
2101 function action_activate() {
2103 $key = getVar('key');
2104 $this->_showActivationPage($key);
2108 * @todo document this
2110 function _showActivationPage($key, $message = '')
2114 // clean up old activation keys
2115 MEMBER::cleanupActivationTable();
2117 // get activation info
2118 $info = MEMBER::getActivationInfo($key);
2121 $this->error(_ERROR_ACTIVATE);
2123 $mem = MEMBER::createFromId($info->vmember);
2126 $this->error(_ERROR_ACTIVATE);
2130 $bNeedsPasswordChange = true;
2132 switch ($info->vtype)
2135 $title = _ACTIVATE_FORGOT_TITLE;
2136 $text = _ACTIVATE_FORGOT_TEXT;
2139 $title = _ACTIVATE_REGISTER_TITLE;
2140 $text = _ACTIVATE_REGISTER_TEXT;
2142 case 'addresschange':
2143 $title = _ACTIVATE_CHANGE_TITLE;
2144 $text = _ACTIVATE_CHANGE_TEXT;
2145 $bNeedsPasswordChange = false;
2146 MEMBER::activate($key);
2151 'memberName' => i18n::hsc($mem->getDisplayName())
2153 $title = TEMPLATE::fill($title, $aVars);
2154 $text = TEMPLATE::fill($text, $aVars);
2158 echo '<h2>' , $title, '</h2>';
2159 echo '<p>' , $text, '</p>';
2163 echo '<p class="error">',$message,'</p>';
2166 if ($bNeedsPasswordChange)
2169 <div><form action="index.php" method="post">
2171 <input type="hidden" name="action" value="activatesetpwd" />
2172 <?php $manager->addTicketHidden() ?>
2173 <input type="hidden" name="key" value="<?php echo i18n::hsc($key) ?>" />
2176 <td><?php echo _MEMBERS_PWD?></td>
2177 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2179 <td><?php echo _MEMBERS_REPPWD?></td>
2180 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2184 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2188 <td><?php echo _MEMBERS_SETPWD ?></td>
2189 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2204 * Account activation - set password part
2208 function action_activatesetpwd() {
2210 $key = postVar('key');
2212 // clean up old activation keys
2213 MEMBER::cleanupActivationTable();
2215 // get activation info
2216 $info = MEMBER::getActivationInfo($key);
2218 if (!$info || ($info->type == 'addresschange'))
2219 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2221 $mem = MEMBER::createFromId($info->vmember);
2224 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2226 $password = postVar('password');
2227 $repeatpassword = postVar('repeatpassword');
2229 if ($password != $repeatpassword)
2230 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2232 if ($password && (i18n::strlen($password) < 6))
2233 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2239 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2241 return $this->_showActivationPage($key,$pwderror);
2247 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2249 return $this->_showActivationPage($key, $error);
2253 $mem->setPassword($password);
2256 // do the activation
2257 MEMBER::activate($key);
2260 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2261 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2268 function action_manageteam() {
2269 global $member, $manager;
2271 $blogid = intRequestVar('blogid');
2274 $member->blogAdminRights($blogid) or $this->disallow();
2278 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2280 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2282 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2286 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2287 . ' FROM '.sql_table('member').', '.sql_table('team')
2288 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2290 $template['content'] = 'teamlist';
2291 $template['tabindex'] = 10;
2293 $manager->loadClass("ENCAPSULATE");
2294 $batch = new BATCH('team');
2295 $batch->showlist($query, 'table', $template);
2298 <h3><?php echo _TEAM_ADDNEW?></h3>
2300 <form method='post' action='index.php'><div>
2302 <input type='hidden' name='action' value='teamaddmember' />
2303 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2304 <?php $manager->addTicketHidden() ?>
2307 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2308 <td><?php // TODO: try to make it so only non-team-members are listed
2309 $query = 'SELECT mname as text, mnumber as value'
2310 . ' FROM '.sql_table('member');
2312 $template['name'] = 'memberid';
2313 $template['tabindex'] = 10000;
2314 showlist($query,'select',$template);
2317 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2318 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2320 <td><?php echo _TEAM_ADD?></td>
2321 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2330 * Add member to team
2332 function action_teamaddmember() {
2333 global $member, $manager;
2335 $memberid = intPostVar('memberid');
2336 $blogid = intPostVar('blogid');
2337 $admin = intPostVar('admin');
2340 $member->blogAdminRights($blogid) or $this->disallow();
2342 $blog =& $manager->getBlog($blogid);
2343 if (!$blog->addTeamMember($memberid, $admin))
2344 $this->error(_ERROR_ALREADYONTEAM);
2346 $this->action_manageteam();
2351 * @todo document this
2353 function action_teamdelete() {
2354 global $member, $manager;
2356 $memberid = intRequestVar('memberid');
2357 $blogid = intRequestVar('blogid');
2360 $member->blogAdminRights($blogid) or $this->disallow();
2362 $teammem = MEMBER::createFromID($memberid);
2363 $blog =& $manager->getBlog($blogid);
2367 <h2><?php echo _DELETE_CONFIRM?></h2>
2369 <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>
2373 <form method="post" action="index.php"><div>
2374 <input type="hidden" name="action" value="teamdeleteconfirm" />
2375 <?php $manager->addTicketHidden() ?>
2376 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2377 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2378 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2385 * @todo document this
2387 function action_teamdeleteconfirm() {
2390 $memberid = intRequestVar('memberid');
2391 $blogid = intRequestVar('blogid');
2393 $error = $this->deleteOneTeamMember($blogid, $memberid);
2395 $this->error($error);
2398 $this->action_manageteam();
2402 * @todo document this
2404 function deleteOneTeamMember($blogid, $memberid) {
2405 global $member, $manager;
2407 $blogid = intval($blogid);
2408 $memberid = intval($memberid);
2411 if (!$member->blogAdminRights($blogid))
2412 return _ERROR_DISALLOWED;
2414 // check if: - there remains at least one blog admin
2415 // - (there remains at least one team member)
2416 $tmem = MEMBER::createFromID($memberid);
2418 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2420 if ($tmem->isBlogAdmin($blogid)) {
2421 // check if there are more blog members left and at least one admin
2422 // (check for at least two admins before deletion)
2423 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2424 $r = sql_query($query);
2425 if (sql_num_rows($r) < 2)
2426 return _ERROR_ATLEASTONEBLOGADMIN;
2429 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2432 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2438 * @todo document this
2440 function action_teamchangeadmin() {
2443 $blogid = intRequestVar('blogid');
2444 $memberid = intRequestVar('memberid');
2447 $member->blogAdminRights($blogid) or $this->disallow();
2449 $mem = MEMBER::createFromID($memberid);
2451 // don't allow when there is only one admin at this moment
2452 if ($mem->isBlogAdmin($blogid)) {
2453 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2454 if (sql_num_rows($r) == 1)
2455 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2458 if ($mem->isBlogAdmin($blogid))
2463 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2466 // only show manageteam if member did not change its own admin privileges
2467 if ($member->isBlogAdmin($blogid))
2468 $this->action_manageteam();
2470 $this->action_overview(_MSG_ADMINCHANGED);
2474 * @todo document this
2476 function action_blogsettings() {
2477 global $member, $manager;
2479 $blogid = intRequestVar('blogid');
2482 $member->blogAdminRights($blogid) or $this->disallow();
2484 $blog =& $manager->getBlog($blogid);
2486 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2487 $this->pagehead($extrahead);
2489 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2491 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2493 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2495 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
2497 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2498 $aMemberNames = array();
2499 while ($o = sql_fetch_object($res))
2500 array_push($aMemberNames, i18n::hsc($o->mname) . ' (' . i18n::hsc($o->mrealname). ')');
2501 echo implode(',', $aMemberNames);
2508 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2511 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2513 <form method="post" action="index.php"><div>
2515 <input type="hidden" name="action" value="blogsettingsupdate" />
2516 <?php $manager->addTicketHidden() ?>
2517 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2519 <td><?php echo _EBLOG_NAME?></td>
2520 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo i18n::hsc($blog->getName()) ?>" /></td>
2522 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2523 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2525 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo i18n::hsc($blog->getShortName()) ?>" /></td>
2527 <td><?php echo _EBLOG_DESC?></td>
2528 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo i18n::hsc($blog->getDescription()) ?>" /></td>
2530 <td><?php echo _EBLOG_URL?></td>
2531 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo i18n::hsc($blog->getURL()) ?>" /></td>
2533 <td><?php echo _EBLOG_DEFSKIN?>
2534 <?php help('blogdefaultskin'); ?>
2538 $query = 'SELECT sdname as text, sdnumber as value'
2539 . ' FROM '.sql_table('skin_desc');
2540 $template['name'] = 'defskin';
2541 $template['selected'] = $blog->getDefaultSkin();
2542 $template['tabindex'] = 50;
2543 showlist($query,'select',$template);
2548 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2550 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2552 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2554 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2556 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2558 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2560 <td><?php echo _EBLOG_ANONYMOUS?>
2562 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2564 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2566 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2568 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2569 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo i18n::hsc($blog->getNotifyAddress()); ?>" /></td>
2571 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2573 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2574 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2575 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2577 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2578 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2579 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2581 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2582 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2583 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2586 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2587 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo i18n::hsc($blog->getMaxComments()); ?>" /></td>
2589 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2590 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo i18n::hsc($blog->getUpdateFile()) ?>" /></td>
2592 <td><?php echo _EBLOG_DEFCAT?></td>
2595 $query = 'SELECT cname as text, catid as value'
2596 . ' FROM '.sql_table('category')
2597 . ' WHERE cblog=' . $blog->getID();
2598 $template['name'] = 'defcat';
2599 $template['selected'] = $blog->getDefaultCategory();
2600 $template['tabindex'] = 110;
2601 showlist($query,'select',$template);
2605 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2606 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
2607 <br /><?php echo _EBLOG_BTIME?> <b><?php echo i18n::strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2609 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo i18n::hsc($blog->getTimeOffset()); ?>" /></td>
2611 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2612 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2616 $this->_insertPluginOptions('blog',$blogid);
2619 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2621 <td><?php echo _EBLOG_CHANGE?></td>
2622 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2627 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2631 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2632 $template['content'] = 'categorylist';
2633 $template['tabindex'] = 200;
2635 $manager->loadClass("ENCAPSULATE");
2636 $batch = new BATCH('category');
2637 $batch->showlist($query,'table',$template);
2642 <form action="index.php" method="post"><div>
2643 <input name="action" value="categorynew" type="hidden" />
2644 <?php $manager->addTicketHidden() ?>
2645 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2648 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2650 <td><?php echo _EBLOG_CAT_NAME?></td>
2651 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2653 <td><?php echo _EBLOG_CAT_DESC?></td>
2654 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2656 <td><?php echo _EBLOG_CAT_CREATE?></td>
2657 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2664 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2667 'BlogSettingsFormExtras',
2677 * @todo document this
2679 function action_categorynew() {
2680 global $member, $manager;
2682 $blogid = intRequestVar('blogid');
2684 $member->blogAdminRights($blogid) or $this->disallow();
2686 $cname = postVar('cname');
2687 $cdesc = postVar('cdesc');
2689 if (!isValidCategoryName($cname))
2690 $this->error(_ERROR_BADCATEGORYNAME);
2692 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2693 $res = sql_query($query);
2694 if (sql_num_rows($res) > 0)
2695 $this->error(_ERROR_DUPCATEGORYNAME);
2697 $blog =& $manager->getBlog($blogid);
2698 $newCatID = $blog->createNewCategory($cname, $cdesc);
2700 $this->action_blogsettings();
2704 * @todo document this
2706 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2707 global $member, $manager;
2710 $blogid = intGetVar('blogid');
2712 $blogid = intval($blogid);
2714 $catid = intGetVar('catid');
2716 $catid = intval($catid);
2718 $member->blogAdminRights($blogid) or $this->disallow();
2720 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2721 $obj = sql_fetch_object($res);
2723 $cname = $obj->cname;
2724 $cdesc = $obj->cdesc;
2726 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2727 $this->pagehead($extrahead);
2729 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2732 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo i18n::hsc($cname)?>'</h2>
2733 <form method='post' action='index.php'><div>
2734 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2735 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2736 <input name="desturl" type="hidden" value="<?php echo i18n::hsc($desturl) ?>" />
2737 <input name="action" type="hidden" value="categoryupdate" />
2738 <?php $manager->addTicketHidden(); ?>
2741 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2743 <td><?php echo _EBLOG_CAT_NAME?></td>
2744 <td><input type="text" name="cname" value="<?php echo i18n::hsc($cname)?>" size="40" maxlength="40" /></td>
2746 <td><?php echo _EBLOG_CAT_DESC?></td>
2747 <td><input type="text" name="cdesc" value="<?php echo i18n::hsc($cdesc)?>" size="40" maxlength="200" /></td>
2750 // insert plugin options
2751 $this->_insertPluginOptions('category',$catid);
2754 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2756 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2757 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2766 * @todo document this
2768 function action_categoryupdate() {
2769 global $member, $manager;
2771 $blogid = intPostVar('blogid');
2772 $catid = intPostVar('catid');
2773 $cname = postVar('cname');
2774 $cdesc = postVar('cdesc');
2775 $desturl = postVar('desturl');
2777 $member->blogAdminRights($blogid) or $this->disallow();
2779 if (!isValidCategoryName($cname))
2780 $this->error(_ERROR_BADCATEGORYNAME);
2782 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2783 $res = sql_query($query);
2784 if (sql_num_rows($res) > 0)
2785 $this->error(_ERROR_DUPCATEGORYNAME);
2787 $query = 'UPDATE '.sql_table('category').' SET'
2788 . " cname='" . sql_real_escape_string($cname) . "',"
2789 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
2790 . " WHERE catid=" . $catid;
2794 // store plugin options
2795 $aOptions = requestArray('plugoption');
2796 NucleusPlugin::_applyPluginOptions($aOptions);
2797 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2804 $this->action_blogsettings();
2809 * @todo document this
2811 function action_categorydelete() {
2812 global $member, $manager;
2814 $blogid = intRequestVar('blogid');
2815 $catid = intRequestVar('catid');
2817 $member->blogAdminRights($blogid) or $this->disallow();
2819 $blog =& $manager->getBlog($blogid);
2821 // check if the category is valid
2822 if (!$blog->isValidCategory($catid))
2823 $this->error(_ERROR_NOSUCHCATEGORY);
2825 // don't allow deletion of default category
2826 if ($blog->getDefaultCategory() == $catid)
2827 $this->error(_ERROR_DELETEDEFCATEGORY);
2829 // check if catid is the only category left for blogid
2830 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2831 $res = sql_query($query);
2832 if (sql_num_rows($res) == 1)
2833 $this->error(_ERROR_DELETELASTCATEGORY);
2838 <h2><?php echo _DELETE_CONFIRM?></h2>
2841 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo i18n::hsc($blog->getCategoryName($catid))?></b>
2844 <form method="post" action="index.php"><div>
2845 <input type="hidden" name="action" value="categorydeleteconfirm" />
2846 <?php $manager->addTicketHidden() ?>
2847 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2848 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2849 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2856 * @todo document this
2858 function action_categorydeleteconfirm() {
2859 global $member, $manager;
2861 $blogid = intRequestVar('blogid');
2862 $catid = intRequestVar('catid');
2864 $member->blogAdminRights($blogid) or $this->disallow();
2866 $error = $this->deleteOneCategory($catid);
2868 $this->error($error);
2870 $this->action_blogsettings();
2874 * @todo document this
2876 function deleteOneCategory($catid) {
2877 global $manager, $member;
2879 $catid = intval($catid);
2881 $blogid = getBlogIDFromCatID($catid);
2883 if (!$member->blogAdminRights($blogid))
2884 return ERROR_DISALLOWED;
2887 $blog =& $manager->getBlog($blogid);
2889 // check if the category is valid
2890 if (!$blog || !$blog->isValidCategory($catid))
2891 return _ERROR_NOSUCHCATEGORY;
2893 $destcatid = $blog->getDefaultCategory();
2895 // don't allow deletion of default category
2896 if ($blog->getDefaultCategory() == $catid)
2897 return _ERROR_DELETEDEFCATEGORY;
2899 // check if catid is the only category left for blogid
2900 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2901 $res = sql_query($query);
2902 if (sql_num_rows($res) == 1)
2903 return _ERROR_DELETELASTCATEGORY;
2905 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2907 // change category for all items to the default category
2908 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2911 // delete all associated plugin options
2912 NucleusPlugin::_deleteOptionValues('category', $catid);
2915 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2918 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2923 * @todo document this
2925 function moveOneCategory($catid, $destblogid) {
2926 global $manager, $member;
2928 $catid = intval($catid);
2929 $destblogid = intval($destblogid);
2931 $blogid = getBlogIDFromCatID($catid);
2933 // mover should have admin rights on both blogs
2934 if (!$member->blogAdminRights($blogid))
2935 return _ERROR_DISALLOWED;
2936 if (!$member->blogAdminRights($destblogid))
2937 return _ERROR_DISALLOWED;
2939 // cannot move to self
2940 if ($blogid == $destblogid)
2941 return _ERROR_MOVETOSELF;
2944 $blog =& $manager->getBlog($blogid);
2945 $destblog =& $manager->getBlog($destblogid);
2947 // check if the category is valid
2948 if (!$blog || !$blog->isValidCategory($catid))
2949 return _ERROR_NOSUCHCATEGORY;
2951 // don't allow default category to be moved
2952 if ($blog->getDefaultCategory() == $catid)
2953 return _ERROR_MOVEDEFCATEGORY;
2959 'sourceblog' => &$blog,
2960 'destblog' => &$destblog
2964 // update comments table (cblog)
2965 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
2966 $items = sql_query($query);
2967 while ($oItem = sql_fetch_object($items)) {
2968 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
2971 // update items (iblog)
2972 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
2976 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
2983 'sourceblog' => &$blog,
2984 'destblog' => $destblog
2991 * @todo document this
2993 function action_blogsettingsupdate()
2995 global $member, $manager;
2997 $blogid = intRequestVar('blogid');
2999 $member->blogAdminRights($blogid) or $this->disallow();
3001 $blog =& $manager->getBlog($blogid);
3003 $notify = trim(postVar('notify'));
3004 $shortname = trim(postVar('shortname'));
3005 $updatefile = trim(postVar('update'));
3007 $notifyComment = intPostVar('notifyComment');
3008 $notifyVote = intPostVar('notifyVote');
3009 $notifyNewItem = intPostVar('notifyNewItem');
3011 if ($notifyComment == 0)
3015 if ($notifyVote == 0)
3019 if ($notifyNewItem == 0)
3023 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
3027 $not = new NOTIFICATION($notify);
3028 if (!$not->validAddresses())
3030 $this->error(_ERROR_BADNOTIFY);
3034 if (!isValidShortName($shortname))
3036 $this->error(_ERROR_BADSHORTBLOGNAME);
3039 if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
3041 $this->error(_ERROR_DUPSHORTBLOGNAME);
3043 // check if update file is writable
3044 if ($updatefile && !is_writeable($updatefile))
3046 $this->error(_ERROR_UPDATEFILE);
3049 $blog->setName(trim(postVar('name')));
3050 $blog->setShortName($shortname);
3051 $blog->setNotifyAddress($notify);
3052 $blog->setNotifyType($notifyType);
3053 $blog->setMaxComments(postVar('maxcomments'));
3054 $blog->setCommentsEnabled(postVar('comments'));
3055 $blog->setTimeOffset(postVar('timeoffset'));
3056 $blog->setUpdateFile($updatefile);
3057 $blog->setURL(trim(postVar('url')));
3058 $blog->setDefaultSkin(intPostVar('defskin'));
3059 $blog->setDescription(trim(postVar('desc')));
3060 $blog->setPublic(postVar('public'));
3061 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3062 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3063 $blog->setDefaultCategory(intPostVar('defcat'));
3064 $blog->setSearchable(intPostVar('searchable'));
3065 $blog->setEmailRequired(intPostVar('reqemail'));
3066 $blog->writeSettings();
3068 // store plugin options
3069 $aOptions = requestArray('plugoption');
3070 NucleusPlugin::_applyPluginOptions($aOptions);
3071 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3073 $this->action_overview(_MSG_SETTINGSCHANGED);
3077 * @todo document this
3079 function action_deleteblog() {
3080 global $member, $CONF, $manager;
3082 $blogid = intRequestVar('blogid');
3084 $member->blogAdminRights($blogid) or $this->disallow();
3086 // check if blog is default blog
3087 if ($CONF['DefaultBlog'] == $blogid)
3088 $this->error(_ERROR_DELDEFBLOG);
3090 $blog =& $manager->getBlog($blogid);
3094 <h2><?php echo _DELETE_CONFIRM?></h2>
3096 <p><?php echo _WARNINGTXT_BLOGDEL?>
3100 <?php echo _CONFIRMTXT_BLOG?><b><?php echo i18n::hsc($blog->getName())?></b>
3103 <form method="post" action="index.php"><div>
3104 <input type="hidden" name="action" value="deleteblogconfirm" />
3105 <?php $manager->addTicketHidden() ?>
3106 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3107 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3114 * @todo document this
3116 function action_deleteblogconfirm() {
3117 global $member, $CONF, $manager;
3119 $blogid = intRequestVar('blogid');
3121 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3123 $member->blogAdminRights($blogid) or $this->disallow();
3125 // check if blog is default blog
3126 if ($CONF['DefaultBlog'] == $blogid)
3127 $this->error(_ERROR_DELDEFBLOG);
3129 // delete all comments
3130 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3134 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3137 // delete all team members
3138 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3142 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3145 // delete all categories
3146 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3149 // delete all associated plugin options
3150 NucleusPlugin::_deleteOptionValues('blog', $blogid);
3152 // delete the blog itself
3153 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3156 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3158 $this->action_overview(_DELETED_BLOG);
3162 * @todo document this
3164 function action_memberdelete() {
3165 global $member, $manager;
3167 $memberid = intRequestVar('memberid');
3169 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3171 $mem = MEMBER::createFromID($memberid);
3175 <h2><?php echo _DELETE_CONFIRM?></h2>
3177 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo i18n::hsc($mem->getDisplayName()) ?></b>
3181 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3184 <form method="post" action="index.php"><div>
3185 <input type="hidden" name="action" value="memberdeleteconfirm" />
3186 <?php $manager->addTicketHidden() ?>
3187 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3188 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3195 * @todo document this
3197 function action_memberdeleteconfirm() {
3200 $memberid = intRequestVar('memberid');
3202 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3204 $error = $this->deleteOneMember($memberid);
3206 $this->error($error);
3208 if ($member->isAdmin())
3209 $this->action_usermanagement();
3211 $this->action_overview(_DELETED_MEMBER);
3216 * @todo document this
3218 function deleteOneMember($memberid) {
3221 $memberid = intval($memberid);
3222 $mem = MEMBER::createFromID($memberid);
3224 if (!$mem->canBeDeleted())
3225 return _ERROR_DELETEMEMBER;
3227 $manager->notify('PreDeleteMember', array('member' => &$mem));
3229 /* unlink comments from memberid */
3231 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())
3232 .'" WHERE cmember='.$memberid;
3236 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3239 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3242 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3245 // delete all associated plugin options
3246 NucleusPlugin::_deleteOptionValues('member', $memberid);
3248 $manager->notify('PostDeleteMember', array('member' => &$mem));
3254 * @todo document this
3256 function action_createnewlog() {
3257 global $member, $CONF, $manager;
3259 // Only Super-Admins can do this
3260 $member->isAdmin() or $this->disallow();
3264 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3266 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3268 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3270 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3272 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3275 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3276 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3279 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3282 <?php echo _EBLOG_CREATE_TEXT?>
3285 <form method="post" action="index.php"><div>
3287 <input type="hidden" name="action" value="addnewlog" />
3288 <?php $manager->addTicketHidden() ?>
3292 <td><?php echo _EBLOG_NAME?></td>
3293 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3295 <td><?php echo _EBLOG_SHORTNAME?>
3296 <?php help('shortblogname'); ?>
3298 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3300 <td><?php echo _EBLOG_DESC?></td>
3301 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3303 <td><?php echo _EBLOG_DEFSKIN?>
3304 <?php help('blogdefaultskin'); ?>
3308 $query = 'SELECT sdname as text, sdnumber as value'
3309 . ' FROM '.sql_table('skin_desc');
3310 $template['name'] = 'defskin';
3311 $template['tabindex'] = 50;
3312 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3313 showlist($query,'select',$template);
3317 <td><?php echo _EBLOG_OFFSET?>
3318 <?php help('blogtimeoffset'); ?>
3319 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
3321 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3323 <td><?php echo _EBLOG_ADMIN?>
3324 <?php help('teamadmin'); ?>
3326 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3328 <td><?php echo _EBLOG_CREATE?></td>
3329 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3338 * @todo document this
3340 function action_addnewlog() {
3341 global $member, $manager, $CONF;
3343 // Only Super-Admins can do this
3344 $member->isAdmin() or $this->disallow();
3346 $bname = trim(postVar('name'));
3347 $bshortname = trim(postVar('shortname'));
3348 $btimeoffset = postVar('timeoffset');
3349 $bdesc = trim(postVar('desc'));
3350 $bdefskin = postVar('defskin');
3352 if (!isValidShortName($bshortname))
3353 $this->error(_ERROR_BADSHORTBLOGNAME);
3355 if ($manager->existsBlog($bshortname))
3356 $this->error(_ERROR_DUPSHORTBLOGNAME);
3362 'shortname' => &$bshortname,
3363 'timeoffset' => &$btimeoffset,
3364 'description' => &$bdesc,
3365 'defaultskin' => &$bdefskin
3370 // add slashes for sql queries
3371 $bname = sql_real_escape_string($bname);
3372 $bshortname = sql_real_escape_string($bshortname);
3373 $btimeoffset = sql_real_escape_string($btimeoffset);
3374 $bdesc = sql_real_escape_string($bdesc);
3375 $bdefskin = sql_real_escape_string($bdefskin);
3378 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3380 $blogid = sql_insert_id();
3381 $blog =& $manager->getBlog($blogid);
3383 // create new category
3384 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3385 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3386 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3387 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3388 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3389 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3390 $catid = sql_insert_id();
3392 // set as default category
3393 $blog->setDefaultCategory($catid);
3394 $blog->writeSettings();
3396 // create team member
3397 $memberid = $member->getID();
3398 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3401 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3402 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3404 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3405 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3420 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3421 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3428 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3430 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, i18n::hsc($bname)) ?></p>
3433 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, i18n::hsc($bshortname)) ?></a></li>
3434 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3437 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, i18n::hsc($bshortname)) ?></a></h3>
3439 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, i18n::hsc($bshortname)) ?></p>
3442 $CONF['Self'] = '<b><?php echo i18n::hsc($bshortname)?>.php</b>';
3444 include('<i>./config.php</i>');
3446 selectBlog('<b><?php echo i18n::hsc($bshortname)?></b>');
3451 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3453 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3455 <form action="index.php" method="post"><div>
3456 <input type="hidden" name="action" value="addnewlog2" />
3457 <?php $manager->addTicketHidden() ?>
3458 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3460 <td><?php echo _EBLOG_URL?></td>
3461 <td><input name="url" maxlength="100" size="40" value="<?php echo i18n::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3463 <td><?php echo _EBLOG_CREATE?></td>
3464 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3468 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3470 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3472 <form action="index.php" method="post"><div>
3473 <input type="hidden" name="action" value="addnewlog2" />
3474 <?php $manager->addTicketHidden() ?>
3475 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3477 <td><?php echo _EBLOG_URL?></td>
3478 <td><input name="url" maxlength="100" size="40" /></td>
3480 <td><?php echo _EBLOG_CREATE?></td>
3481 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3485 <?php $this->pagefoot();
3490 * @todo document this
3492 function action_addnewlog2() {
3493 global $member, $manager;
3495 $member->blogAdminRights($blogid) or $this->disallow();
3497 $burl = requestVar('url');
3498 $blogid = intRequestVar('blogid');
3500 $blog =& $manager->getBlog($blogid);
3501 $blog->setURL(trim($burl));
3502 $blog->writeSettings();
3504 $this->action_overview(_MSG_NEWBLOG);
3508 * @todo document this
3510 function action_skinieoverview() {
3511 global $member, $DIR_LIBS, $manager;
3513 $member->isAdmin() or $this->disallow();
3515 // load skinie class
3516 include_once($DIR_LIBS . 'skinie.php');
3520 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3523 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3525 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3526 <?php global $DIR_SKINS;
3528 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3530 if (sizeof($candidates) > 0) {
3532 <form method="post" action="index.php"><div>
3533 <input type="hidden" name="action" value="skinieimport" />
3534 <?php $manager->addTicketHidden() ?>
3535 <input type="hidden" name="mode" value="file" />
3536 <select name="skinfile" id="skinie_import_local">
3537 <?php foreach ($candidates as $skinname => $skinfile) {
3538 $html = i18n::hsc($skinfile);
3539 echo '<option value="',$html,'">',$skinname,'</option>';
3543 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3546 echo _SKINIE_NOCANDIDATES;
3551 <p><em><?php echo _OR?></em></p>
3553 <form method="post" action="index.php"><p>
3554 <?php $manager->addTicketHidden() ?>
3555 <input type="hidden" name="action" value="skinieimport" />
3556 <input type="hidden" name="mode" value="url" />
3557 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3558 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3559 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3563 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3564 <form method="post" action="index.php"><div>
3565 <input type="hidden" name="action" value="skinieexport" />
3566 <?php $manager->addTicketHidden() ?>
3568 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3571 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3573 <?php // show list of skins
3574 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3575 while ($skinObj = sql_fetch_object($res)) {
3576 $id = 'skinexp' . $skinObj->sdnumber;
3577 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3578 echo '<label for="',$id,'">',i18n::hsc($skinObj->sdname),'</label></td>';
3579 echo '<td>',i18n::hsc($skinObj->sddesc),'</td>';
3583 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3585 // show list of templates
3586 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3587 while ($templateObj = sql_fetch_object($res)) {
3588 $id = 'templateexp' . $templateObj->tdnumber;
3589 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3590 echo '<label for="',$id,'">',i18n::hsc($templateObj->tdname),'</label></td>';
3591 echo '<td>',i18n::hsc($templateObj->tddesc),'</td>';
3596 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3598 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3600 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3602 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3612 * @todo document this
3614 function action_skinieimport() {
3615 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3617 $member->isAdmin() or $this->disallow();
3619 // load skinie class
3620 include_once($DIR_LIBS . 'skinie.php');
3622 $skinFileRaw= postVar('skinfile');
3623 $mode = postVar('mode');
3625 $importer = new SKINIMPORT();
3627 // get full filename
3628 if ($mode == 'file')
3630 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3632 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3633 if (!file_exists($skinFile))
3634 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3636 $skinFile = $skinFileRaw;
3639 // read only metadata
3640 $error = $importer->readFile($skinFile, 1);
3643 $skinNameClashes = $importer->checkSkinNameClashes();
3644 $templateNameClashes = $importer->checkTemplateNameClashes();
3645 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3647 if ($error) $this->error($error);
3651 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3653 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3656 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo i18n::hsc($importer->getInfo())?></p></li>
3657 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3658 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3660 if ($hasNameClashes)
3663 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3664 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3666 } // if (hasNameClashes)
3670 <form method="post" action="index.php"><div>
3671 <input type="hidden" name="action" value="skiniedoimport" />
3672 <?php $manager->addTicketHidden() ?>
3673 <input type="hidden" name="skinfile" value="<?php echo i18n::hsc(postVar('skinfile'))?>" />
3674 <input type="hidden" name="mode" value="<?php echo i18n::hsc($mode)?>" />
3675 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3677 if ($hasNameClashes)
3681 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3683 } // if (hasNameClashes)
3693 * @todo document this
3695 function action_skiniedoimport() {
3696 global $member, $DIR_LIBS, $DIR_SKINS;
3698 $member->isAdmin() or $this->disallow();
3700 // load skinie class
3701 include_once($DIR_LIBS . 'skinie.php');
3703 $skinFileRaw= postVar('skinfile');
3704 $mode = postVar('mode');
3706 $allowOverwrite = intPostVar('overwrite');
3708 // get full filename
3709 if ($mode == 'file')
3711 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3713 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3714 if (!file_exists($skinFile))
3715 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3718 $skinFile = $skinFileRaw;
3721 $importer = new SKINIMPORT();
3723 $error = $importer->readFile($skinFile);
3726 $this->error($error);
3728 $error = $importer->writeToDatabase($allowOverwrite);
3731 $this->error($error);
3735 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3737 <h2><?php echo _SKINIE_DONE?></h2>
3740 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo i18n::hsc($importer->getInfo())?></p></li>
3741 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3742 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3745 <?php $this->pagefoot();
3750 * @todo document this
3752 function action_skinieexport() {
3753 global $member, $DIR_LIBS;
3755 $member->isAdmin() or $this->disallow();
3757 // load skinie class
3758 include_once($DIR_LIBS . 'skinie.php');
3760 $aSkins = requestIntArray('skin');
3761 $aTemplates = requestIntArray('template');
3763 if (!is_array($aTemplates)) $aTemplates = array();
3764 if (!is_array($aSkins)) $aSkins = array();
3766 $skinList = array_keys($aSkins);
3767 $templateList = array_keys($aTemplates);
3769 $info = postVar('info');
3771 $exporter = new SKINEXPORT();
3772 foreach ($skinList as $skinId) {
3773 $exporter->addSkin($skinId);
3775 foreach ($templateList as $templateId) {
3776 $exporter->addTemplate($templateId);
3778 $exporter->setInfo($info);
3780 $exporter->export();
3784 * @todo document this
3786 function action_templateoverview() {
3787 global $member, $manager;
3789 $member->isAdmin() or $this->disallow();
3793 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3795 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3796 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3798 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3799 $template['content'] = 'templatelist';
3800 $template['tabindex'] = 10;
3801 showlist($query,'table',$template);
3803 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3806 <form method="post" action="index.php"><div>
3808 <input name="action" value="templatenew" type="hidden" />
3809 <?php $manager->addTicketHidden() ?>
3811 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3812 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3814 <td><?php echo _TEMPLATE_DESC?></td>
3815 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3817 <td><?php echo _TEMPLATE_CREATE?></td>
3818 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3828 * @todo document this
3830 function action_templateedit($msg = '') {
3831 global $member, $manager;
3833 $templateid = intRequestVar('templateid');
3835 $member->isAdmin() or $this->disallow();
3837 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3838 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
3840 $this->pagehead($extrahead);
3842 $templatename = TEMPLATE::getNameFromId($templateid);
3843 $templatedescription = TEMPLATE::getDesc($templateid);
3844 $template =& $manager->getTemplate($templatename);
3848 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3851 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo i18n::hsc($templatename); ?>'</h2>
3853 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3856 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3858 <form method="post" action="index.php">
3861 <input type="hidden" name="action" value="templateupdate" />
3862 <?php $manager->addTicketHidden() ?>
3863 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3866 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3868 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3869 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo i18n::hsc($templatename) ?>" /></td>
3871 <td><?php echo _TEMPLATE_DESC?></td>
3872 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo i18n::hsc($templatedescription) ?>" /></td>
3874 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3876 <td><?php echo _TEMPLATE_UPDATE?></td>
3878 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3879 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3882 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3883 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3884 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3885 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3886 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3887 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3888 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3891 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3892 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3893 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3894 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3895 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3896 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3897 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3898 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3901 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3903 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3906 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3907 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3910 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3911 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3912 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3913 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3916 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3917 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3918 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3919 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3922 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3923 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
3924 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
3925 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
3928 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3929 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
3930 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
3931 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
3932 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
3933 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
3936 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3937 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
3938 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
3939 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
3942 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3943 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
3944 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
3947 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
3950 $pluginfields = array();
3951 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
3953 foreach ($pluginfields as $pfkey=>$pfvalue) {
3955 echo '<th colspan="2">' . i18n::hen($pfkey) . "</th>\n";
3956 foreach ($pfvalue as $pffield=>$pfdesc) {
3957 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
3962 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3964 <td><?php echo _TEMPLATE_UPDATE?></td>
3966 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3967 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3978 * @todo document this
3980 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3982 if (!isset($template[$name])) $template[$name] = '';
3985 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3986 <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>
3991 * @todo document this
3993 function action_templateupdate() {
3994 global $member,$manager;
3996 $templateid = intRequestVar('templateid');
3998 $member->isAdmin() or $this->disallow();
4000 $name = postVar('tname');
4001 $desc = postVar('tdesc');
4003 if (!isValidTemplateName($name))
4004 $this->error(_ERROR_BADTEMPLATENAME);
4006 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
4007 $this->error(_ERROR_DUPTEMPLATENAME);
4010 $name = sql_real_escape_string($name);
4011 $desc = sql_real_escape_string($desc);
4013 // 1. Remove all template parts
4014 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4017 // 2. Update description
4018 $query = 'UPDATE '.sql_table('template_desc').' SET'
4019 . " tdname='" . $name . "',"
4020 . " tddesc='" . $desc . "'"
4021 . " WHERE tdnumber=" . $templateid;
4024 // 3. Add non-empty template parts
4025 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4026 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4027 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4028 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4029 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4030 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4031 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4032 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4033 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4034 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4035 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4036 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4037 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4038 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4039 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4040 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4041 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4042 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4043 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4044 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4045 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4046 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4047 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4048 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4049 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4050 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4051 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4052 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4053 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4054 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4055 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4056 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4057 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4058 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4060 $pluginfields = array();
4061 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4062 foreach ($pluginfields as $pfkey=>$pfvalue) {
4063 foreach ($pfvalue as $pffield=>$pfdesc) {
4064 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4068 // jump back to template edit
4069 $this->action_templateedit(_TEMPLATE_UPDATED);
4074 * @todo document this
4076 function addToTemplate($id, $partname, $content) {
4077 $partname = sql_real_escape_string($partname);
4078 $content = sql_real_escape_string($content);
4082 // don't add empty parts:
4083 if (!trim($content)) return -1;
4085 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
4086 . "VALUES ($id, '$partname', '$content')";
4087 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4088 return sql_insert_id();
4092 * @todo document this
4094 function action_templatedelete() {
4095 global $member, $manager;
4097 $member->isAdmin() or $this->disallow();
4099 $templateid = intRequestVar('templateid');
4100 // TODO: check if template can be deleted
4104 $name = TEMPLATE::getNameFromId($templateid);
4105 $desc = TEMPLATE::getDesc($templateid);
4108 <h2><?php echo _DELETE_CONFIRM?></h2>
4111 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo i18n::hsc($name)?></b> (<?php echo i18n::hsc($desc) ?>)
4114 <form method="post" action="index.php"><div>
4115 <input type="hidden" name="action" value="templatedeleteconfirm" />
4116 <?php $manager->addTicketHidden() ?>
4117 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4118 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4125 * @todo document this
4127 function action_templatedeleteconfirm() {
4128 global $member, $manager;
4130 $templateid = intRequestVar('templateid');
4132 $member->isAdmin() or $this->disallow();
4134 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4136 // 1. delete description
4137 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4140 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4142 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4144 $this->action_templateoverview();
4148 * @todo document this
4150 function action_templatenew() {
4153 $member->isAdmin() or $this->disallow();
4155 $name = postVar('name');
4156 $desc = postVar('desc');
4158 if (!isValidTemplateName($name))
4159 $this->error(_ERROR_BADTEMPLATENAME);
4161 if (TEMPLATE::exists($name))
4162 $this->error(_ERROR_DUPTEMPLATENAME);
4164 $newTemplateId = TEMPLATE::createNew($name, $desc);
4166 $this->action_templateoverview();
4170 * @todo document this
4172 function action_templateclone() {
4175 $templateid = intRequestVar('templateid');
4177 $member->isAdmin() or $this->disallow();
4179 // 1. read old template
4180 $name = TEMPLATE::getNameFromId($templateid);
4181 $desc = TEMPLATE::getDesc($templateid);
4183 // 2. create desc thing
4184 $name = "cloned" . $name;
4186 // if a template with that name already exists:
4187 if (TEMPLATE::exists($name)) {
4189 while (TEMPLATE::exists($name . $i))
4194 $newid = TEMPLATE::createNew($name, $desc);
4197 // go through parts of old template and add them to the new one
4198 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4199 while ($o = sql_fetch_object($res)) {
4200 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4203 $this->action_templateoverview();
4207 * @todo document this
4209 function action_skinoverview() {
4210 global $member, $manager;
4212 $member->isAdmin() or $this->disallow();
4216 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4218 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4220 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4222 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4223 $template['content'] = 'skinlist';
4224 $template['tabindex'] = 10;
4225 showlist($query,'table',$template);
4227 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4230 <form method="post" action="index.php">
4233 <input name="action" value="skinnew" type="hidden" />
4234 <?php $manager->addTicketHidden() ?>
4236 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4237 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4239 <td><?php echo _SKIN_DESC?></td>
4240 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4242 <td><?php echo _SKIN_CREATE?></td>
4243 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4254 * @todo document this
4256 function action_skinnew() {
4259 $member->isAdmin() or $this->disallow();
4261 $name = trim(postVar('name'));
4262 $desc = trim(postVar('desc'));
4264 if (!isValidSkinName($name))
4265 $this->error(_ERROR_BADSKINNAME);
4267 if (SKIN::exists($name))
4268 $this->error(_ERROR_DUPSKINNAME);
4270 $newId = SKIN::createNew($name, $desc);
4272 $this->action_skinoverview();
4276 * @todo document this
4278 function action_skinedit() {
4279 global $member, $manager;
4281 $skinid = intRequestVar('skinid');
4283 $member->isAdmin() or $this->disallow();
4285 $skin = new SKIN($skinid);
4290 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4292 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4294 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4295 <?php echo _SKIN_PARTS_MSG?>
4297 <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>
4298 <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>
4299 <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>
4300 <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>
4301 <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>
4302 <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>
4303 <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>
4304 <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>
4309 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4310 $res = sql_query($query);
4312 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4313 echo '<form method="get" action="index.php">' . "\r\n";
4314 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4315 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4316 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4317 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4318 echo '</form>' . "\r\n";
4320 if ($res && sql_num_rows($res) > 0) {
4324 while ($row = sql_fetch_assoc($res)) {
4325 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>';
4333 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4334 <form method="post" action="index.php">
4337 <input type="hidden" name="action" value="skineditgeneral" />
4338 <?php $manager->addTicketHidden() ?>
4339 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4341 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4342 <td><input name="name" tabindex="90" value="<?php echo i18n::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
4344 <td><?php echo _SKIN_DESC?></td>
4345 <td><input name="desc" tabindex="100" value="<?php echo i18n::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4347 <td><?php echo _SKIN_TYPE?></td>
4348 <td><input name="type" tabindex="110" value="<?php echo i18n::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4350 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4351 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4353 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4354 <td><input name="inc_prefix" tabindex="130" value="<?php echo i18n::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4356 <td><?php echo _SKIN_CHANGE?></td>
4357 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4364 <?php $this->pagefoot();
4368 * @todo document this
4370 function action_skineditgeneral() {
4373 $skinid = intRequestVar('skinid');
4375 $member->isAdmin() or $this->disallow();
4377 $name = postVar('name');
4378 $desc = postVar('desc');
4379 $type = postVar('type');
4380 $inc_mode = postVar('inc_mode');
4381 $inc_prefix = postVar('inc_prefix');
4383 $skin = new SKIN($skinid);
4386 if (!isValidSkinName($name))
4387 $this->error(_ERROR_BADSKINNAME);
4389 if (($skin->getName() != $name) && SKIN::exists($name))
4390 $this->error(_ERROR_DUPSKINNAME);
4392 if (!$type) $type = 'text/html';
4393 if (!$inc_mode) $inc_mode = 'normal';
4395 // 2. Update description
4396 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4398 $this->action_skinedit();
4403 * @todo document this
4405 function action_skinedittype($msg = '') {
4406 global $member, $manager;
4408 $skinid = intRequestVar('skinid');
4409 $type = requestVar('type');
4411 $member->isAdmin() or $this->disallow();
4413 $type = trim($type);
4414 $type = strtolower($type);
4416 if (!isValidShortName($type)) {
4417 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4420 $skin = new SKIN($skinid);
4422 $friendlyNames = SKIN::getFriendlyNames();
4426 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4428 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo i18n::hsc($skin->getName()) ?>': <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4430 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4434 <form method="post" action="index.php">
4437 <input type="hidden" name="action" value="skinupdate" />
4438 <?php $manager->addTicketHidden() ?>
4439 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4440 <input type="hidden" name="type" value="<?php echo $type ?>" />
4442 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4443 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4444 (skin type: <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4445 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4446 help('skinpart' . $type);
4448 help('skinpartspecial');
4452 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo i18n::hsc($skin->getContent($type)) ?></textarea>
4455 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4456 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4457 (skin type: <?php echo i18n::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4460 <?php echo _SKIN_ALLOWEDVARS?>
4461 <?php $actions = SKIN::getAllowedActionsForType($type);
4465 while ($current = array_shift($actions)) {
4466 // skip deprecated vars
4467 if ($current == 'ifcat') continue;
4468 if ($current == 'imagetext') continue;
4469 if ($current == 'vars') continue;
4471 echo helplink('skinvar-' . $current) . "$current</a>";
4472 if (count($actions) != 0) echo ", ";
4474 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
4475 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4476 showlist($query,'table',array('content'=>'shortblognames'));
4477 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
4478 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4479 showlist($query,'table',array('content'=>'shortnames'));
4480 echo '</div></form>';
4485 * @todo document this
4487 function action_skinupdate() {
4490 $skinid = intRequestVar('skinid');
4491 $content = trim(postVar('content'));
4492 $type = postVar('type');
4494 $member->isAdmin() or $this->disallow();
4496 $skin = new SKIN($skinid);
4497 $skin->update($type, $content);
4499 $this->action_skinedittype(_SKIN_UPDATED);
4503 * @todo document this
4505 function action_skindelete() {
4506 global $member, $manager, $CONF;
4508 $skinid = intRequestVar('skinid');
4510 $member->isAdmin() or $this->disallow();
4512 // don't allow default skin to be deleted
4513 if ($skinid == $CONF['BaseSkin'])
4514 $this->error(_ERROR_DEFAULTSKIN);
4516 // don't allow deletion of default skins for blogs
4517 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4518 $r = sql_query($query);
4519 if ($o = sql_fetch_object($r))
4520 $this->error(_ERROR_SKINDEFDELETE . i18n::hsc($o->bname));
4524 $skin = new SKIN($skinid);
4525 $name = $skin->getName();
4526 $desc = $skin->getDescription();
4529 <h2><?php echo _DELETE_CONFIRM?></h2>
4532 <?php echo _CONFIRMTXT_SKIN?><b><?php echo i18n::hsc($name) ?></b> (<?php echo i18n::hsc($desc)?>)
4535 <form method="post" action="index.php"><div>
4536 <input type="hidden" name="action" value="skindeleteconfirm" />
4537 <?php $manager->addTicketHidden() ?>
4538 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4539 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4546 * @todo document this
4548 function action_skindeleteconfirm() {
4549 global $member, $CONF, $manager;
4551 $skinid = intRequestVar('skinid');
4553 $member->isAdmin() or $this->disallow();
4555 // don't allow default skin to be deleted
4556 if ($skinid == $CONF['BaseSkin'])
4557 $this->error(_ERROR_DEFAULTSKIN);
4559 // don't allow deletion of default skins for blogs
4560 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4561 $r = sql_query($query);
4562 if ($o = sql_fetch_object($r))
4563 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4565 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4567 // 1. delete description
4568 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4571 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4573 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4575 $this->action_skinoverview();
4579 * @todo document this
4581 function action_skinremovetype() {
4582 global $member, $manager, $CONF;
4584 $skinid = intRequestVar('skinid');
4585 $skintype = requestVar('type');
4587 if (!isValidShortName($skintype)) {
4588 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4591 $member->isAdmin() or $this->disallow();
4593 // don't allow default skinparts to be deleted
4594 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4595 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4600 $skin = new SKIN($skinid);
4601 $name = $skin->getName();
4602 $desc = $skin->getDescription();
4605 <h2><?php echo _DELETE_CONFIRM?></h2>
4608 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo i18n::hsc($skintype); ?> (<?php echo i18n::hsc($name); ?>)</b> (<?php echo i18n::hsc($desc)?>)
4611 <form method="post" action="index.php"><div>
4612 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4613 <?php $manager->addTicketHidden() ?>
4614 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4615 <input type="hidden" name="type" value="<?php echo i18n::hsc($skintype); ?>" />
4616 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4623 * @todo document this
4625 function action_skinremovetypeconfirm() {
4626 global $member, $CONF, $manager;
4628 $skinid = intRequestVar('skinid');
4629 $skintype = requestVar('type');
4631 if (!isValidShortName($skintype)) {
4632 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4635 $member->isAdmin() or $this->disallow();
4637 // don't allow default skinparts to be deleted
4638 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4639 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4642 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4645 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4647 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4649 $this->action_skinedit();
4653 * @todo document this
4655 function action_skinclone() {
4658 $skinid = intRequestVar('skinid');
4660 $member->isAdmin() or $this->disallow();
4662 // 1. read skin to clone
4663 $skin = new SKIN($skinid);
4665 $name = "clone_" . $skin->getName();
4667 // if a skin with that name already exists:
4668 if (SKIN::exists($name)) {
4670 while (SKIN::exists($name . $i))
4675 // 2. create skin desc
4676 $newid = SKIN::createNew(
4678 $skin->getDescription(),
4679 $skin->getContentType(),
4680 $skin->getIncludeMode(),
4681 $skin->getIncludePrefix()
4687 $this->skinclonetype($skin, $newid, 'index');
4688 $this->skinclonetype($skin, $newid, 'item');
4689 $this->skinclonetype($skin, $newid, 'archivelist');
4690 $this->skinclonetype($skin, $newid, 'archive');
4691 $this->skinclonetype($skin, $newid, 'search');
4692 $this->skinclonetype($skin, $newid, 'error');
4693 $this->skinclonetype($skin, $newid, 'member');
4694 $this->skinclonetype($skin, $newid, 'imagepopup');
4697 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4698 $res = sql_query($query);
4699 while ($row = sql_fetch_assoc($res)) {
4700 $this->skinclonetype($skin, $newid, $row['stype']);
4703 $this->action_skinoverview();
4708 * @todo document this
4710 function skinclonetype($skin, $newid, $type) {
4711 $newid = intval($newid);
4712 $content = $skin->getContent($type);
4714 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
4720 * @todo document this
4722 function action_settingsedit() {
4723 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4725 $member->isAdmin() or $this->disallow();
4729 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4732 <h2><?php echo _SETTINGS_TITLE?></h2>
4734 <form action="index.php" method="post">
4737 <input type="hidden" name="action" value="settingsupdate" />
4738 <?php $manager->addTicketHidden() ?>
4741 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4743 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4746 $query = 'SELECT bname as text, bnumber as value'
4747 . ' FROM '.sql_table('blog');
4748 $template['name'] = 'DefaultBlog';
4749 $template['selected'] = $CONF['DefaultBlog'];
4750 $template['tabindex'] = 10;
4751 showlist($query,'select',$template);
4755 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4758 $query = 'SELECT sdname as text, sdnumber as value'
4759 . ' FROM '.sql_table('skin_desc');
4760 $template['name'] = 'BaseSkin';
4761 $template['selected'] = $CONF['BaseSkin'];
4762 $template['tabindex'] = 1;
4763 showlist($query,'select',$template);
4767 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4768 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo i18n::hsc($CONF['AdminEmail']) ?>" /></td>
4770 <td><?php echo _SETTINGS_SITENAME?></td>
4771 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo i18n::hsc($CONF['SiteName']) ?>" /></td>
4773 <td><?php echo _SETTINGS_SITEURL?></td>
4774 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo i18n::hsc($CONF['IndexURL']) ?>" /></td>
4776 <td><?php echo _SETTINGS_ADMINURL?></td>
4777 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo i18n::hsc($CONF['AdminURL']) ?>" /></td>
4779 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4780 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo i18n::hsc($CONF['PluginURL']) ?>" /></td>
4782 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4783 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo i18n::hsc($CONF['SkinsURL']) ?>" /></td>
4785 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4786 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo i18n::hsc($CONF['ActionURL']) ?>" /></td>
4788 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
4791 <select name="Language" tabindex="10050">
4793 $locales = i18n::get_available_locale_list();
4794 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4796 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4800 echo "<option value=\"\">en_Latn_US</option>\n";
4803 foreach ( $locales as $locale )
4805 if ( $locale == 'en_Latn_US' )
4809 if ( $locale == i18n::get_current_locale() )
4811 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4815 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4823 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4825 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4827 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo i18n::hsc($CONF['DisableSiteURL'])?>" />
4830 <td><?php echo _SETTINGS_DIRS?></td>
4831 <td><?php echo i18n::hsc($DIR_NUCLEUS) ?>
4832 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4834 <td><?php echo _SETTINGS_DBLOGIN?></td>
4835 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4839 echo _SETTINGS_JSTOOLBAR
4840 /* =_SETTINGS_DISABLEJS
4842 I temporary changed the meaning of DisableJsTools, until I can find a good
4843 way to select the javascript version to use
4847 1 : all javascript disabled
4848 2 : 'simpler' javascript (for mozilla/opera/mac)
4852 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4853 <select name="DisableJsTools" tabindex="10075">
4854 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4855 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4856 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4857 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4858 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4859 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4864 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4867 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4868 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4870 echo ' ', _SETTINGS_URLMODE_HELP;
4876 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
4879 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
4885 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
4888 if (!array_key_exists('DefaultListSize',$CONF)) {
4889 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
4890 $CONF['DefaultListSize'] = 10;
4893 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo i18n::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
4896 <td><?php echo _SETTINGS_ADMINCSS?>
4900 <select name="AdminCSS" tabindex="10080">
4901 <?php // show a dropdown list of all available admin css files
4902 global $DIR_NUCLEUS;
4904 $dirhandle = opendir($DIR_NUCLEUS."styles/");
4906 while ($filename = readdir($dirhandle) )
4909 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
4910 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
4912 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
4915 $name = $matches[1];
4916 echo "<option value=\"$name\"";
4918 if ($name == $CONF['AdminCSS'])
4920 echo " selected=\"selected\"";
4923 echo ">$name</option>";
4929 closedir($dirhandle);
4936 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4938 <td><?php echo _SETTINGS_MEDIADIR?></td>
4939 <td><?php echo i18n::hsc($DIR_MEDIA) ?>
4940 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4941 <?php if (!is_dir($DIR_MEDIA))
4942 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4943 if (!is_readable($DIR_MEDIA))
4944 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4945 if (!is_writeable($DIR_MEDIA))
4946 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4950 <td><?php echo _SETTINGS_MEDIAURL?></td>
4952 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo i18n::hsc($CONF['MediaURL']) ?>" />
4955 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4956 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4958 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4960 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo i18n::hsc($CONF['AllowedTypes']) ?>" />
4963 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4965 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo i18n::hsc($CONF['MaxUploadSize']) ?>" />
4968 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4969 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4972 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4974 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4975 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4977 <td><?php echo _SETTINGS_ALLOWCREATE?>
4978 <?php help('allowaccountcreation'); ?>
4980 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4983 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4984 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4986 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4989 <td><?php echo _SETTINGS_MEMBERMSGS?>
4990 <?php help('messageservice'); ?>
4992 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
4995 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
4996 <?php help('messageservice'); ?>
4998 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5001 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
5002 <?php help('protectmemnames'); ?>
5004 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5010 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
5012 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
5013 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo i18n::hsc($CONF['CookiePrefix'])?>" /></td>
5015 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
5016 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo i18n::hsc($CONF['CookieDomain'])?>" /></td>
5018 <td><?php echo _SETTINGS_COOKIEPATH?></td>
5019 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo i18n::hsc($CONF['CookiePath'])?>" /></td>
5021 <td><?php echo _SETTINGS_COOKIESECURE?></td>
5022 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5024 <td><?php echo _SETTINGS_COOKIELIFE?></td>
5025 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5026 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5029 <td><?php echo _SETTINGS_LASTVISIT?></td>
5030 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5035 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5037 <td><?php echo _SETTINGS_UPDATE?></td>
5038 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5045 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5048 'GeneralSettingsFormExtras',
5056 * @todo document this
5058 function action_settingsupdate() {
5059 global $member, $CONF;
5061 $member->isAdmin() or $this->disallow();
5063 // check if email address for admin is valid
5064 if ( !isValidMailAddress(postVar('AdminEmail')) )
5066 $this->error(_ERROR_BADMAILADDRESS);
5070 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5071 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5072 $this->updateConfig('IndexURL', postVar('IndexURL'));
5073 $this->updateConfig('AdminURL', postVar('AdminURL'));
5074 $this->updateConfig('PluginURL', postVar('PluginURL'));
5075 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5076 $this->updateConfig('ActionURL', postVar('ActionURL'));
5077 $this->updateConfig('Language', postVar('Language'));
5078 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5079 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5080 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5081 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5082 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5083 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5084 $this->updateConfig('SiteName', postVar('SiteName'));
5085 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5086 $this->updateConfig('DisableSite', postVar('DisableSite'));
5087 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5088 $this->updateConfig('LastVisit', postVar('LastVisit'));
5089 $this->updateConfig('MediaURL', postVar('MediaURL'));
5090 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5091 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5092 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5093 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5094 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5095 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5096 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5097 $this->updateConfig('CookiePath', postVar('CookiePath'));
5098 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5099 $this->updateConfig('URLMode', postVar('URLMode'));
5100 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5101 $this->updateConfig('DebugVars', postVar('DebugVars'));
5102 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5103 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5105 // load new config and redirect (this way, the new language will be used is necessary)
5106 // note that when changing cookie settings, this redirect might cause the user
5107 // to have to log in again.
5109 redirect($CONF['AdminURL'] . '?action=manage');
5114 * Give an overview over the used system
5116 function action_systemoverview() {
5117 global $member, $nucleus, $CONF;
5121 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5123 if ($member->isLoggedIn() && $member->isAdmin()) {
5125 // Information about the used PHP and MySQL installation
5126 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";
5128 // Version of PHP MySQL
5131 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5132 echo "\t</tr><tr>\n";
5133 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5134 echo "\t\t" . '<td>' . phpversion() . "</td>\n";
5135 echo "\t</tr><tr>\n";
5136 echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5137 echo "\t\t" . '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5141 // Important PHP settings
5144 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5145 echo "\t</tr><tr>\n";
5146 echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";
5147 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5148 echo "\t\t" . '<td>' . $mqg . "</td>\n";
5149 echo "\t</tr><tr>\n";
5150 echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";
5151 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5152 echo "\t\t" . '<td>' . $mqr . "</td>\n";
5153 echo "\t</tr><tr>\n";
5154 echo "\t\t" . '<td>register_globals' . "</td>\n";
5155 $rg = ini_get('register_globals') ? 'On' : 'Off';
5156 echo "\t\t" . '<td>' . $rg . "</td>\n";
5160 // Information about GD library
5161 $gdinfo = gd_info();
5164 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5166 foreach ($gdinfo as $key=>$value) {
5167 if (is_bool($value)) {
5168 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5170 $value = i18n::hsc($value);
5173 echo "\t\t" . '<td width="50%">' . $key . "</td>\n";
5174 echo "\t\t" . '<td>' . $value . "</td>\n";
5179 // Check if special modules are loaded
5181 phpinfo(INFO_MODULES);
5182 $im = ob_get_contents();
5186 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5187 echo "\t</tr><tr>\n";
5188 echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";
5189 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5190 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5191 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5192 echo "\t\t" . '<td>' . $modrewrite . "</td>\n";
5196 // Information about the used Nucleus CMS
5197 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5199 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5200 $np = getNucleusPatchLevel();
5203 echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";
5204 echo "\t</tr><tr>\n";
5205 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5206 echo "\t\t" . '<td>' . $nv . "</td>\n";
5207 echo "\t</tr><tr>\n";
5208 echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5209 echo "\t\t" . '<td>' . $np . "</td>\n";
5213 // Important settings of the installation
5216 echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5217 echo "\t</tr><tr>\n";
5218 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";
5219 echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";
5220 echo "\t</tr><tr>\n";
5221 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";
5222 echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";
5223 echo "\t</tr><tr>\n";
5224 echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5225 $ohs = $CONF['alertOnHeadersSent'] ?
5226 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5227 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5228 echo "\t\t" . '<td>' . $ohs . "</td>\n";
5232 // Link to the online version test at the Nucleus CMS website
5233 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5234 if ($nucleus['codename'] != '') {
5235 $codenamestring = ' "' . $nucleus['codename'] . '"';
5237 $codenamestring = '';
5239 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5240 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5241 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5242 echo 'Nucleus CMS ' . $nv . $codenamestring;
5247 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5254 * @todo document this
5256 function updateConfig($name, $val) {
5257 $name = sql_real_escape_string($name);
5258 $val = trim(sql_real_escape_string($val));
5260 $query = 'UPDATE '.sql_table('config')
5261 . " SET value='$val'"
5262 . " WHERE name='$name'";
5264 sql_query($query) or die("Query error: " . sql_error());
5265 return sql_insert_id();
5270 * @param string $msg message that will be shown
5272 function error($msg) {
5278 echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
5284 * @todo document this
5286 function disallow() {
5287 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5289 $this->error(_ERROR_DISALLOWED);
5293 * @todo document this
5295 function pagehead($extrahead = '') {
5296 global $member, $nucleus, $CONF, $manager;
5301 'extrahead' => &$extrahead,
5302 'action' => $this->action
5306 $baseUrl = i18n::hsc($CONF['AdminURL']);
5307 if (!array_key_exists('AdminCSS',$CONF))
5309 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5310 $CONF['AdminCSS'] = 'original';
5314 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5315 <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
5317 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo i18n::get_current_charset() ?>" />
5318 <title><?php echo i18n::hsc($CONF['SiteName'])?> - Admin</title>
5319 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin_<?php echo $CONF["AdminCSS"]?>.css" />
5320 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
5321 href="<?php echo $baseUrl?>styles/addedit.css" />
5323 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
5324 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
5325 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
5327 <meta http-equiv='Pragma' content='no-cache' />
5328 <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
5329 <meta http-equiv='Expires' content='-1' />
5331 <?php echo $extrahead?>
5334 <div id="adminwrapper">
5335 <div class="header">
5336 <h1><?php echo i18n::hsc($CONF['SiteName'])?></h1>
5338 <div id="container">
5340 <div class="loginname">
5341 <?php if ($member->isLoggedIn())
5342 echo _LOGGEDINAS . ' ' . $member->getDisplayName()
5343 ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
5344 . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5346 echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
5348 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
5352 $codenamestring = ($nucleus['codename']!='')? ' "'.$nucleus['codename'].'"':'';
5354 if ($member->isLoggedIn() && $member->isAdmin()) {
5355 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5356 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5357 $newestVersion = getLatestVersion();
5358 $newestCompare = str_replace('/','.',$newestVersion);
5359 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5360 if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {
5361 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE.'">'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.'</a>';
5364 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5371 * @todo document this
5373 function pagefoot() {
5374 global $action, $member, $manager;
5379 'action' => $this->action
5383 if ($member->isLoggedIn() && ($action != 'showlogin')) {
5385 <h2><?php echo _LOGOUT ?></h2>
5387 <li><a href="index.php?action=overview"><?php echo _BACKHOME?></a></li>
5388 <li><a href='index.php?action=logout'><?php echo _LOGOUT?></a></li>
5393 <a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> © 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>
5395 <a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>
5398 </div><!-- content -->
5400 <div id="quickmenu">
5402 <?php // ---- user settings ----
5403 if (($action != 'showlogin') && ($member->isLoggedIn())) {
5405 echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
5408 echo '<h2>',_QMENU_ADD,'</h2>';
5409 echo '<form method="get" action="index.php"><div>';
5410 echo '<input type="hidden" name="action" value="createitem" />';
5412 $showAll = requestVar('showall');
5413 if (($member->isAdmin()) && ($showAll == 'yes')) {
5414 // Super-Admins have access to all blogs! (no add item support though)
5415 $query = 'SELECT bnumber as value, bname as text'
5416 . ' FROM ' . sql_table('blog')
5417 . ' ORDER BY bname';
5419 $query = 'SELECT bnumber as value, bname as text'
5420 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5421 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5422 . ' ORDER BY bname';
5424 $template['name'] = 'blogid';
5425 $template['tabindex'] = 15000;
5426 $template['extra'] = _QMENU_ADD_SELECT;
5427 $template['selected'] = -1;
5428 $template['shorten'] = 10;
5429 $template['shortenel'] = '';
5430 $template['javascript'] = 'onchange="return form.submit()"';
5431 showlist($query,'select',$template);
5433 echo '</div></form>';
5435 echo '<h2>' . $member->getDisplayName(). '</h2>';
5437 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';
5438 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';
5439 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';
5445 // ---- general settings ----
5446 if ($member->isAdmin()) {
5448 echo '<h2>',_QMENU_MANAGE,'</h2>';
5451 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';
5452 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';
5453 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';
5454 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';
5455 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';
5456 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';
5457 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';
5460 echo '<h2>',_QMENU_LAYOUT,'</h2>';
5462 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';
5463 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';
5464 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';
5469 $aPluginExtras = array();
5473 'options' => &$aPluginExtras
5476 if (count($aPluginExtras) > 0)
5478 echo '<h2>', _QMENU_PLUGINS, '</h2>';
5480 foreach ($aPluginExtras as $aInfo)
5482 echo '<li><a href="'.i18n::hsc($aInfo['url']).'" title="'.i18n::hsc($aInfo['tooltip']).'">'.i18n::hsc($aInfo['title']).'</a></li>';
5487 } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
5489 echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
5491 // introduction text on login screen
5492 echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
5497 <!-- content / quickmenu container -->
5498 <div class="clear"></div> <!-- new -->
5501 <!-- adminwrapper --> <!-- new -->
5508 * @todo document this
5510 function action_regfile() {
5511 global $member, $CONF;
5513 $blogid = intRequestVar('blogid');
5515 $member->teamRights($blogid) or $this->disallow();
5517 // header-code stolen from phpMyAdmin
5518 // REGEDIT and bookmarklet code stolen from GreyMatter
5520 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5523 header('Content-Type: application/octetstream');
5524 header('Content-Disposition: filename="nucleus.reg"');
5525 header('Pragma: no-cache');
5526 header('Expires: 0');
5529 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5530 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5531 echo '"contexts"=hex:31';
5535 * @todo document this
5537 function action_bookmarklet() {
5538 global $member, $manager;
5540 $blogid = intRequestVar('blogid');
5542 $member->teamRights($blogid) or $this->disallow();
5544 $blog =& $manager->getBlog($blogid);
5545 $bm = getBookmarklet($blogid);
5549 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5553 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
5556 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
5559 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
5561 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
5564 <?php echo '<a href="' . i18n::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, i18n::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
5567 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
5570 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5571 $url = $manager->addTicketToUrl($url);
5573 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . i18n::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
5577 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
5580 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
5582 <?php echo _BOOKMARKLET_DELETEBAR ?>
5586 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
5590 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
5591 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
5592 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
5593 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
5594 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
5603 * @todo document this
5605 function action_actionlog() {
5606 global $member, $manager;
5608 $member->isAdmin() or $this->disallow();
5612 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5614 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5617 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5618 <p><a href="<?php echo i18n::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5620 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5622 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5623 $template['content'] = 'actionlist';
5624 $amount = showlist($query,'table',$template);
5631 * @todo document this
5633 function action_banlist() {
5634 global $member, $manager;
5636 $blogid = intRequestVar('blogid');
5638 $member->blogAdminRights($blogid) or $this->disallow();
5640 $blog =& $manager->getBlog($blogid);
5644 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5646 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5648 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5649 $template['content'] = 'banlist';
5650 $amount = showlist($query,'table',$template);
5655 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5656 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5664 * @todo document this
5666 function action_banlistdelete() {
5667 global $member, $manager;
5669 $blogid = intRequestVar('blogid');
5670 $iprange = requestVar('iprange');
5672 $member->blogAdminRights($blogid) or $this->disallow();
5674 $blog =& $manager->getBlog($blogid);
5675 $banBlogName = i18n::hsc($blog->getName());
5679 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5681 <form method="post" action="index.php">
5683 <h3><?php echo _BAN_IPRANGE?></h3>
5686 <?php echo _CONFIRMTXT_BAN?> <?php echo i18n::hsc($iprange) ?>
5687 <input name="iprange" type="hidden" value="<?php echo i18n::hsc($iprange)?>" />
5690 <h3><?php echo _BAN_BLOGS?></h3>
5693 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5694 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
5695 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
5697 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5700 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5703 <?php $manager->addTicketHidden() ?>
5704 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5705 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5714 * @todo document this
5716 function action_banlistdeleteconfirm() {
5717 global $member, $manager;
5719 $blogid = intPostVar('blogid');
5720 $allblogs = postVar('allblogs');
5721 $iprange = postVar('iprange');
5723 $member->blogAdminRights($blogid) or $this->disallow();
5728 if (BAN::removeBan($blogid, $iprange))
5729 array_push($deleted, $blogid);
5731 // get blogs fot which member has admin rights
5732 $adminblogs = $member->getAdminBlogs();
5733 foreach ($adminblogs as $blogje) {
5734 if (BAN::removeBan($blogje, $iprange))
5735 array_push($deleted, $blogje);
5739 if (sizeof($deleted) == 0)
5740 $this->error(_ERROR_DELETEBAN);
5744 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5745 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5746 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5749 foreach ($deleted as $delblog) {
5750 $b =& $manager->getBlog($delblog);
5751 echo "<li>" . i18n::hsc($b->getName()). "</li>";
5760 * @todo document this
5762 function action_banlistnewfromitem() {
5763 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5767 * @todo document this
5769 function action_banlistnew($blogid = '') {
5770 global $member, $manager;
5773 $blogid = intRequestVar('blogid');
5775 $ip = requestVar('ip');
5777 $member->blogAdminRights($blogid) or $this->disallow();
5779 $blog =& $manager->getBlog($blogid);
5783 <h2><?php echo _BAN_ADD_TITLE?></h2>
5786 <form method="post" action="index.php">
5788 <h3><?php echo _BAN_IPRANGE?></h3>
5790 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5793 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
5794 <?php echo _BAN_EXAMPLE_TEXT ?>
5800 $iprangeVal = i18n::hsc($ip);
5802 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
5803 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
5805 <input name="iprange" type="radio" value="custom" id="ip_custom" />
5806 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
5807 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
5810 echo "<input name='iprange' value='custom' type='hidden' />";
5811 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5816 <h3><?php echo _BAN_BLOGS?></h3>
5818 <p><?php echo _BAN_BLOGS_TEXT?></p>
5821 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5822 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo i18n::hsc($blog->getName())?>'</label>
5824 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5827 <h3><?php echo _BAN_REASON_TITLE?></h3>
5829 <p><?php echo _BAN_REASON_TEXT?></p>
5831 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5833 <h3><?php echo _BAN_ADD_TITLE?></h3>
5836 <input name="action" type="hidden" value="banlistadd" />
5837 <?php $manager->addTicketHidden() ?>
5838 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5843 <?php $this->pagefoot();
5847 * @todo document this
5849 function action_banlistadd() {
5852 $blogid = intPostVar('blogid');
5853 $allblogs = postVar('allblogs');
5854 $iprange = postVar('iprange');
5855 if ($iprange == "custom")
5856 $iprange = postVar('customiprange');
5857 $reason = postVar('reason');
5859 $member->blogAdminRights($blogid) or $this->disallow();
5861 // TODO: check IP range validity
5864 if (!BAN::addBan($blogid, $iprange, $reason))
5865 $this->error(_ERROR_ADDBAN);
5867 // get blogs fot which member has admin rights
5868 $adminblogs = $member->getAdminBlogs();
5870 foreach ($adminblogs as $blogje) {
5871 if (!BAN::addBan($blogje, $iprange, $reason))
5875 $this->error(_ERROR_ADDBAN);
5878 $this->action_banlist();
5883 * @todo document this
5885 function action_clearactionlog() {
5888 $member->isAdmin() or $this->disallow();
5892 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5896 * @todo document this
5898 function action_backupoverview() {
5899 global $member, $manager;
5901 $member->isAdmin() or $this->disallow();
5905 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5907 <h2><?php echo _BACKUPS_TITLE?></h2>
5909 <h3><?php echo _BACKUP_TITLE?></h3>
5911 <p><?php echo _BACKUP_INTRO?></p>
5913 <form method="post" action="index.php"><p>
5914 <input type="hidden" name="action" value="backupcreate" />
5915 <?php $manager->addTicketHidden() ?>
5917 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
5919 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
5921 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
5925 <div class="note"><?php echo _BACKUP_NOTE?></div>
5928 <h3><?php echo _RESTORE_TITLE?></h3>
5930 <div class="note"><?php echo _RESTORE_NOTE?></div>
5932 <p><?php echo _RESTORE_INTRO?></p>
5934 <form method="post" action="index.php" enctype="multipart/form-data"><p>
5935 <input type="hidden" name="action" value="backuprestore" />
5936 <?php $manager->addTicketHidden() ?>
5937 <input name="backup_file" type="file" tabindex="30" />
5939 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
5940 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
5941 <br /><?php echo _RESTORE_WARNING?>
5944 <?php $this->pagefoot();
5948 * @todo document this
5950 function action_backupcreate() {
5951 global $member, $DIR_LIBS;
5953 $member->isAdmin() or $this->disallow();
5955 // use compression ?
5956 $useGzip = intval(postVar('gzip'));
5958 include($DIR_LIBS . 'backup.php');
5960 // try to extend time limit
5961 // (creating/restoring dumps might take a while)
5962 @set_time_limit(1200);
5965 $bu->do_backup($useGzip);
5970 * @todo document this
5972 function action_backuprestore() {
5973 global $member, $DIR_LIBS;
5975 $member->isAdmin() or $this->disallow();
5977 if (intPostVar('letsgo') != 1)
5978 $this->error(_ERROR_BACKUP_NOTSURE);
5980 include($DIR_LIBS . 'backup.php');
5982 // try to extend time limit
5983 // (creating/restoring dumps might take a while)
5984 @set_time_limit(1200);
5987 $message = $bu->do_restore();
5989 $this->error($message);
5993 <h2><?php echo _RESTORE_COMPLETE?></h2>
5994 <?php $this->pagefoot();
5999 * @todo document this
6001 function action_pluginlist() {
6002 global $member, $manager;
6005 $member->isAdmin() or $this->disallow();
6009 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6011 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6013 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6016 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6018 $template['content'] = 'pluginlist';
6019 $template['tabindex'] = 10;
6020 showlist($query, 'table', $template);
6023 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
6025 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
6027 <form method="post" action="index.php"><div>
6028 <input type="hidden" name="action" value="pluginupdate" />
6029 <?php $manager->addTicketHidden() ?>
6030 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
6033 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
6036 // find a list of possibly non-installed plugins
6037 $candidates = array();
6039 global $DIR_PLUGINS;
6041 $dirhandle = opendir($DIR_PLUGINS);
6043 while ($filename = readdir($dirhandle) )
6046 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
6047 # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
6049 if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6052 $name = $matches[1];
6053 // only show in list when not yet installed
6054 $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
6056 if (sql_num_rows($res) == 0)
6058 array_push($candidates, $name);
6065 closedir($dirhandle);
6067 if (sizeof($candidates) > 0)
6070 <p><?php echo _PLUGS_ADD_TEXT?></p>
6072 <form method='post' action='index.php'><div>
6073 <input type='hidden' name='action' value='pluginadd' />
6074 <?php $manager->addTicketHidden() ?>
6075 <select name="filename" tabindex="30">
6077 foreach($candidates as $name)
6079 echo '<option value="NP_',$name,'">',i18n::hsc($name),'</option>';
6083 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
6090 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6098 * @todo document this
6100 function action_pluginhelp() {
6101 global $member, $manager, $DIR_PLUGINS, $CONF;
6104 $member->isAdmin() or $this->disallow();
6106 $plugid = intGetVar('plugid');
6108 if (!$manager->pidInstalled($plugid))
6109 $this->error(_ERROR_NOSUCHPLUGIN);
6111 $plugName = getPluginNameFromPid($plugid);
6115 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6117 echo '<h2>',_PLUGS_HELP_TITLE,': ',i18n::hsc($plugName),'</h2>';
6119 $plug =& $manager->getPlugin($plugName);
6120 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6122 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6123 @readfile($helpFile);
6125 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6126 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6134 * @todo document this
6136 function action_pluginadd() {
6137 global $member, $manager, $DIR_PLUGINS;
6140 $member->isAdmin() or $this->disallow();
6142 $name = postVar('filename');
6144 if ($manager->pluginInstalled($name))
6145 $this->error(_ERROR_DUPPLUGIN);
6146 if (!checkPlugin($name))
6147 $this->error(_ERROR_PLUGFILEERROR . ' (' . i18n::hsc($name) . ')');
6149 // get number of currently installed plugins
6150 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6151 $numCurrent = sql_num_rows($res);
6153 // plugin will be added as last one in the list
6154 $newOrder = $numCurrent + 1;
6163 // do this before calling getPlugin (in case the plugin id is used there)
6164 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6166 $iPid = sql_insert_id();
6168 $manager->clearCachedInfo('installedPlugins');
6170 // Load the plugin for condition checking and instalation
6171 $plugin =& $manager->getPlugin($name);
6173 // check if it got loaded (could have failed)
6176 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6177 $manager->clearCachedInfo('installedPlugins');
6178 $this->error(_ERROR_PLUGIN_LOAD);
6181 // check if plugin needs a newer Nucleus version
6182 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
6184 // uninstall plugin again...
6185 $this->deleteOnePlugin($plugin->getID());
6187 // ...and show error
6188 $this->error(_ERROR_NUCLEUSVERSIONREQ . i18n::hsc($plugin->getMinNucleusVersion()));
6191 // check if plugin needs a newer Nucleus version
6192 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
6194 // uninstall plugin again...
6195 $this->deleteOnePlugin($plugin->getID());
6197 // ...and show error
6198 $this->error(_ERROR_NUCLEUSVERSIONREQ . i18n::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6201 $pluginList = $plugin->getPluginDep();
6202 foreach ($pluginList as $pluginName)
6205 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6206 if (sql_num_rows($res) == 0)
6208 // uninstall plugin again...
6209 $this->deleteOnePlugin($plugin->getID());
6211 $this->error(sprintf(_ERROR_INSREQPLUGIN, i18n::hsc($pluginName)));
6215 // call the install method of the plugin
6221 'plugin' => &$plugin
6225 // update all events
6226 $this->action_pluginupdate();
6230 * @todo document this
6232 function action_pluginupdate() {
6233 global $member, $manager, $CONF;
6236 $member->isAdmin() or $this->disallow();
6238 // delete everything from plugin_events
6239 sql_query('DELETE FROM '.sql_table('plugin_event'));
6241 // loop over all installed plugins
6242 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6243 while($o = sql_fetch_object($res)) {
6245 $plug =& $manager->getPlugin($o->pfile);
6248 $eventList = $plug->getEventList();
6249 foreach ($eventList as $eventName)
6250 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
6254 redirect($CONF['AdminURL'] . '?action=pluginlist');
6255 // $this->action_pluginlist();
6259 * @todo document this
6261 function action_plugindelete() {
6262 global $member, $manager;
6265 $member->isAdmin() or $this->disallow();
6267 $pid = intGetVar('plugid');
6269 if (!$manager->pidInstalled($pid))
6270 $this->error(_ERROR_NOSUCHPLUGIN);
6274 <h2><?php echo _DELETE_CONFIRM?></h2>
6276 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6278 <form method="post" action="index.php"><div>
6279 <?php $manager->addTicketHidden() ?>
6280 <input type="hidden" name="action" value="plugindeleteconfirm" />
6281 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6282 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6289 * @todo document this
6291 function action_plugindeleteconfirm() {
6292 global $member, $manager, $CONF;
6295 $member->isAdmin() or $this->disallow();
6297 $pid = intPostVar('plugid');
6299 $error = $this->deleteOnePlugin($pid, 1);
6301 $this->error($error);
6304 redirect($CONF['AdminURL'] . '?action=pluginlist');
6305 // $this->action_pluginlist();
6309 * @todo document this
6311 function deleteOnePlugin($pid, $callUninstall = 0) {
6314 $pid = intval($pid);
6316 if (!$manager->pidInstalled($pid))
6317 return _ERROR_NOSUCHPLUGIN;
6319 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6321 /* // call the unInstall method of the plugin
6322 if ($callUninstall) {
6323 $plugin =& $manager->getPlugin($name);
6324 if ($plugin) $plugin->unInstall();
6327 // check dependency before delete
6328 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6329 while($o = sql_fetch_object($res)) {
6330 $plug =& $manager->getPlugin($o->pfile);
6333 $depList = $plug->getPluginDep();
6334 foreach ($depList as $depName)
6336 if ($name == $depName)
6338 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6344 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6346 // call the unInstall method of the plugin
6347 if ($callUninstall) {
6348 $plugin =& $manager->getPlugin($name);
6349 if ($plugin) $plugin->unInstall();
6352 // delete all subscriptions
6353 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6355 // delete all options
6356 // get OIDs from plugin_option_desc
6357 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6359 while ($o = sql_fetch_object($res)) {
6360 array_push($aOIDs, $o->oid);
6363 // delete from plugin_option and plugin_option_desc
6364 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6365 if (count($aOIDs) > 0)
6366 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6368 // update order numbers
6369 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6370 $o = sql_fetch_object($res);
6371 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6374 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6376 $manager->clearCachedInfo('installedPlugins');
6377 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6383 * @todo document this
6385 function action_pluginup() {
6386 global $member, $manager, $CONF;
6389 $member->isAdmin() or $this->disallow();
6391 $plugid = intGetVar('plugid');
6393 if (!$manager->pidInstalled($plugid))
6394 $this->error(_ERROR_NOSUCHPLUGIN);
6396 // 1. get old order number
6397 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6398 $o = sql_fetch_object($res);
6399 $oldOrder = $o->porder;
6401 // 2. calculate new order number
6402 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6404 // 3. update plug numbers
6405 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6406 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6408 //$this->action_pluginlist();
6409 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6410 redirect($CONF['AdminURL'] . '?action=pluginlist');
6414 * @todo document this
6416 function action_plugindown() {
6417 global $member, $manager, $CONF;
6420 $member->isAdmin() or $this->disallow();
6422 $plugid = intGetVar('plugid');
6423 if (!$manager->pidInstalled($plugid))
6424 $this->error(_ERROR_NOSUCHPLUGIN);
6426 // 1. get old order number
6427 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6428 $o = sql_fetch_object($res);
6429 $oldOrder = $o->porder;
6431 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6432 $maxOrder = sql_num_rows($res);
6434 // 2. calculate new order number
6435 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6437 // 3. update plug numbers
6438 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6439 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6441 //$this->action_pluginlist();
6442 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6443 redirect($CONF['AdminURL'] . '?action=pluginlist');
6447 * @todo document this
6449 function action_pluginoptions($message = '') {
6450 global $member, $manager;
6453 $member->isAdmin() or $this->disallow();
6455 $pid = intRequestVar('plugid');
6456 if (!$manager->pidInstalled($pid))
6457 $this->error(_ERROR_NOSUCHPLUGIN);
6459 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
6460 $pluginName = i18n::hsc(getPluginNameFromPid($pid));
6461 $this->pagehead($extrahead);
6464 <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
6466 <h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>
6468 <?php if ($message) echo $message?>
6470 <form action="index.php" method="post">
6472 <input type="hidden" name="action" value="pluginoptionsupdate" />
6473 <input type="hidden" name="plugid" value="<?php echo $pid?>" />
6477 $manager->addTicketHidden();
6479 $aOptions = array();
6481 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
6482 $r = sql_query($query);
6483 while ($o = sql_fetch_object($r)) {
6484 array_push($aOIDs, $o->oid);
6485 $aOptions[$o->oid] = array(
6487 'value' => $o->odef,
6488 'name' => $o->oname,
6489 'description' => $o->odesc,
6490 'type' => $o->otype,
6491 'typeinfo' => $o->oextra,
6495 // fill out actual values
6496 if (count($aOIDs) > 0) {
6497 $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
6498 while ($o = sql_fetch_object($r))
6499 $aOptions[$o->oid]['value'] = $o->ovalue;
6503 $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
6505 $template['content'] = 'plugoptionlist';
6506 $amount = showlist($aOptions,'table',$template);
6508 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6513 <?php $this->pagefoot();
6520 * @todo document this
6522 function action_pluginoptionsupdate() {
6523 global $member, $manager;
6526 $member->isAdmin() or $this->disallow();
6528 $pid = intRequestVar('plugid');
6529 if (!$manager->pidInstalled($pid))
6530 $this->error(_ERROR_NOSUCHPLUGIN);
6532 $aOptions = requestArray('plugoption');
6533 NucleusPlugin::_applyPluginOptions($aOptions);
6535 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6537 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6542 * @todo document this
6544 function _insertPluginOptions($context, $contextid = 0) {
6545 // get all current values for this contextid
6546 // (note: this might contain doubles for overlapping contextids)
6547 $aIdToValue = array();
6548 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6549 while ($o = sql_fetch_object($res)) {
6550 $aIdToValue[$o->oid] = $o->ovalue;
6553 // get list of oids per pid
6554 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6555 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
6556 $res = sql_query($query);
6557 $aOptions = array();
6558 while ($o = sql_fetch_object($res)) {
6559 if (in_array($o->oid, array_keys($aIdToValue)))
6560 $value = $aIdToValue[$o->oid];
6564 array_push($aOptions, array(
6566 'pfile' => $o->pfile,
6569 'name' => $o->oname,
6570 'description' => $o->odesc,
6571 'type' => $o->otype,
6572 'typeinfo' => $o->oextra,
6573 'contextid' => $contextid,
6579 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6583 foreach ($aOptions as $aOption) {
6586 if ($iPrevPid != $aOption['pid']) {
6587 $iPrevPid = $aOption['pid'];
6588 if (!defined('_PLUGIN_OPTIONS_TITLE')) {
6589 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
6591 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, i18n::hsc($aOption['pfile'])).'</th></tr>';
6594 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
6595 if (@$meta['access'] != 'hidden') {
6597 listplug_plugOptionRow($aOption);
6607 * Helper functions to create option forms etc.
6608 * @todo document parameters
6610 function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
6611 $id = i18n::hsc($name);
6612 $id = str_replace('[','-',$id);
6613 $id = str_replace(']','-',$id);
6614 $id1 = $id . i18n::hsc($value1);
6615 $id2 = $id . i18n::hsc($value2);
6617 if ($name=="admin") {
6618 echo '<input onclick="selectCanLogin(true);" type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value1),'" ';
6620 echo '<input type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value1),'" ';
6623 if ($checkedval == $value1)
6624 echo "tabindex='$tabindex' checked='checked'";
6625 echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
6627 if ($name=="admin") {
6628 echo '<input onclick="selectCanLogin(false);" type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value2),'" ';
6630 echo '<input type="radio" name="', i18n::hsc($name),'" value="', i18n::hsc($value2),'" ';
6632 if ($checkedval != $value1)
6633 echo "tabindex='$tabindex' checked='checked'";
6634 if ($isAdmin && $name=="canlogin")
6635 echo ' disabled="disabled"';
6636 echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';