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 1661 2012-02-12 11:55:39Z sakamocchi $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
29 private $xml_version_info = '1.0';
30 private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
31 private $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
32 private $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
35 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
49 * @param string $action action to be performed
51 function action($action) {
52 global $CONF, $manager;
54 // list of action aliases
56 'login' => 'overview',
60 if (isset($alias[$action]))
61 $action = $alias[$action];
63 $methodName = 'action_' . $action;
65 $this->action = strtolower($action);
67 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
68 // is an action that requires user interaction before something is actually done)
69 // all safe actions are in this array:
70 $aActionsNotToCheck = array(
101 'banlistnewfromitem',
122 // the rest of the actions needs to be checked
123 $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');
125 if (!in_array($this->action, $aActionsNotToCheck))
127 if (!$manager->checkTicket())
128 $this->error(_ERROR_BADTICKET);
131 if (method_exists($this, $methodName))
132 call_user_func(array(&$this, $methodName));
134 $this->error(_BADACTION . ENTITY::hsc(" ($action)"));
139 * @todo document this
141 function action_showlogin() {
143 $this->action_login($error);
147 * @todo document this
149 function action_login($msg = '', $passvars = 1) {
152 // skip to overview when allowed
153 if ($member->isLoggedIn() && $member->canLogin()) {
154 $this->action_overview();
160 echo '<h2>', _LOGIN ,'</h2>';
161 if ($msg) echo _MESSAGE , ': ', ENTITY::hsc($msg);
164 <form action="index.php" method="post"><p>
165 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
167 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
169 <input name="action" value="login" type="hidden" />
171 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
174 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
175 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
177 <?php // pass through vars
179 $oldaction = postVar('oldaction');
180 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
187 <?php $this->pagefoot();
192 * provides a screen with the overview of the actions available
193 * @todo document parameter
195 function action_overview($msg = '') {
201 echo _MESSAGE , ': ', $msg;
203 /* ---- add items ---- */
204 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
206 $showAll = requestVar('showall');
208 if (($member->isAdmin()) && ($showAll == 'yes')) {
209 // Super-Admins have access to all blogs! (no add item support though)
210 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
211 . ' FROM ' . sql_table('blog')
214 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
215 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
216 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
219 $template['content'] = 'bloglist';
220 $template['superadmin'] = $member->isAdmin();
221 $amount = showlist($query,'table',$template);
223 if (($showAll != 'yes') && ($member->isAdmin())) {
224 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
225 if ($total > $amount)
226 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
230 echo _OVERVIEW_NOBLOGS;
233 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
234 $query = 'SELECT ititle, inumber, bshortname'
235 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
236 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
237 $template['content'] = 'draftlist';
238 $amountdrafts = showlist($query, 'table', $template);
239 if ($amountdrafts == 0)
240 echo _OVERVIEW_NODRAFTS;
244 $yrBlogs = $member->getAdminBlogs();
245 if ($showAll != 'yes') {
247 foreach ($yrBlogs as $value) {
248 if ($member->isBlogAdmin(intval($value))) {
249 $admBlogs[] = intval($value);
252 $yrBlogs = $admBlogs;
255 if (count($yrBlogs) > 0) {
256 echo '<h2>' . _OVERVIEW_OTHER_DRAFTS . '</h2>';
257 $query = 'SELECT ititle, inumber, bshortname, mname'
258 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog'). ', ' . sql_table('member')
259 . ' WHERE iauthor<>'.$member->getID().' and iblog IN ('.implode(",",$yrBlogs).') and iblog=bnumber and iauthor=mnumber and idraft=1'
260 . ' ORDER BY iblog ASC';
261 $template['content'] = 'otherdraftlist';
262 $amountdrafts = showlist($query, 'table', $template);
263 if ($amountdrafts == 0)
264 echo _OVERVIEW_NODRAFTS;
268 /* ---- user settings ---- */
269 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
271 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
272 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
273 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
276 /* ---- general settings ---- */
277 if ($member->isAdmin()) {
278 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
280 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
289 * Returns a link to a weblog
292 function bloglink(&$blog) {
293 return '<a href="'.ENTITY::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. ENTITY::hsc( $blog->getName() ) .'</a>';
297 * @todo document this
299 function action_manage($msg = '') {
302 $member->isAdmin() or $this->disallow();
306 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
309 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
312 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
315 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
316 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
317 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
318 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
321 echo '<h2>' . _MANAGE_SKINS . '</h2>';
323 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
324 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
325 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
328 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
330 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
331 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
338 * @todo document this
340 function action_itemlist($blogid = '') {
341 global $member, $manager, $CONF;
344 $blogid = intRequestVar('blogid');
346 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
349 $blog =& $manager->getBlog($blogid);
351 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
352 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
355 if (postVar('start'))
356 $start = intPostVar('start');
361 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
363 // amount of items to show
364 if (postVar('amount'))
365 $amount = intPostVar('amount');
367 $amount = intval($CONF['DefaultListSize']);
372 $search = postVar('search'); // search through items
374 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
375 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
376 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
379 $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) . '%"))';
381 // non-blog-admins can only edit/delete their own items
382 if (!$member->blogAdminRights($blogid))
383 $query .= ' and iauthor=' . $member->getID();
386 $query .= ' ORDER BY itime DESC'
387 . " LIMIT $start,$amount";
389 $template['content'] = 'itemlist';
390 $template['now'] = $blog->getCorrectTime(time());
392 $manager->loadClass("ENCAPSULATE");
393 $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
394 $navList->showBatchList('item',$query,'table',$template);
401 * @todo document this
403 function action_batchitem() {
404 global $member, $manager;
406 // check if logged in
407 $member->isLoggedIn() or $this->disallow();
409 // more precise check will be done for each performed operation
411 // get array of itemids from request
412 $selected = requestIntArray('batch');
413 $action = requestVar('batchaction');
415 // Show error when no items were selected
416 if (!is_array($selected) || sizeof($selected) == 0)
417 $this->error(_BATCH_NOSELECTION);
419 // On move: when no destination blog/category chosen, show choice now
420 $destCatid = intRequestVar('destcatid');
421 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
422 $this->batchMoveSelectDestination('item',$selected);
424 // On delete: check if confirmation has been given
425 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
426 $this->batchAskDeleteConfirmation('item',$selected);
430 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
431 echo '<h2>',_BATCH_ITEMS,'</h2>';
432 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
436 // walk over all itemids and perform action
437 foreach ($selected as $itemid) {
438 $itemid = intval($itemid);
439 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
441 // perform action, display errors if needed
444 $error = $this->deleteOneItem($itemid);
447 $error = $this->moveOneItem($itemid, $destCatid);
450 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
453 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
458 echo '<b>',_BATCH_DONE,'</b>';
466 * @todo document this
468 function action_batchcomment() {
471 // check if logged in
472 $member->isLoggedIn() or $this->disallow();
474 // more precise check will be done for each performed operation
476 // get array of itemids from request
477 $selected = requestIntArray('batch');
478 $action = requestVar('batchaction');
480 // Show error when no items were selected
481 if (!is_array($selected) || sizeof($selected) == 0)
482 $this->error(_BATCH_NOSELECTION);
484 // On delete: check if confirmation has been given
485 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
486 $this->batchAskDeleteConfirmation('comment',$selected);
490 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
491 echo '<h2>',_BATCH_COMMENTS,'</h2>';
492 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
495 // walk over all itemids and perform action
496 foreach ($selected as $commentid) {
497 $commentid = intval($commentid);
498 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
500 // perform action, display errors if needed
503 $error = $this->deleteOneComment($commentid);
506 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
509 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
514 echo '<b>',_BATCH_DONE,'</b>';
522 * @todo document this
524 function action_batchmember() {
527 // check if logged in and admin
528 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
530 // get array of itemids from request
531 $selected = requestIntArray('batch');
532 $action = requestVar('batchaction');
534 // Show error when no members selected
535 if (!is_array($selected) || sizeof($selected) == 0)
536 $this->error(_BATCH_NOSELECTION);
538 // On delete: check if confirmation has been given
539 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
540 $this->batchAskDeleteConfirmation('member',$selected);
544 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
545 echo '<h2>',_BATCH_MEMBERS,'</h2>';
546 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
549 // walk over all itemids and perform action
550 foreach ($selected as $memberid) {
551 $memberid = intval($memberid);
552 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
554 // perform action, display errors if needed
557 $error = $this->deleteOneMember($memberid);
561 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
565 // there should always remain at least one super-admin
566 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
567 if (sql_num_rows($r) < 2)
568 $error = _ERROR_ATLEASTONEADMIN;
570 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
573 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
576 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
581 echo '<b>',_BATCH_DONE,'</b>';
589 * @todo document this
591 function action_batchteam() {
594 $blogid = intRequestVar('blogid');
596 // check if logged in and admin
597 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
599 // get array of itemids from request
600 $selected = requestIntArray('batch');
601 $action = requestVar('batchaction');
603 // Show error when no members selected
604 if (!is_array($selected) || sizeof($selected) == 0)
605 $this->error(_BATCH_NOSELECTION);
607 // On delete: check if confirmation has been given
608 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
609 $this->batchAskDeleteConfirmation('team',$selected);
613 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
615 echo '<h2>',_BATCH_TEAM,'</h2>';
616 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
619 // walk over all itemids and perform action
620 foreach ($selected as $memberid) {
621 $memberid = intval($memberid);
622 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
624 // perform action, display errors if needed
627 $error = $this->deleteOneTeamMember($blogid, $memberid);
631 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
635 // there should always remain at least one admin
636 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
637 if (sql_num_rows($r) < 2)
638 $error = _ERROR_ATLEASTONEBLOGADMIN;
640 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
643 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
646 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
651 echo '<b>',_BATCH_DONE,'</b>';
659 * @todo document this
661 function action_batchcategory() {
662 global $member, $manager;
664 // check if logged in
665 $member->isLoggedIn() or $this->disallow();
667 // more precise check will be done for each performed operation
669 // get array of itemids from request
670 $selected = requestIntArray('batch');
671 $action = requestVar('batchaction');
673 // Show error when no items were selected
674 if (!is_array($selected) || sizeof($selected) == 0)
675 $this->error(_BATCH_NOSELECTION);
677 // On move: when no destination blog chosen, show choice now
678 $destBlogId = intRequestVar('destblogid');
679 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
680 $this->batchMoveCategorySelectDestination('category',$selected);
682 // On delete: check if confirmation has been given
683 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
684 $this->batchAskDeleteConfirmation('category',$selected);
688 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
689 echo '<h2>',BATCH_CATEGORIES,'</h2>';
690 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
693 // walk over all itemids and perform action
694 foreach ($selected as $catid) {
695 $catid = intval($catid);
696 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
698 // perform action, display errors if needed
701 $error = $this->deleteOneCategory($catid);
704 $error = $this->moveOneCategory($catid, $destBlogId);
707 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
710 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
715 echo '<b>',_BATCH_DONE,'</b>';
722 * @todo document this
724 function batchMoveSelectDestination($type, $ids) {
728 <h2><?php echo _MOVE_TITLE?></h2>
729 <form method="post" action="index.php"><div>
731 <input type="hidden" name="action" value="batch<?php echo $type?>" />
732 <input type="hidden" name="batchaction" value="move" />
734 $manager->addTicketHidden();
736 // insert selected item numbers
738 foreach ($ids as $id)
739 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
741 // show blog/category selection list
742 $this->selectBlogCategory('destcatid');
747 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
750 <?php $this->pagefoot();
755 * @todo document this
757 function batchMoveCategorySelectDestination($type, $ids) {
761 <h2><?php echo _MOVECAT_TITLE?></h2>
762 <form method="post" action="index.php"><div>
764 <input type="hidden" name="action" value="batch<?php echo $type?>" />
765 <input type="hidden" name="batchaction" value="move" />
767 $manager->addTicketHidden();
769 // insert selected item numbers
771 foreach ($ids as $id)
772 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
774 // show blog/category selection list
775 $this->selectBlog('destblogid');
780 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
783 <?php $this->pagefoot();
788 * @todo document this
790 function batchAskDeleteConfirmation($type, $ids) {
795 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
796 <form method="post" action="index.php"><div>
798 <input type="hidden" name="action" value="batch<?php echo $type?>" />
799 <?php $manager->addTicketHidden() ?>
800 <input type="hidden" name="batchaction" value="delete" />
801 <input type="hidden" name="confirmation" value="yes" />
802 <?php // insert selected item numbers
804 foreach ($ids as $id)
805 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
807 // add hidden vars for team & comment
810 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
812 if ($type == 'comment')
814 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
819 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
822 <?php $this->pagefoot();
828 * Inserts a HTML select element with choices for all categories to which the current
830 * @see function selectBlog
832 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
833 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
837 * Inserts a HTML select element with choices for all blogs to which the user has access
838 * mode = 'blog' => shows blognames and values are blogids
839 * mode = 'category' => show category names and values are catids
841 * @param $iForcedBlogInclude
842 * ID of a blog that always needs to be included, without checking if the
843 * member is on the blog team (-1 = none)
844 * @todo document parameters
846 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
847 global $member, $CONF;
849 // 0. get IDs of blogs to which member can post items (+ forced blog)
851 if ($iForcedBlogInclude != -1)
852 $aBlogIds[] = intval($iForcedBlogInclude);
854 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
855 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
857 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
858 $rblogids = sql_query($queryBlogs);
859 while ($o = sql_fetch_object($rblogids))
860 if ($o->bnumber != $iForcedBlogInclude)
861 $aBlogIds[] = intval($o->bnumber);
863 if (count($aBlogIds) == 0)
866 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
868 // 1. select blogs (we'll create optiongroups)
869 // (only select those blogs that have the user on the team)
870 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
871 $blogs = sql_query($queryBlogs);
872 if ($mode == 'category') {
873 if (sql_num_rows($blogs) > 1)
876 while ($oBlog = sql_fetch_object($blogs)) {
878 echo '<optgroup label="',ENTITY::hsc($oBlog->bname),'">';
880 // show selection to create new category when allowed/wanted
882 // check if allowed to do so
883 if ($member->blogAdminRights($oBlog->bnumber))
884 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
887 // 2. for each category in that blog
888 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
889 while ($oCat = sql_fetch_object($categories)) {
890 if ($oCat->catid == $selected)
891 $selectText = ' selected="selected" ';
894 echo '<option value="',$oCat->catid,'" ', $selectText,'>',ENTITY::hsc($oCat->cname),'</option>';
902 while ($oBlog = sql_fetch_object($blogs)) {
903 echo '<option value="',$oBlog->bnumber,'"';
904 if ($oBlog->bnumber == $selected)
905 echo ' selected="selected"';
906 echo'>',ENTITY::hsc($oBlog->bname),'</option>';
914 * @todo document this
916 function action_browseownitems() {
917 global $member, $manager, $CONF;
921 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
922 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
925 if (postVar('start'))
926 $start = intPostVar('start');
930 // amount of items to show
931 if (postVar('amount'))
932 $amount = intPostVar('amount');
934 $amount = intval($CONF['DefaultListSize']);
939 $search = postVar('search'); // search through items
941 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
942 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
943 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
946 $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) . '%"))';
948 $query .= ' ORDER BY itime DESC'
949 . " LIMIT $start,$amount";
951 $template['content'] = 'itemlist';
952 $template['now'] = time();
954 $manager->loadClass("ENCAPSULATE");
955 $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
956 $navList->showBatchList('item',$query,'table',$template);
963 * Show all the comments for a given item
966 function action_itemcommentlist($itemid = '') {
967 global $member, $manager, $CONF;
970 $itemid = intRequestVar('itemid');
972 // only allow if user is allowed to alter item
973 $member->canAlterItem($itemid) or $this->disallow();
975 $blogid = getBlogIdFromItemId($itemid);
980 if (postVar('start'))
981 $start = intPostVar('start');
985 // amount of items to show
986 if (postVar('amount'))
987 $amount = intPostVar('amount');
989 $amount = intval($CONF['DefaultListSize']);
994 $search = postVar('search');
996 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
997 echo '<h2>',_COMMENTS,'</h2>';
999 $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;
1002 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1004 $query .= ' ORDER BY ctime ASC'
1005 . " LIMIT $start,$amount";
1007 $template['content'] = 'commentlist';
1008 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
1010 $manager->loadClass("ENCAPSULATE");
1011 $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
1012 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
1018 * Browse own comments
1020 function action_browseowncomments() {
1021 global $member, $manager, $CONF;
1024 if (postVar('start'))
1025 $start = intPostVar('start');
1029 // amount of items to show
1030 if (postVar('amount'))
1031 $amount = intPostVar('amount');
1033 $amount = intval($CONF['DefaultListSize']);
1038 $search = postVar('search');
1041 $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();
1044 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1046 $query .= ' ORDER BY ctime DESC'
1047 . " LIMIT $start,$amount";
1051 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1052 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
1054 $template['content'] = 'commentlist';
1055 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
1057 $manager->loadClass("ENCAPSULATE");
1058 $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
1059 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
1065 * Browse all comments for a weblog
1066 * @param int $blogid
1068 function action_blogcommentlist($blogid = '')
1070 global $member, $manager, $CONF;
1073 $blogid = intRequestVar('blogid');
1075 $blogid = intval($blogid);
1077 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
1080 if (postVar('start'))
1081 $start = intPostVar('start');
1085 // amount of items to show
1086 if (postVar('amount'))
1087 $amount = intPostVar('amount');
1089 $amount = intval($CONF['DefaultListSize']);
1094 $search = postVar('search'); // search through comments
1097 $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);
1100 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1103 $query .= ' ORDER BY ctime DESC'
1104 . " LIMIT $start,$amount";
1107 $blog =& $manager->getBlog($blogid);
1111 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1112 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1114 $template['content'] = 'commentlist';
1115 $template['canAddBan'] = $member->blogAdminRights($blogid);
1117 $manager->loadClass("ENCAPSULATE");
1118 $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1119 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1125 * Provide a page to item a new item to the given blog
1127 function action_createitem() {
1128 global $member, $manager;
1130 $blogid = intRequestVar('blogid');
1133 $member->teamRights($blogid) or $this->disallow();
1135 $memberid = $member->getID();
1137 $blog =& $manager->getBlog($blogid);
1141 // generate the add-item form
1142 $formfactory = new PAGEFACTORY($blogid);
1143 $formfactory->createAddForm('admin');
1149 * @todo document this
1151 function action_itemedit()
1153 global $member, $manager;
1155 $itemid = intRequestVar('itemid');
1157 // only allow if user is allowed to alter item
1158 $member->canAlterItem($itemid) or $this->disallow();
1160 $item =& $manager->getItem($itemid, 1, 1);
1161 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1163 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1165 if ($blog->convertBreaks())
1167 $item['body'] = removeBreaks($item['body']);
1168 $item['more'] = removeBreaks($item['more']);
1171 // form to edit blog items
1173 $formfactory = new PAGEFACTORY($blog->getID());
1174 $formfactory->createEditForm('admin', $item);
1179 * @todo document this
1181 function action_itemupdate() {
1182 global $member, $manager, $CONF;
1184 $itemid = intRequestVar('itemid');
1185 $catid = postVar('catid');
1187 // only allow if user is allowed to alter item
1188 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1190 $actiontype = postVar('actiontype');
1192 // delete actions are handled by itemdelete (which has confirmation)
1193 if ($actiontype == 'delete') {
1194 $this->action_itemdelete();
1198 $body = postVar('body');
1199 $title = postVar('title');
1200 $more = postVar('more');
1201 $closed = intPostVar('closed');
1202 $draftid = intPostVar('draftid');
1204 // default action = add now
1206 $actiontype='addnow';
1208 // create new category if needed
1209 if (strstr($catid,'newcat')) {
1211 list($blogid) = sscanf($catid,"newcat-%d");
1214 $blog =& $manager->getBlog($blogid);
1215 $catid = $blog->createNewCategory();
1217 // show error when sth goes wrong
1219 $this->doError(_ERROR_CATCREATEFAIL);
1223 set some variables based on actiontype
1226 draft items -> addnow, addfuture, adddraft, delete
1227 non-draft items -> edit, changedate, delete
1230 $timestamp: set to a nonzero value for future dates or date changes
1231 $wasdraft: set to 1 when the item used to be a draft item
1232 $publish: set to 1 when the edited item is not a draft
1234 $blogid = getBlogIDFromItemID($itemid);
1235 $blog =& $manager->getBlog($blogid);
1237 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1238 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1239 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1240 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1241 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1246 // edit the item for real
1247 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1249 $this->updateFuturePosted($blogid);
1252 // delete permission is checked inside ITEM::delete()
1253 ITEM::delete($draftid);
1256 // show category edit window when we created a new category
1257 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1258 if ($catid != intPostVar('catid')) {
1259 $this->action_categoryedit(
1262 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1265 // TODO: set start item correctly for itemlist
1266 $this->action_itemlist(getBlogIDFromItemID($itemid));
1271 * ADMIN::action_itemdelete()
1277 function action_itemdelete()
1279 global $member, $manager;
1281 $itemid = intRequestVar('itemid');
1283 // only allow if user is allowed to alter item
1284 $member->canAlterItem($itemid) or $this->disallow();
1286 if ( !$manager->existsItem($itemid,1,1) )
1288 $this->error(_ERROR_NOSUCHITEM);
1291 $item =& $manager->getItem($itemid,1,1);
1292 $title = ENTITY::hsc(strip_tags($item['title']));
1293 $body = strip_tags($item['body']);
1294 $body = ENTITY::hsc(ENTITY::shorten($body,300,'...'));
1297 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1298 echo '<p>' . _CONFIRMTXT_ITEM . "</p>\n";
1299 echo "<div class=\"note\">\n";
1300 echo "<b>{$title}</b>\n";
1304 echo "<form method=\"post\" action=\"index.php\">\n";
1306 echo "<input type=\"hidden\" name=\"action\" value=\"itemdeleteconfirm\" />\n";
1307 echo $manager->addTicketHidden() . "\n";
1308 echo "<input type=\"hidden\" name=\"itemid\" value=\"{$itemid}\" />\n";
1309 echo '<input type="submit" value="' . _DELETE_CONFIRM_BTN . "\" tabindex=\"10\" />\n";
1317 * @todo document this
1319 function action_itemdeleteconfirm() {
1322 $itemid = intRequestVar('itemid');
1324 // only allow if user is allowed to alter item
1325 $member->canAlterItem($itemid) or $this->disallow();
1328 $blogid = getBlogIdFromItemId($itemid);
1330 // delete item (note: some checks will be performed twice)
1331 $this->deleteOneItem($itemid);
1333 $this->action_itemlist($blogid);
1337 * Deletes one item and returns error if something goes wrong
1338 * @param int $itemid
1340 function deleteOneItem($itemid) {
1341 global $member, $manager;
1343 // only allow if user is allowed to alter item (also checks if itemid exists)
1344 if (!$member->canAlterItem($itemid))
1345 return _ERROR_DISALLOWED;
1347 // need to get blogid before the item is deleted
1348 $blogid = getBlogIDFromItemId($itemid);
1350 $manager->loadClass('ITEM');
1351 ITEM::delete($itemid);
1353 // update blog's futureposted
1354 $this->updateFuturePosted($blogid);
1358 * Update a blog's future posted flag
1359 * @param int $blogid
1361 function updateFuturePosted($blogid) {
1364 $blog =& $manager->getBlog($blogid);
1365 $currenttime = $blog->getCorrectTime(time());
1366 $result = sql_query("SELECT * FROM ".sql_table('item').
1367 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
1368 if (sql_num_rows($result) > 0) {
1369 $blog->setFuturePost();
1372 $blog->clearFuturePost();
1377 * @todo document this
1379 function action_itemmove() {
1380 global $member, $manager;
1382 $itemid = intRequestVar('itemid');
1384 // only allow if user is allowed to alter item
1385 $member->canAlterItem($itemid) or $this->disallow();
1387 $item =& $manager->getItem($itemid,1,1);
1391 <h2><?php echo _MOVE_TITLE?></h2>
1392 <form method="post" action="index.php"><div>
1393 <input type="hidden" name="action" value="itemmoveto" />
1394 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1398 $manager->addTicketHidden();
1399 $this->selectBlogCategory('catid',$item['catid'],10,1);
1402 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1409 * @todo document this
1411 function action_itemmoveto() {
1412 global $member, $manager;
1414 $itemid = intRequestVar('itemid');
1415 $catid = requestVar('catid');
1417 // create new category if needed
1418 if (strstr($catid,'newcat')) {
1420 list($blogid) = sscanf($catid,'newcat-%d');
1423 $blog =& $manager->getBlog($blogid);
1424 $catid = $blog->createNewCategory();
1426 // show error when sth goes wrong
1428 $this->doError(_ERROR_CATCREATEFAIL);
1431 // only allow if user is allowed to alter item
1432 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1434 $old_blogid = getBlogIDFromItemId($itemid);
1436 ITEM::move($itemid, $catid);
1438 // set the futurePosted flag on the blog
1439 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1441 // reset the futurePosted in case the item is moved from one blog to another
1442 $this->updateFuturePosted($old_blogid);
1444 if ($catid != intRequestVar('catid'))
1445 $this->action_categoryedit($catid, $blog->getID());
1447 $this->action_itemlist(getBlogIDFromCatID($catid));
1451 * Moves one item to a given category (category existance should be checked by caller)
1452 * errors are returned
1453 * @param int $itemid
1454 * @param int $destCatid category ID to which the item will be moved
1456 function moveOneItem($itemid, $destCatid) {
1459 // only allow if user is allowed to move item
1460 if (!$member->canUpdateItem($itemid, $destCatid))
1461 return _ERROR_DISALLOWED;
1463 ITEM::move($itemid, $destCatid);
1467 * Adds a item to the chosen blog
1469 function action_additem() {
1470 global $manager, $CONF;
1472 $manager->loadClass('ITEM');
1474 $result = ITEM::createFromRequest();
1476 if ($result['status'] == 'error')
1477 $this->error($result['message']);
1479 $blogid = getBlogIDFromItemID($result['itemid']);
1480 $blog =& $manager->getBlog($blogid);
1481 $btimestamp = $blog->getCorrectTime();
1482 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1484 if ($result['status'] == 'newcategory') {
1485 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1486 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1488 $methodName = 'action_itemList';
1489 call_user_func(array(&$this, $methodName), $blogid);
1494 * Allows to edit previously made comments
1496 function action_commentedit() {
1498 global $member, $manager;
1500 $commentid = intRequestVar('commentid');
1502 $member->canAlterComment($commentid) or $this->disallow();
1504 $comment = COMMENT::getComment($commentid);
1506 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1508 // change <br /> to \n
1509 $comment['body'] = str_replace('<br />', '', $comment['body']);
1511 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1512 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1514 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1519 <h2><?php echo _EDITC_TITLE?></h2>
1521 <form action="index.php" method="post"><div>
1523 <input type="hidden" name="action" value="commentupdate" />
1524 <?php $manager->addTicketHidden(); ?>
1525 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1527 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1529 <td><?php echo _EDITC_WHO?></td>
1531 <?php if ($comment['member'])
1532 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1534 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1538 <td><?php echo _EDITC_WHEN?></td>
1539 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1541 <td><?php echo _EDITC_HOST?></td>
1542 <td><?php echo $comment['host']; ?></td>
1545 <td><?php echo _EDITC_URL; ?></td>
1546 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1549 <td><?php echo _EDITC_EMAIL; ?></td>
1550 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1553 <td><?php echo _EDITC_TEXT?></td>
1555 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1556 echo $comment['body'];
1560 <td><?php echo _EDITC_EDIT?></td>
1561 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1570 * @todo document this
1572 function action_commentupdate() {
1573 global $member, $manager;
1575 $commentid = intRequestVar('commentid');
1577 $member->canAlterComment($commentid) or $this->disallow();
1579 $url = postVar('url');
1580 $email = postVar('email');
1581 $body = postVar('body');
1583 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1584 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1585 # important note that '\' must be matched with '\\\\' in preg* expressions
1587 // intercept words that are too long
1588 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1590 $this->error(_ERROR_COMMENT_LONGWORD);
1594 if (i18n::strlen($body) < 3)
1596 $this->error(_ERROR_COMMENT_NOCOMMENT);
1599 if (i18n::strlen($body) > 5000)
1601 $this->error(_ERROR_COMMENT_TOOLONG);
1605 $body = COMMENT::prepareBody($body);
1608 $manager->notify('PreUpdateComment',array('body' => &$body));
1610 $query = 'UPDATE ' . sql_table('comment')
1611 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1612 . " WHERE cnumber = " . $commentid;
1616 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1617 $o = sql_fetch_object($res);
1618 $itemid = $o->citem;
1620 if ($member->canAlterItem($itemid))
1621 $this->action_itemcommentlist($itemid);
1623 $this->action_browseowncomments();
1628 * ADMIN::action_commentdelete()
1634 function action_commentdelete()
1636 global $member, $manager;
1638 $commentid = intRequestVar('commentid');
1639 $member->canAlterComment($commentid) or $this->disallow();
1640 $comment = COMMENT::getComment($commentid);
1642 $body = strip_tags($comment['body']);
1643 $body = ENTITY::hsc(ENTITY::shorten($body, 300, '...'));
1645 if ( $comment['member'] )
1647 $author = $comment['member'];
1651 $author = $comment['user'];
1656 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1657 echo '<p>' . _CONFIRMTXT_COMMENT . "</p>\n";
1658 echo "<div class=\"note\">\n";
1659 echo '<b>' . _EDITC_WHO . ":</b>{$author}<br />\n";
1660 echo '<b>' . _EDITC_TEXT . ":</b>{$body}\n";
1662 echo "<form method=\"post\" action=\"index.php\">\n";
1664 echo "<input type=\"hidden\" name=\"action\" value=\"commentdeleteconfirm\" />\n";
1665 echo $manager->addTicketHidden() . "\n";
1666 echo "<input type=\"hidden\" name=\"commentid\" value=\"{$commentid}\" />\n";
1667 echo '<input type="submit" tabindex="10" value="'. _DELETE_CONFIRM_BTN . "\" />\n";
1675 * @todo document this
1677 function action_commentdeleteconfirm() {
1680 $commentid = intRequestVar('commentid');
1682 // get item id first
1683 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1684 $o = sql_fetch_object($res);
1685 $itemid = $o->citem;
1687 $error = $this->deleteOneComment($commentid);
1689 $this->doError($error);
1691 if ($member->canAlterItem($itemid))
1692 $this->action_itemcommentlist($itemid);
1694 $this->action_browseowncomments();
1698 * @todo document this
1700 function deleteOneComment($commentid) {
1701 global $member, $manager;
1703 $commentid = intval($commentid);
1705 if (!$member->canAlterComment($commentid))
1706 return _ERROR_DISALLOWED;
1708 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1710 // delete the comments associated with the item
1711 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1714 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1720 * Usermanagement main
1722 function action_usermanagement() {
1723 global $member, $manager;
1726 $member->isAdmin() or $this->disallow();
1730 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1732 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1734 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1736 // show list of members with actions
1738 . ' FROM '.sql_table('member');
1739 $template['content'] = 'memberlist';
1740 $template['tabindex'] = 10;
1742 $manager->loadClass("ENCAPSULATE");
1743 $batch = new BATCH('member');
1744 $batch->showlist($query,'table',$template);
1746 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1748 <form method="post" action="index.php" name="memberedit"><div>
1750 <input type="hidden" name="action" value="memberadd" />
1751 <?php $manager->addTicketHidden() ?>
1755 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1757 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1758 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1760 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
1762 <td><?php echo _MEMBERS_REALNAME?></td>
1763 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1765 <td><?php echo _MEMBERS_PWD?></td>
1766 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1768 <td><?php echo _MEMBERS_REPPWD?></td>
1769 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1771 <td><?php echo _MEMBERS_EMAIL?></td>
1772 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1774 <td><?php echo _MEMBERS_URL?></td>
1775 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1777 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1778 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1780 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1781 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1783 <td><?php echo _MEMBERS_NOTES?></td>
1784 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1786 <td><?php echo _MEMBERS_NEW?></td>
1787 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1796 * Edit member settings
1798 function action_memberedit() {
1799 $this->action_editmembersettings(intRequestVar('memberid'));
1803 * @todo document this
1805 function action_editmembersettings($memberid = '') {
1806 global $member, $manager, $CONF;
1808 if ($memberid == '')
1810 $memberid = $member->getID();
1814 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1816 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1817 $this->pagehead($extrahead);
1819 // show message to go back to member overview (only for admins)
1820 if ($member->isAdmin())
1822 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1826 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1828 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1830 $mem = MEMBER::createFromID($memberid);
1832 <form method="post" action="index.php" name="memberedit"><div>
1834 <input type="hidden" name="action" value="changemembersettings" />
1835 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1836 <?php $manager->addTicketHidden() ?>
1839 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1841 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1842 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1845 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1846 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo ENTITY::hsc($mem->getDisplayName()); ?>" />
1848 echo ENTITY::hsc($member->getDisplayName());
1853 <td><?php echo _MEMBERS_REALNAME?></td>
1854 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo ENTITY::hsc($mem->getRealName()); ?>" /></td>
1856 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1857 <td><?php echo _MEMBERS_PWD?></td>
1858 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1860 <td><?php echo _MEMBERS_REPPWD?></td>
1861 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1864 <td><?php echo _MEMBERS_EMAIL?>
1865 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1867 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo ENTITY::hsc($mem->getEmail()); ?>" /></td>
1869 <td><?php echo _MEMBERS_URL?></td>
1870 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo ENTITY::hsc($mem->getURL()); ?>" /></td>
1871 <?php // only allow to change this by super-admins
1872 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1873 if ($member->isAdmin()) {
1876 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1877 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1879 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1880 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1883 <td><?php echo _MEMBERS_NOTES?></td>
1884 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo ENTITY::hsc($mem->getNotes()); ?>" /></td>
1886 <td><?php echo _MEMBERS_LOCALE?> <?php help('locale'); ?>
1890 <select name="locale" tabindex="85">
1892 $locales = i18n::get_available_locale_list();
1893 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
1895 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1899 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1902 foreach( $locales as $locale )
1904 if( $locale == $mem->getLocale() )
1906 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
1910 echo "<option value=\"{$locale}\">{$locale}</option>\n";
1919 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
1920 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
1924 $this->_insertPluginOptions('member',$memberid);
1927 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1929 <td><?php echo _MEMBERS_EDIT?></td>
1930 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1936 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1939 'MemberSettingsFormExtras',
1948 * @todo document this
1950 function action_changemembersettings() {
1951 global $member, $CONF, $manager;
1953 $memberid = intRequestVar('memberid');
1956 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1958 $name = trim(strip_tags(postVar('name')));
1959 $realname = trim(strip_tags(postVar('realname')));
1960 $password = postVar('password');
1961 $repeatpassword = postVar('repeatpassword');
1962 $email = strip_tags(postVar('email'));
1963 $url = strip_tags(postVar('url'));
1965 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1966 # original eregi: !eregi("^https?://", $url)
1968 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
1969 if (!preg_match('#^https?://#', $url) )
1971 $url = 'http://' . $url;
1974 $admin = postVar('admin');
1975 $canlogin = postVar('canlogin');
1976 $notes = strip_tags(postVar('notes'));
1977 $locale = postVar('locale');
1979 $mem = MEMBER::createFromID($memberid);
1981 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1983 if (!isValidDisplayName($name))
1984 $this->error(_ERROR_BADNAME);
1986 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1987 $this->error(_ERROR_NICKNAMEINUSE);
1989 if ($password != $repeatpassword)
1990 $this->error(_ERROR_PASSWORDMISMATCH);
1992 if ($password && (i18n::strlen($password) < 6))
1993 $this->error(_ERROR_PASSWORDTOOSHORT);
1998 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2000 $this->error($pwderror);
2005 if ( !NOTIFICATION::address_validation($email) )
2007 $this->error(_ERROR_BADMAILADDRESS);
2011 $this->error(_ERROR_REALNAMEMISSING);
2013 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2014 $this->error(_ERROR_NOSUCHTRANSLATION);
2016 // check if there will remain at least one site member with both the logon and admin rights
2017 // (check occurs when taking away one of these rights from such a member)
2018 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2019 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2022 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2023 if (sql_num_rows($r) < 2)
2024 $this->error(_ERROR_ATLEASTONEADMIN);
2027 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2028 $mem->setDisplayName($name);
2030 $mem->setPassword($password);
2033 $oldEmail = $mem->getEmail();
2035 $mem->setRealName($realname);
2036 $mem->setEmail($email);
2038 $mem->setNotes($notes);
2039 $mem->setLocale($locale);
2042 // only allow super-admins to make changes to the admin status
2043 if ($member->isAdmin()) {
2044 $mem->setAdmin($admin);
2045 $mem->setCanLogin($canlogin);
2048 $autosave = postVar ('autosave');
2049 $mem->setAutosave($autosave);
2053 // store plugin options
2054 $aOptions = requestArray('plugoption');
2055 NucleusPlugin::apply_plugin_options($aOptions);
2056 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2058 // if email changed, generate new password
2059 if ($oldEmail != $mem->getEmail())
2061 $mem->sendActivationLink('addresschange', $oldEmail);
2063 $mem->newCookieKey();
2065 // only log out if the member being edited is the current member.
2066 if ($member->getID() == $memberid)
2068 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2073 if ( ( $mem->getID() == $member->getID() )
2074 && ( $mem->getDisplayName() != $member->getDisplayName() )
2076 $mem->newCookieKey();
2078 $this->action_login(_MSG_LOGINAGAIN, 0);
2080 $this->action_overview(_MSG_SETTINGSCHANGED);
2085 * @todo document this
2087 function action_memberadd() {
2088 global $member, $manager;
2091 $member->isAdmin() or $this->disallow();
2093 if (postVar('password') != postVar('repeatpassword'))
2094 $this->error(_ERROR_PASSWORDMISMATCH);
2095 if (i18n::strlen(postVar('password')) < 6)
2096 $this->error(_ERROR_PASSWORDTOOSHORT);
2098 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2102 // fire PostRegister event
2103 $newmem = new MEMBER();
2104 $newmem->readFromName(postVar('name'));
2105 $manager->notify('PostRegister',array('member' => &$newmem));
2107 $this->action_usermanagement();
2111 * Account activation
2115 function action_activate() {
2117 $key = getVar('key');
2118 $this->_showActivationPage($key);
2122 * @todo document this
2124 function _showActivationPage($key, $message = '')
2128 // clean up old activation keys
2129 MEMBER::cleanupActivationTable();
2131 // get activation info
2132 $info = MEMBER::getActivationInfo($key);
2135 $this->error(_ERROR_ACTIVATE);
2137 $mem = MEMBER::createFromId($info->vmember);
2140 $this->error(_ERROR_ACTIVATE);
2144 $bNeedsPasswordChange = true;
2146 switch ($info->vtype)
2149 $title = _ACTIVATE_FORGOT_TITLE;
2150 $text = _ACTIVATE_FORGOT_TEXT;
2153 $title = _ACTIVATE_REGISTER_TITLE;
2154 $text = _ACTIVATE_REGISTER_TEXT;
2156 case 'addresschange':
2157 $title = _ACTIVATE_CHANGE_TITLE;
2158 $text = _ACTIVATE_CHANGE_TEXT;
2159 $bNeedsPasswordChange = false;
2160 MEMBER::activate($key);
2165 'memberName' => ENTITY::hsc($mem->getDisplayName())
2167 $title = TEMPLATE::fill($title, $aVars);
2168 $text = TEMPLATE::fill($text, $aVars);
2172 echo '<h2>' , $title, '</h2>';
2173 echo '<p>' , $text, '</p>';
2177 echo '<p class="error">',$message,'</p>';
2180 if ($bNeedsPasswordChange)
2183 <div><form action="index.php" method="post">
2185 <input type="hidden" name="action" value="activatesetpwd" />
2186 <?php $manager->addTicketHidden() ?>
2187 <input type="hidden" name="key" value="<?php echo ENTITY::hsc($key) ?>" />
2190 <td><?php echo _MEMBERS_PWD?></td>
2191 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2193 <td><?php echo _MEMBERS_REPPWD?></td>
2194 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2198 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2202 <td><?php echo _MEMBERS_SETPWD ?></td>
2203 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2218 * Account activation - set password part
2222 function action_activatesetpwd() {
2224 $key = postVar('key');
2226 // clean up old activation keys
2227 MEMBER::cleanupActivationTable();
2229 // get activation info
2230 $info = MEMBER::getActivationInfo($key);
2232 if (!$info || ($info->type == 'addresschange'))
2233 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2235 $mem = MEMBER::createFromId($info->vmember);
2238 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2240 $password = postVar('password');
2241 $repeatpassword = postVar('repeatpassword');
2243 if ($password != $repeatpassword)
2244 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2246 if ($password && (i18n::strlen($password) < 6))
2247 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2253 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2255 return $this->_showActivationPage($key,$pwderror);
2261 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2263 return $this->_showActivationPage($key, $error);
2267 $mem->setPassword($password);
2270 // do the activation
2271 MEMBER::activate($key);
2274 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2275 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2282 function action_manageteam() {
2283 global $member, $manager;
2285 $blogid = intRequestVar('blogid');
2288 $member->blogAdminRights($blogid) or $this->disallow();
2292 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2294 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2296 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2300 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2301 . ' FROM '.sql_table('member').', '.sql_table('team')
2302 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2304 $template['content'] = 'teamlist';
2305 $template['tabindex'] = 10;
2307 $manager->loadClass("ENCAPSULATE");
2308 $batch = new BATCH('team');
2309 $batch->showlist($query, 'table', $template);
2312 <h3><?php echo _TEAM_ADDNEW?></h3>
2314 <form method='post' action='index.php'><div>
2316 <input type='hidden' name='action' value='teamaddmember' />
2317 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2318 <?php $manager->addTicketHidden() ?>
2321 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2322 <td><?php // TODO: try to make it so only non-team-members are listed
2323 $query = 'SELECT mname as text, mnumber as value'
2324 . ' FROM '.sql_table('member');
2326 $template['name'] = 'memberid';
2327 $template['tabindex'] = 10000;
2328 showlist($query,'select',$template);
2331 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2332 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2334 <td><?php echo _TEAM_ADD?></td>
2335 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2344 * Add member to team
2346 function action_teamaddmember() {
2347 global $member, $manager;
2349 $memberid = intPostVar('memberid');
2350 $blogid = intPostVar('blogid');
2351 $admin = intPostVar('admin');
2354 $member->blogAdminRights($blogid) or $this->disallow();
2356 $blog =& $manager->getBlog($blogid);
2357 if (!$blog->addTeamMember($memberid, $admin))
2358 $this->error(_ERROR_ALREADYONTEAM);
2360 $this->action_manageteam();
2365 * @todo document this
2367 function action_teamdelete() {
2368 global $member, $manager;
2370 $memberid = intRequestVar('memberid');
2371 $blogid = intRequestVar('blogid');
2374 $member->blogAdminRights($blogid) or $this->disallow();
2376 $teammem = MEMBER::createFromID($memberid);
2377 $blog =& $manager->getBlog($blogid);
2381 <h2><?php echo _DELETE_CONFIRM?></h2>
2383 <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo ENTITY::hsc($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo ENTITY::hsc(strip_tags($blog->getName())) ?></b>
2387 <form method="post" action="index.php"><div>
2388 <input type="hidden" name="action" value="teamdeleteconfirm" />
2389 <?php $manager->addTicketHidden() ?>
2390 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2391 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2392 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2399 * @todo document this
2401 function action_teamdeleteconfirm() {
2404 $memberid = intRequestVar('memberid');
2405 $blogid = intRequestVar('blogid');
2407 $error = $this->deleteOneTeamMember($blogid, $memberid);
2409 $this->error($error);
2412 $this->action_manageteam();
2416 * @todo document this
2418 function deleteOneTeamMember($blogid, $memberid) {
2419 global $member, $manager;
2421 $blogid = intval($blogid);
2422 $memberid = intval($memberid);
2425 if (!$member->blogAdminRights($blogid))
2426 return _ERROR_DISALLOWED;
2428 // check if: - there remains at least one blog admin
2429 // - (there remains at least one team member)
2430 $tmem = MEMBER::createFromID($memberid);
2432 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2434 if ($tmem->isBlogAdmin($blogid)) {
2435 // check if there are more blog members left and at least one admin
2436 // (check for at least two admins before deletion)
2437 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2438 $r = sql_query($query);
2439 if (sql_num_rows($r) < 2)
2440 return _ERROR_ATLEASTONEBLOGADMIN;
2443 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2446 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2452 * @todo document this
2454 function action_teamchangeadmin() {
2457 $blogid = intRequestVar('blogid');
2458 $memberid = intRequestVar('memberid');
2461 $member->blogAdminRights($blogid) or $this->disallow();
2463 $mem = MEMBER::createFromID($memberid);
2465 // don't allow when there is only one admin at this moment
2466 if ($mem->isBlogAdmin($blogid)) {
2467 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2468 if (sql_num_rows($r) == 1)
2469 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2472 if ($mem->isBlogAdmin($blogid))
2477 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2480 // only show manageteam if member did not change its own admin privileges
2481 if ($member->isBlogAdmin($blogid))
2482 $this->action_manageteam();
2484 $this->action_overview(_MSG_ADMINCHANGED);
2488 * @todo document this
2490 function action_blogsettings() {
2491 global $member, $manager;
2493 $blogid = intRequestVar('blogid');
2496 $member->blogAdminRights($blogid) or $this->disallow();
2498 $blog =& $manager->getBlog($blogid);
2500 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2501 $this->pagehead($extrahead);
2503 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2505 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2507 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2509 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
2511 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2512 $aMemberNames = array();
2513 while ($o = sql_fetch_object($res))
2514 array_push($aMemberNames, ENTITY::hsc($o->mname) . ' (' . ENTITY::hsc($o->mrealname). ')');
2515 echo implode(',', $aMemberNames);
2522 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2525 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2527 <form method="post" action="index.php"><div>
2529 <input type="hidden" name="action" value="blogsettingsupdate" />
2530 <?php $manager->addTicketHidden() ?>
2531 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2533 <td><?php echo _EBLOG_NAME?></td>
2534 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo ENTITY::hsc($blog->getName()) ?>" /></td>
2536 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2537 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2539 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo ENTITY::hsc($blog->getShortName()) ?>" /></td>
2541 <td><?php echo _EBLOG_DESC?></td>
2542 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo ENTITY::hsc($blog->getDescription()) ?>" /></td>
2544 <td><?php echo _EBLOG_URL?></td>
2545 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo ENTITY::hsc($blog->getURL()) ?>" /></td>
2547 <td><?php echo _EBLOG_DEFSKIN?>
2548 <?php help('blogdefaultskin'); ?>
2552 $query = 'SELECT sdname as text, sdnumber as value'
2553 . ' FROM '.sql_table('skin_desc');
2554 $template['name'] = 'defskin';
2555 $template['selected'] = $blog->getDefaultSkin();
2556 $template['tabindex'] = 50;
2557 showlist($query,'select',$template);
2562 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2564 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2566 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2568 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2570 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2572 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2574 <td><?php echo _EBLOG_ANONYMOUS?>
2576 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2578 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2580 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2582 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2583 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo ENTITY::hsc($blog->getNotifyAddress()); ?>" /></td>
2585 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2587 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2588 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2589 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2591 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2592 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2593 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2595 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2596 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2597 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2600 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2601 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo ENTITY::hsc($blog->getMaxComments()); ?>" /></td>
2603 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2604 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo ENTITY::hsc($blog->getUpdateFile()) ?>" /></td>
2606 <td><?php echo _EBLOG_DEFCAT?></td>
2609 $query = 'SELECT cname as text, catid as value'
2610 . ' FROM '.sql_table('category')
2611 . ' WHERE cblog=' . $blog->getID();
2612 $template['name'] = 'defcat';
2613 $template['selected'] = $blog->getDefaultCategory();
2614 $template['tabindex'] = 110;
2615 showlist($query,'select',$template);
2619 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2620 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
2621 <br /><?php echo _EBLOG_BTIME?> <b><?php echo i18n::strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2623 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo ENTITY::hsc($blog->getTimeOffset()); ?>" /></td>
2625 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2626 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2630 $this->_insertPluginOptions('blog',$blogid);
2633 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2635 <td><?php echo _EBLOG_CHANGE?></td>
2636 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2641 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2645 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2646 $template['content'] = 'categorylist';
2647 $template['tabindex'] = 200;
2649 $manager->loadClass("ENCAPSULATE");
2650 $batch = new BATCH('category');
2651 $batch->showlist($query,'table',$template);
2656 <form action="index.php" method="post"><div>
2657 <input name="action" value="categorynew" type="hidden" />
2658 <?php $manager->addTicketHidden() ?>
2659 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2662 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2664 <td><?php echo _EBLOG_CAT_NAME?></td>
2665 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2667 <td><?php echo _EBLOG_CAT_DESC?></td>
2668 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2670 <td><?php echo _EBLOG_CAT_CREATE?></td>
2671 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2678 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2681 'BlogSettingsFormExtras',
2691 * @todo document this
2693 function action_categorynew() {
2694 global $member, $manager;
2696 $blogid = intRequestVar('blogid');
2698 $member->blogAdminRights($blogid) or $this->disallow();
2700 $cname = postVar('cname');
2701 $cdesc = postVar('cdesc');
2703 if (!isValidCategoryName($cname))
2704 $this->error(_ERROR_BADCATEGORYNAME);
2706 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2707 $res = sql_query($query);
2708 if (sql_num_rows($res) > 0)
2709 $this->error(_ERROR_DUPCATEGORYNAME);
2711 $blog =& $manager->getBlog($blogid);
2712 $newCatID = $blog->createNewCategory($cname, $cdesc);
2714 $this->action_blogsettings();
2718 * @todo document this
2720 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2721 global $member, $manager;
2724 $blogid = intGetVar('blogid');
2726 $blogid = intval($blogid);
2728 $catid = intGetVar('catid');
2730 $catid = intval($catid);
2732 $member->blogAdminRights($blogid) or $this->disallow();
2734 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2735 $obj = sql_fetch_object($res);
2737 $cname = $obj->cname;
2738 $cdesc = $obj->cdesc;
2740 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2741 $this->pagehead($extrahead);
2743 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2746 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo ENTITY::hsc($cname)?>'</h2>
2747 <form method='post' action='index.php'><div>
2748 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2749 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2750 <input name="desturl" type="hidden" value="<?php echo ENTITY::hsc($desturl) ?>" />
2751 <input name="action" type="hidden" value="categoryupdate" />
2752 <?php $manager->addTicketHidden(); ?>
2755 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2757 <td><?php echo _EBLOG_CAT_NAME?></td>
2758 <td><input type="text" name="cname" value="<?php echo ENTITY::hsc($cname)?>" size="40" maxlength="40" /></td>
2760 <td><?php echo _EBLOG_CAT_DESC?></td>
2761 <td><input type="text" name="cdesc" value="<?php echo ENTITY::hsc($cdesc)?>" size="40" maxlength="200" /></td>
2764 // insert plugin options
2765 $this->_insertPluginOptions('category',$catid);
2768 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2770 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2771 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2780 * @todo document this
2782 function action_categoryupdate() {
2783 global $member, $manager;
2785 $blogid = intPostVar('blogid');
2786 $catid = intPostVar('catid');
2787 $cname = postVar('cname');
2788 $cdesc = postVar('cdesc');
2789 $desturl = postVar('desturl');
2791 $member->blogAdminRights($blogid) or $this->disallow();
2793 if (!isValidCategoryName($cname))
2794 $this->error(_ERROR_BADCATEGORYNAME);
2796 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2797 $res = sql_query($query);
2798 if (sql_num_rows($res) > 0)
2799 $this->error(_ERROR_DUPCATEGORYNAME);
2801 $query = 'UPDATE '.sql_table('category').' SET'
2802 . " cname='" . sql_real_escape_string($cname) . "',"
2803 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
2804 . " WHERE catid=" . $catid;
2808 // store plugin options
2809 $aOptions = requestArray('plugoption');
2810 NucleusPlugin::apply_plugin_options($aOptions);
2811 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2818 $this->action_blogsettings();
2823 * @todo document this
2825 function action_categorydelete() {
2826 global $member, $manager;
2828 $blogid = intRequestVar('blogid');
2829 $catid = intRequestVar('catid');
2831 $member->blogAdminRights($blogid) or $this->disallow();
2833 $blog =& $manager->getBlog($blogid);
2835 // check if the category is valid
2836 if (!$blog->isValidCategory($catid))
2837 $this->error(_ERROR_NOSUCHCATEGORY);
2839 // don't allow deletion of default category
2840 if ($blog->getDefaultCategory() == $catid)
2841 $this->error(_ERROR_DELETEDEFCATEGORY);
2843 // check if catid is the only category left for blogid
2844 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2845 $res = sql_query($query);
2846 if (sql_num_rows($res) == 1)
2847 $this->error(_ERROR_DELETELASTCATEGORY);
2852 <h2><?php echo _DELETE_CONFIRM?></h2>
2855 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo ENTITY::hsc($blog->getCategoryName($catid))?></b>
2858 <form method="post" action="index.php"><div>
2859 <input type="hidden" name="action" value="categorydeleteconfirm" />
2860 <?php $manager->addTicketHidden() ?>
2861 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2862 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2863 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2870 * @todo document this
2872 function action_categorydeleteconfirm() {
2873 global $member, $manager;
2875 $blogid = intRequestVar('blogid');
2876 $catid = intRequestVar('catid');
2878 $member->blogAdminRights($blogid) or $this->disallow();
2880 $error = $this->deleteOneCategory($catid);
2882 $this->error($error);
2884 $this->action_blogsettings();
2888 * ADMIN::deleteOneCategory()
2889 * Delete a category by its id
2891 * @param String $catid category id for deleting
2894 function deleteOneCategory($catid)
2896 global $manager, $member;
2898 $catid = intval($catid);
2899 $blogid = getBlogIDFromCatID($catid);
2901 if ( !$member->blogAdminRights($blogid) )
2903 return ERROR_DISALLOWED;
2907 $blog =& $manager->getBlog($blogid);
2909 // check if the category is valid
2910 if ( !$blog || !$blog->isValidCategory($catid) )
2912 return _ERROR_NOSUCHCATEGORY;
2915 $destcatid = $blog->getDefaultCategory();
2917 // don't allow deletion of default category
2918 if ( $blog->getDefaultCategory() == $catid )
2920 return _ERROR_DELETEDEFCATEGORY;
2923 // check if catid is the only category left for blogid
2924 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2925 $res = sql_query($query);
2926 if ( sql_num_rows($res) == 1 )
2928 return _ERROR_DELETELASTCATEGORY;
2931 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2933 // change category for all items to the default category
2934 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2937 // delete all associated plugin options
2938 NucleusPlugin::delete_option_values('category', $catid);
2941 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2944 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2949 * ADMIN::action_blogsettingsupdate
2950 * Updating blog settings
2955 function action_blogsettingsupdate()
2957 global $member, $manager;
2959 $blogid = intRequestVar('blogid');
2961 $member->blogAdminRights($blogid) or $this->disallow();
2963 $blog =& $manager->getBlog($blogid);
2965 $notify_address = trim(postVar('notify'));
2966 $shortname = trim(postVar('shortname'));
2967 $updatefile = trim(postVar('update'));
2969 $notifyComment = intPostVar('notifyComment');
2970 $notifyVote = intPostVar('notifyVote');
2971 $notifyNewItem = intPostVar('notifyNewItem');
2973 if ( $notifyComment == 0 )
2977 if ( $notifyVote == 0 )
2981 if ( $notifyNewItem == 0 )
2985 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
2987 if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
2989 $this->error(_ERROR_BADNOTIFY);
2992 if ( !isValidShortName($shortname) )
2994 $this->error(_ERROR_BADSHORTBLOGNAME);
2997 if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
2999 $this->error(_ERROR_DUPSHORTBLOGNAME);
3001 // check if update file is writable
3002 if ( $updatefile && !is_writeable($updatefile) )
3004 $this->error(_ERROR_UPDATEFILE);
3007 $blog->setName(trim(postVar('name')));
3008 $blog->setShortName($shortname);
3009 $blog->setNotifyAddress($notify_address);
3010 $blog->setNotifyType($notifyType);
3011 $blog->setMaxComments(postVar('maxcomments'));
3012 $blog->setCommentsEnabled(postVar('comments'));
3013 $blog->setTimeOffset(postVar('timeoffset'));
3014 $blog->setUpdateFile($updatefile);
3015 $blog->setURL(trim(postVar('url')));
3016 $blog->setDefaultSkin(intPostVar('defskin'));
3017 $blog->setDescription(trim(postVar('desc')));
3018 $blog->setPublic(postVar('public'));
3019 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3020 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3021 $blog->setDefaultCategory(intPostVar('defcat'));
3022 $blog->setSearchable(intPostVar('searchable'));
3023 $blog->setEmailRequired(intPostVar('reqemail'));
3024 $blog->writeSettings();
3026 // store plugin options
3027 $aOptions = requestArray('plugoption');
3028 NucleusPlugin::apply_plugin_options($aOptions);
3029 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3031 $this->action_overview(_MSG_SETTINGSCHANGED);
3036 * @todo document this
3038 function action_deleteblog() {
3039 global $member, $CONF, $manager;
3041 $blogid = intRequestVar('blogid');
3043 $member->blogAdminRights($blogid) or $this->disallow();
3045 // check if blog is default blog
3046 if ($CONF['DefaultBlog'] == $blogid)
3047 $this->error(_ERROR_DELDEFBLOG);
3049 $blog =& $manager->getBlog($blogid);
3053 <h2><?php echo _DELETE_CONFIRM?></h2>
3055 <p><?php echo _WARNINGTXT_BLOGDEL?>
3059 <?php echo _CONFIRMTXT_BLOG?><b><?php echo ENTITY::hsc($blog->getName())?></b>
3062 <form method="post" action="index.php"><div>
3063 <input type="hidden" name="action" value="deleteblogconfirm" />
3064 <?php $manager->addTicketHidden() ?>
3065 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3066 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3073 * ADMIN::action_deleteblogconfirm()
3079 function action_deleteblogconfirm()
3081 global $member, $CONF, $manager;
3083 $blogid = intRequestVar('blogid');
3084 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3085 $member->blogAdminRights($blogid) or $this->disallow();
3087 // check if blog is default blog
3088 if ( $CONF['DefaultBlog'] == $blogid )
3090 $this->error(_ERROR_DELDEFBLOG);
3093 // delete all comments
3094 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3098 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3101 // delete all team members
3102 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3106 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3109 // delete all categories
3110 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3113 // delete all associated plugin options
3114 NucleusPlugin::delete_option_values('blog', $blogid);
3116 // delete the blog itself
3117 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3120 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3122 $this->action_overview(_DELETED_BLOG);
3127 * @todo document this
3129 function action_memberdelete() {
3130 global $member, $manager;
3132 $memberid = intRequestVar('memberid');
3134 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3136 $mem = MEMBER::createFromID($memberid);
3140 <h2><?php echo _DELETE_CONFIRM?></h2>
3142 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo ENTITY::hsc($mem->getDisplayName()) ?></b>
3146 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3149 <form method="post" action="index.php"><div>
3150 <input type="hidden" name="action" value="memberdeleteconfirm" />
3151 <?php $manager->addTicketHidden() ?>
3152 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3153 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3160 * @todo document this
3162 function action_memberdeleteconfirm() {
3165 $memberid = intRequestVar('memberid');
3167 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3169 $error = $this->deleteOneMember($memberid);
3171 $this->error($error);
3173 if ($member->isAdmin())
3174 $this->action_usermanagement();
3176 $this->action_overview(_DELETED_MEMBER);
3180 * ADMIN::deleteOneMember()
3181 * Delete a member by id
3184 * @params Integer $memberid member id
3185 * @return String null string or error messages
3187 function deleteOneMember($memberid)
3191 $memberid = intval($memberid);
3192 $mem = MEMBER::createFromID($memberid);
3194 if ( !$mem->canBeDeleted() )
3196 return _ERROR_DELETEMEMBER;
3199 $manager->notify('PreDeleteMember', array('member' => &$mem));
3201 /* unlink comments from memberid */
3204 $query = "UPDATE %s SET cmember=0, cuser='%s' WHERE cmember=%d";
3205 $query = sprintf($query, sql_table('comment'), sql_real_escape_string($mem->getDisplayName()), $memberid);
3209 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3212 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3215 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3218 // delete all associated plugin options
3219 NucleusPlugin::delete_option_values('member', $memberid);
3221 $manager->notify('PostDeleteMember', array('member' => &$mem));
3227 * @todo document this
3229 function action_createnewlog() {
3230 global $member, $CONF, $manager;
3232 // Only Super-Admins can do this
3233 $member->isAdmin() or $this->disallow();
3237 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3239 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3241 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3243 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3245 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3248 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3249 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3252 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3255 <?php echo _EBLOG_CREATE_TEXT?>
3258 <form method="post" action="index.php"><div>
3260 <input type="hidden" name="action" value="addnewlog" />
3261 <?php $manager->addTicketHidden() ?>
3265 <td><?php echo _EBLOG_NAME?></td>
3266 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3268 <td><?php echo _EBLOG_SHORTNAME?>
3269 <?php help('shortblogname'); ?>
3271 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3273 <td><?php echo _EBLOG_DESC?></td>
3274 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3276 <td><?php echo _EBLOG_DEFSKIN?>
3277 <?php help('blogdefaultskin'); ?>
3281 $query = 'SELECT sdname as text, sdnumber as value'
3282 . ' FROM '.sql_table('skin_desc');
3283 $template['name'] = 'defskin';
3284 $template['tabindex'] = 50;
3285 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3286 showlist($query,'select',$template);
3290 <td><?php echo _EBLOG_OFFSET?>
3291 <?php help('blogtimeoffset'); ?>
3292 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
3294 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3296 <td><?php echo _EBLOG_ADMIN?>
3297 <?php help('teamadmin'); ?>
3299 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3301 <td><?php echo _EBLOG_CREATE?></td>
3302 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3311 * @todo document this
3313 function action_addnewlog() {
3314 global $member, $manager, $CONF;
3316 // Only Super-Admins can do this
3317 $member->isAdmin() or $this->disallow();
3319 $bname = trim(postVar('name'));
3320 $bshortname = trim(postVar('shortname'));
3321 $btimeoffset = postVar('timeoffset');
3322 $bdesc = trim(postVar('desc'));
3323 $bdefskin = postVar('defskin');
3325 if (!isValidShortName($bshortname))
3326 $this->error(_ERROR_BADSHORTBLOGNAME);
3328 if ($manager->existsBlog($bshortname))
3329 $this->error(_ERROR_DUPSHORTBLOGNAME);
3335 'shortname' => &$bshortname,
3336 'timeoffset' => &$btimeoffset,
3337 'description' => &$bdesc,
3338 'defaultskin' => &$bdefskin
3343 // add slashes for sql queries
3344 $bname = sql_real_escape_string($bname);
3345 $bshortname = sql_real_escape_string($bshortname);
3346 $btimeoffset = sql_real_escape_string($btimeoffset);
3347 $bdesc = sql_real_escape_string($bdesc);
3348 $bdefskin = sql_real_escape_string($bdefskin);
3351 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3353 $blogid = sql_insert_id();
3354 $blog =& $manager->getBlog($blogid);
3356 // create new category
3357 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3358 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3359 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3360 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3361 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3362 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3363 $catid = sql_insert_id();
3365 // set as default category
3366 $blog->setDefaultCategory($catid);
3367 $blog->writeSettings();
3369 // create team member
3370 $memberid = $member->getID();
3371 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3374 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3375 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3377 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3378 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3393 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3394 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3401 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3403 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, ENTITY::hsc($bname)) ?></p>
3406 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, ENTITY::hsc($bshortname)) ?></a></li>
3407 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3410 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, ENTITY::hsc($bshortname)) ?></a></h3>
3412 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, ENTITY::hsc($bshortname)) ?></p>
3415 $CONF['Self'] = '<b><?php echo ENTITY::hsc($bshortname)?>.php</b>';
3417 include('<i>./config.php</i>');
3419 selectBlog('<b><?php echo ENTITY::hsc($bshortname)?></b>');
3424 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3426 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3428 <form action="index.php" method="post"><div>
3429 <input type="hidden" name="action" value="addnewlog2" />
3430 <?php $manager->addTicketHidden() ?>
3431 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3433 <td><?php echo _EBLOG_URL?></td>
3434 <td><input name="url" maxlength="100" size="40" value="<?php echo ENTITY::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3436 <td><?php echo _EBLOG_CREATE?></td>
3437 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3441 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3443 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3445 <form action="index.php" method="post"><div>
3446 <input type="hidden" name="action" value="addnewlog2" />
3447 <?php $manager->addTicketHidden() ?>
3448 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3450 <td><?php echo _EBLOG_URL?></td>
3451 <td><input name="url" maxlength="100" size="40" /></td>
3453 <td><?php echo _EBLOG_CREATE?></td>
3454 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3458 <?php $this->pagefoot();
3463 * @todo document this
3465 function action_addnewlog2() {
3466 global $member, $manager;
3468 $member->blogAdminRights($blogid) or $this->disallow();
3470 $burl = requestVar('url');
3471 $blogid = intRequestVar('blogid');
3473 $blog =& $manager->getBlog($blogid);
3474 $blog->setURL(trim($burl));
3475 $blog->writeSettings();
3477 $this->action_overview(_MSG_NEWBLOG);
3481 * @todo document this
3483 function action_skinieoverview() {
3484 global $member, $DIR_LIBS, $manager;
3486 $member->isAdmin() or $this->disallow();
3488 // load skinie class
3489 include_once($DIR_LIBS . 'skinie.php');
3493 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3496 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3498 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3499 <?php global $DIR_SKINS;
3501 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3503 if (sizeof($candidates) > 0) {
3505 <form method="post" action="index.php"><div>
3506 <input type="hidden" name="action" value="skinieimport" />
3507 <?php $manager->addTicketHidden() ?>
3508 <input type="hidden" name="mode" value="file" />
3509 <select name="skinfile" id="skinie_import_local">
3510 <?php foreach ($candidates as $skinname => $skinfile) {
3511 $html = ENTITY::hsc($skinfile);
3512 echo '<option value="',$html,'">',$skinname,'</option>';
3516 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3519 echo _SKINIE_NOCANDIDATES;
3524 <p><em><?php echo _OR?></em></p>
3526 <form method="post" action="index.php"><p>
3527 <?php $manager->addTicketHidden() ?>
3528 <input type="hidden" name="action" value="skinieimport" />
3529 <input type="hidden" name="mode" value="url" />
3530 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3531 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3532 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3536 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3537 <form method="post" action="index.php"><div>
3538 <input type="hidden" name="action" value="skinieexport" />
3539 <?php $manager->addTicketHidden() ?>
3541 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3544 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3546 <?php // show list of skins
3547 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3548 while ($skinObj = sql_fetch_object($res)) {
3549 $id = 'skinexp' . $skinObj->sdnumber;
3550 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3551 echo '<label for="',$id,'">',ENTITY::hsc($skinObj->sdname),'</label></td>';
3552 echo '<td>',ENTITY::hsc($skinObj->sddesc),'</td>';
3556 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3558 // show list of templates
3559 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3560 while ($templateObj = sql_fetch_object($res)) {
3561 $id = 'templateexp' . $templateObj->tdnumber;
3562 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3563 echo '<label for="',$id,'">',ENTITY::hsc($templateObj->tdname),'</label></td>';
3564 echo '<td>',ENTITY::hsc($templateObj->tddesc),'</td>';
3569 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3571 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3573 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3575 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3585 * @todo document this
3587 function action_skinieimport() {
3588 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3590 $member->isAdmin() or $this->disallow();
3592 // load skinie class
3593 include_once($DIR_LIBS . 'skinie.php');
3595 $skinFileRaw= postVar('skinfile');
3596 $mode = postVar('mode');
3598 $importer = new SKINIMPORT();
3600 // get full filename
3601 if ($mode == 'file')
3603 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3605 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3606 if (!file_exists($skinFile))
3607 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3609 $skinFile = $skinFileRaw;
3612 // read only metadata
3613 $error = $importer->readFile($skinFile, 1);
3616 $skinNameClashes = $importer->checkSkinNameClashes();
3617 $templateNameClashes = $importer->checkTemplateNameClashes();
3618 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3620 if ($error) $this->error($error);
3624 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3626 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3629 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo ENTITY::hsc($importer->getInfo())?></p></li>
3630 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3631 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3633 if ($hasNameClashes)
3636 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3637 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3639 } // if (hasNameClashes)
3643 <form method="post" action="index.php"><div>
3644 <input type="hidden" name="action" value="skiniedoimport" />
3645 <?php $manager->addTicketHidden() ?>
3646 <input type="hidden" name="skinfile" value="<?php echo ENTITY::hsc(postVar('skinfile'))?>" />
3647 <input type="hidden" name="mode" value="<?php echo ENTITY::hsc($mode)?>" />
3648 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3650 if ($hasNameClashes)
3654 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3656 } // if (hasNameClashes)
3666 * @todo document this
3668 function action_skiniedoimport() {
3669 global $member, $DIR_LIBS, $DIR_SKINS;
3671 $member->isAdmin() or $this->disallow();
3673 // load skinie class
3674 include_once($DIR_LIBS . 'skinie.php');
3676 $skinFileRaw= postVar('skinfile');
3677 $mode = postVar('mode');
3679 $allowOverwrite = intPostVar('overwrite');
3681 // get full filename
3682 if ($mode == 'file')
3684 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3686 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3687 if (!file_exists($skinFile))
3688 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3691 $skinFile = $skinFileRaw;
3694 $importer = new SKINIMPORT();
3696 $error = $importer->readFile($skinFile);
3699 $this->error($error);
3701 $error = $importer->writeToDatabase($allowOverwrite);
3704 $this->error($error);
3708 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3710 <h2><?php echo _SKINIE_DONE?></h2>
3713 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo ENTITY::hsc($importer->getInfo())?></p></li>
3714 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3715 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3718 <?php $this->pagefoot();
3723 * @todo document this
3725 function action_skinieexport() {
3726 global $member, $DIR_LIBS;
3728 $member->isAdmin() or $this->disallow();
3730 // load skinie class
3731 include_once($DIR_LIBS . 'skinie.php');
3733 $aSkins = requestIntArray('skin');
3734 $aTemplates = requestIntArray('template');
3736 if (!is_array($aTemplates)) $aTemplates = array();
3737 if (!is_array($aSkins)) $aSkins = array();
3739 $skinList = array_keys($aSkins);
3740 $templateList = array_keys($aTemplates);
3742 $info = postVar('info');
3744 $exporter = new SKINEXPORT();
3745 foreach ($skinList as $skinId) {
3746 $exporter->addSkin($skinId);
3748 foreach ($templateList as $templateId) {
3749 $exporter->addTemplate($templateId);
3751 $exporter->setInfo($info);
3753 $exporter->export();
3757 * @todo document this
3759 function action_templateoverview() {
3760 global $member, $manager;
3762 $member->isAdmin() or $this->disallow();
3766 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3768 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3769 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3771 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3772 $template['content'] = 'templatelist';
3773 $template['tabindex'] = 10;
3774 showlist($query,'table',$template);
3776 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3779 <form method="post" action="index.php"><div>
3781 <input name="action" value="templatenew" type="hidden" />
3782 <?php $manager->addTicketHidden() ?>
3784 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3785 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3787 <td><?php echo _TEMPLATE_DESC?></td>
3788 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3790 <td><?php echo _TEMPLATE_CREATE?></td>
3791 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3801 * @todo document this
3803 function action_templateedit($msg = '') {
3804 global $member, $manager;
3806 $templateid = intRequestVar('templateid');
3808 $member->isAdmin() or $this->disallow();
3810 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3811 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
3813 $this->pagehead($extrahead);
3815 $templatename = TEMPLATE::getNameFromId($templateid);
3816 $templatedescription = TEMPLATE::getDesc($templateid);
3817 $template =& $manager->getTemplate($templatename);
3821 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3824 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo ENTITY::hsc($templatename); ?>'</h2>
3826 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3829 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3831 <form method="post" action="index.php">
3834 <input type="hidden" name="action" value="templateupdate" />
3835 <?php $manager->addTicketHidden() ?>
3836 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3839 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3841 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3842 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo ENTITY::hsc($templatename) ?>" /></td>
3844 <td><?php echo _TEMPLATE_DESC?></td>
3845 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo ENTITY::hsc($templatedescription) ?>" /></td>
3847 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3849 <td><?php echo _TEMPLATE_UPDATE?></td>
3851 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3852 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3855 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3856 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3857 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3858 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3859 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3860 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3861 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3864 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3865 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3866 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3867 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3868 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3869 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3870 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3871 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3874 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3876 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3879 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3880 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3883 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3884 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3885 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3886 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3889 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3890 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3891 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3892 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3895 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3896 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
3897 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
3898 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
3901 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3902 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
3903 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
3904 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
3905 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
3906 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
3909 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3910 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
3911 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
3912 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
3915 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3916 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
3917 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
3920 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
3923 $pluginfields = array();
3924 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
3926 foreach ($pluginfields as $pfkey=>$pfvalue) {
3928 echo '<th colspan="2">' . ENTITY::hen($pfkey) . "</th>\n";
3929 foreach ($pfvalue as $pffield=>$pfdesc) {
3930 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
3935 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3937 <td><?php echo _TEMPLATE_UPDATE?></td>
3939 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3940 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3951 * @todo document this
3953 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3955 if (!isset($template[$name])) $template[$name] = '';
3958 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3959 <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 ENTITY::hsc($template[$name]); ?></textarea></td>
3964 * @todo document this
3966 function action_templateupdate() {
3967 global $member,$manager;
3969 $templateid = intRequestVar('templateid');
3971 $member->isAdmin() or $this->disallow();
3973 $name = postVar('tname');
3974 $desc = postVar('tdesc');
3976 if (!isValidTemplateName($name))
3977 $this->error(_ERROR_BADTEMPLATENAME);
3979 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
3980 $this->error(_ERROR_DUPTEMPLATENAME);
3983 $name = sql_real_escape_string($name);
3984 $desc = sql_real_escape_string($desc);
3986 // 1. Remove all template parts
3987 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
3990 // 2. Update description
3991 $query = 'UPDATE '.sql_table('template_desc').' SET'
3992 . " tdname='" . $name . "',"
3993 . " tddesc='" . $desc . "'"
3994 . " WHERE tdnumber=" . $templateid;
3997 // 3. Add non-empty template parts
3998 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
3999 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4000 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4001 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4002 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4003 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4004 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4005 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4006 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4007 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4008 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4009 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4010 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4011 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4012 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4013 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4014 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4015 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4016 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4017 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4018 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4019 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4020 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4021 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4022 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4023 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4024 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4025 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4026 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4027 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4028 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4029 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4030 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4031 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4033 $pluginfields = array();
4034 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4035 foreach ($pluginfields as $pfkey=>$pfvalue) {
4036 foreach ($pfvalue as $pffield=>$pfdesc) {
4037 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4041 // jump back to template edit
4042 $this->action_templateedit(_TEMPLATE_UPDATED);
4047 * @todo document this
4049 function addToTemplate($id, $partname, $content) {
4050 $partname = sql_real_escape_string($partname);
4051 $content = sql_real_escape_string($content);
4055 // don't add empty parts:
4056 if (!trim($content)) return -1;
4058 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
4059 . "VALUES ($id, '$partname', '$content')";
4060 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4061 return sql_insert_id();
4065 * @todo document this
4067 function action_templatedelete() {
4068 global $member, $manager;
4070 $member->isAdmin() or $this->disallow();
4072 $templateid = intRequestVar('templateid');
4073 // TODO: check if template can be deleted
4077 $name = TEMPLATE::getNameFromId($templateid);
4078 $desc = TEMPLATE::getDesc($templateid);
4081 <h2><?php echo _DELETE_CONFIRM?></h2>
4084 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo ENTITY::hsc($name)?></b> (<?php echo ENTITY::hsc($desc) ?>)
4087 <form method="post" action="index.php"><div>
4088 <input type="hidden" name="action" value="templatedeleteconfirm" />
4089 <?php $manager->addTicketHidden() ?>
4090 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4091 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4098 * @todo document this
4100 function action_templatedeleteconfirm() {
4101 global $member, $manager;
4103 $templateid = intRequestVar('templateid');
4105 $member->isAdmin() or $this->disallow();
4107 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4109 // 1. delete description
4110 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4113 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4115 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4117 $this->action_templateoverview();
4121 * @todo document this
4123 function action_templatenew() {
4126 $member->isAdmin() or $this->disallow();
4128 $name = postVar('name');
4129 $desc = postVar('desc');
4131 if (!isValidTemplateName($name))
4132 $this->error(_ERROR_BADTEMPLATENAME);
4134 if (TEMPLATE::exists($name))
4135 $this->error(_ERROR_DUPTEMPLATENAME);
4137 $newTemplateId = TEMPLATE::createNew($name, $desc);
4139 $this->action_templateoverview();
4143 * @todo document this
4145 function action_templateclone() {
4148 $templateid = intRequestVar('templateid');
4150 $member->isAdmin() or $this->disallow();
4152 // 1. read old template
4153 $name = TEMPLATE::getNameFromId($templateid);
4154 $desc = TEMPLATE::getDesc($templateid);
4156 // 2. create desc thing
4157 $name = "cloned" . $name;
4159 // if a template with that name already exists:
4160 if (TEMPLATE::exists($name)) {
4162 while (TEMPLATE::exists($name . $i))
4167 $newid = TEMPLATE::createNew($name, $desc);
4170 // go through parts of old template and add them to the new one
4171 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4172 while ($o = sql_fetch_object($res)) {
4173 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4176 $this->action_templateoverview();
4180 * @todo document this
4182 function action_skinoverview() {
4183 global $member, $manager;
4185 $member->isAdmin() or $this->disallow();
4189 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4191 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4193 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4195 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4196 $template['content'] = 'skinlist';
4197 $template['tabindex'] = 10;
4198 showlist($query,'table',$template);
4200 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4203 <form method="post" action="index.php">
4206 <input name="action" value="skinnew" type="hidden" />
4207 <?php $manager->addTicketHidden() ?>
4209 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4210 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4212 <td><?php echo _SKIN_DESC?></td>
4213 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4215 <td><?php echo _SKIN_CREATE?></td>
4216 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4227 * @todo document this
4229 function action_skinnew() {
4232 $member->isAdmin() or $this->disallow();
4234 $name = trim(postVar('name'));
4235 $desc = trim(postVar('desc'));
4237 if (!isValidSkinName($name))
4238 $this->error(_ERROR_BADSKINNAME);
4240 if (SKIN::exists($name))
4241 $this->error(_ERROR_DUPSKINNAME);
4243 $newId = SKIN::createNew($name, $desc);
4245 $this->action_skinoverview();
4249 * @todo document this
4251 function action_skinedit() {
4252 global $member, $manager;
4254 $skinid = intRequestVar('skinid');
4256 $member->isAdmin() or $this->disallow();
4258 $skin = new SKIN($skinid);
4263 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4265 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4267 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4268 <?php echo _SKIN_PARTS_MSG?>
4270 <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>
4271 <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>
4272 <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>
4273 <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>
4274 <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>
4275 <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>
4276 <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>
4277 <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>
4282 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4283 $res = sql_query($query);
4285 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4286 echo '<form method="get" action="index.php">' . "\r\n";
4287 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4288 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4289 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4290 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4291 echo '</form>' . "\r\n";
4293 if ($res && sql_num_rows($res) > 0) {
4297 while ($row = sql_fetch_assoc($res)) {
4298 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . ENTITY::hsc(strtolower($row['stype'])) . '">' . ENTITY::hsc(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . ENTITY::hsc(strtolower($row['stype'])) . '">remove</a>)</li>';
4306 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4307 <form method="post" action="index.php">
4310 <input type="hidden" name="action" value="skineditgeneral" />
4311 <?php $manager->addTicketHidden() ?>
4312 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4314 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4315 <td><input name="name" tabindex="90" value="<?php echo ENTITY::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
4317 <td><?php echo _SKIN_DESC?></td>
4318 <td><input name="desc" tabindex="100" value="<?php echo ENTITY::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4320 <td><?php echo _SKIN_TYPE?></td>
4321 <td><input name="type" tabindex="110" value="<?php echo ENTITY::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4323 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4324 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4326 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4327 <td><input name="inc_prefix" tabindex="130" value="<?php echo ENTITY::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4329 <td><?php echo _SKIN_CHANGE?></td>
4330 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4337 <?php $this->pagefoot();
4341 * @todo document this
4343 function action_skineditgeneral() {
4346 $skinid = intRequestVar('skinid');
4348 $member->isAdmin() or $this->disallow();
4350 $name = postVar('name');
4351 $desc = postVar('desc');
4352 $type = postVar('type');
4353 $inc_mode = postVar('inc_mode');
4354 $inc_prefix = postVar('inc_prefix');
4356 $skin = new SKIN($skinid);
4359 if (!isValidSkinName($name))
4360 $this->error(_ERROR_BADSKINNAME);
4362 if (($skin->getName() != $name) && SKIN::exists($name))
4363 $this->error(_ERROR_DUPSKINNAME);
4365 if (!$type) $type = 'text/html';
4366 if (!$inc_mode) $inc_mode = 'normal';
4368 // 2. Update description
4369 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4371 $this->action_skinedit();
4376 * @todo document this
4378 function action_skinedittype($msg = '') {
4379 global $member, $manager;
4381 $skinid = intRequestVar('skinid');
4382 $type = requestVar('type');
4384 $member->isAdmin() or $this->disallow();
4386 $type = trim($type);
4387 $type = strtolower($type);
4389 if (!isValidShortName($type)) {
4390 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4393 $skin = new SKIN($skinid);
4395 $friendlyNames = SKIN::getFriendlyNames();
4399 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4401 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo ENTITY::hsc($skin->getName()) ?>': <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4403 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4407 <form method="post" action="index.php">
4410 <input type="hidden" name="action" value="skinupdate" />
4411 <?php $manager->addTicketHidden() ?>
4412 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4413 <input type="hidden" name="type" value="<?php echo $type ?>" />
4415 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4416 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4417 (skin type: <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4418 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4419 help('skinpart' . $type);
4421 help('skinpartspecial');
4425 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo ENTITY::hsc($skin->getContent($type)) ?></textarea>
4428 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4429 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4430 (skin type: <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4433 <?php echo _SKIN_ALLOWEDVARS?>
4434 <?php $actions = SKIN::getAllowedActionsForType($type);
4438 while ($current = array_shift($actions)) {
4439 // skip deprecated vars
4440 if ($current == 'ifcat') continue;
4441 if ($current == 'imagetext') continue;
4442 if ($current == 'vars') continue;
4444 echo helplink('skinvar-' . $current) . "$current</a>";
4445 if (count($actions) != 0) echo ", ";
4447 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
4448 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4449 showlist($query,'table',array('content'=>'shortblognames'));
4450 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
4451 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4452 showlist($query,'table',array('content'=>'shortnames'));
4453 echo '</div></form>';
4458 * @todo document this
4460 function action_skinupdate() {
4463 $skinid = intRequestVar('skinid');
4464 $content = trim(postVar('content'));
4465 $type = postVar('type');
4467 $member->isAdmin() or $this->disallow();
4469 $skin = new SKIN($skinid);
4470 $skin->update($type, $content);
4472 $this->action_skinedittype(_SKIN_UPDATED);
4476 * @todo document this
4478 function action_skindelete() {
4479 global $member, $manager, $CONF;
4481 $skinid = intRequestVar('skinid');
4483 $member->isAdmin() or $this->disallow();
4485 // don't allow default skin to be deleted
4486 if ($skinid == $CONF['BaseSkin'])
4487 $this->error(_ERROR_DEFAULTSKIN);
4489 // don't allow deletion of default skins for blogs
4490 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4491 $r = sql_query($query);
4492 if ($o = sql_fetch_object($r))
4493 $this->error(_ERROR_SKINDEFDELETE . ENTITY::hsc($o->bname));
4497 $skin = new SKIN($skinid);
4498 $name = $skin->getName();
4499 $desc = $skin->getDescription();
4502 <h2><?php echo _DELETE_CONFIRM?></h2>
4505 <?php echo _CONFIRMTXT_SKIN?><b><?php echo ENTITY::hsc($name) ?></b> (<?php echo ENTITY::hsc($desc)?>)
4508 <form method="post" action="index.php"><div>
4509 <input type="hidden" name="action" value="skindeleteconfirm" />
4510 <?php $manager->addTicketHidden() ?>
4511 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4512 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4519 * @todo document this
4521 function action_skindeleteconfirm() {
4522 global $member, $CONF, $manager;
4524 $skinid = intRequestVar('skinid');
4526 $member->isAdmin() or $this->disallow();
4528 // don't allow default skin to be deleted
4529 if ($skinid == $CONF['BaseSkin'])
4530 $this->error(_ERROR_DEFAULTSKIN);
4532 // don't allow deletion of default skins for blogs
4533 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4534 $r = sql_query($query);
4535 if ($o = sql_fetch_object($r))
4536 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4538 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4540 // 1. delete description
4541 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4544 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4546 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4548 $this->action_skinoverview();
4552 * @todo document this
4554 function action_skinremovetype() {
4555 global $member, $manager, $CONF;
4557 $skinid = intRequestVar('skinid');
4558 $skintype = requestVar('type');
4560 if (!isValidShortName($skintype)) {
4561 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4564 $member->isAdmin() or $this->disallow();
4566 // don't allow default skinparts to be deleted
4567 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4568 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4573 $skin = new SKIN($skinid);
4574 $name = $skin->getName();
4575 $desc = $skin->getDescription();
4578 <h2><?php echo _DELETE_CONFIRM?></h2>
4581 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo ENTITY::hsc($skintype); ?> (<?php echo ENTITY::hsc($name); ?>)</b> (<?php echo ENTITY::hsc($desc)?>)
4584 <form method="post" action="index.php"><div>
4585 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4586 <?php $manager->addTicketHidden() ?>
4587 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4588 <input type="hidden" name="type" value="<?php echo ENTITY::hsc($skintype); ?>" />
4589 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4596 * @todo document this
4598 function action_skinremovetypeconfirm() {
4599 global $member, $CONF, $manager;
4601 $skinid = intRequestVar('skinid');
4602 $skintype = requestVar('type');
4604 if (!isValidShortName($skintype)) {
4605 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4608 $member->isAdmin() or $this->disallow();
4610 // don't allow default skinparts to be deleted
4611 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4612 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4615 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4618 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4620 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4622 $this->action_skinedit();
4626 * @todo document this
4628 function action_skinclone() {
4631 $skinid = intRequestVar('skinid');
4633 $member->isAdmin() or $this->disallow();
4635 // 1. read skin to clone
4636 $skin = new SKIN($skinid);
4638 $name = "clone_" . $skin->getName();
4640 // if a skin with that name already exists:
4641 if (SKIN::exists($name)) {
4643 while (SKIN::exists($name . $i))
4648 // 2. create skin desc
4649 $newid = SKIN::createNew(
4651 $skin->getDescription(),
4652 $skin->getContentType(),
4653 $skin->getIncludeMode(),
4654 $skin->getIncludePrefix()
4660 $this->skinclonetype($skin, $newid, 'index');
4661 $this->skinclonetype($skin, $newid, 'item');
4662 $this->skinclonetype($skin, $newid, 'archivelist');
4663 $this->skinclonetype($skin, $newid, 'archive');
4664 $this->skinclonetype($skin, $newid, 'search');
4665 $this->skinclonetype($skin, $newid, 'error');
4666 $this->skinclonetype($skin, $newid, 'member');
4667 $this->skinclonetype($skin, $newid, 'imagepopup');
4670 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4671 $res = sql_query($query);
4672 while ($row = sql_fetch_assoc($res)) {
4673 $this->skinclonetype($skin, $newid, $row['stype']);
4676 $this->action_skinoverview();
4681 * @todo document this
4683 function skinclonetype($skin, $newid, $type) {
4684 $newid = intval($newid);
4685 $content = $skin->getContent($type);
4687 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
4693 * @todo document this
4695 function action_settingsedit() {
4696 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4698 $member->isAdmin() or $this->disallow();
4702 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4705 <h2><?php echo _SETTINGS_TITLE?></h2>
4707 <form action="index.php" method="post">
4710 <input type="hidden" name="action" value="settingsupdate" />
4711 <?php $manager->addTicketHidden() ?>
4714 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4716 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4719 $query = 'SELECT bname as text, bnumber as value'
4720 . ' FROM '.sql_table('blog');
4721 $template['name'] = 'DefaultBlog';
4722 $template['selected'] = $CONF['DefaultBlog'];
4723 $template['tabindex'] = 10;
4724 showlist($query,'select',$template);
4728 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4731 $query = 'SELECT sdname as text, sdnumber as value'
4732 . ' FROM '.sql_table('skin_desc');
4733 $template['name'] = 'BaseSkin';
4734 $template['selected'] = $CONF['BaseSkin'];
4735 $template['tabindex'] = 1;
4736 showlist($query,'select',$template);
4740 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4741 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo ENTITY::hsc($CONF['AdminEmail']) ?>" /></td>
4743 <td><?php echo _SETTINGS_SITENAME?></td>
4744 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo ENTITY::hsc($CONF['SiteName']) ?>" /></td>
4746 <td><?php echo _SETTINGS_SITEURL?></td>
4747 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo ENTITY::hsc($CONF['IndexURL']) ?>" /></td>
4749 <td><?php echo _SETTINGS_ADMINURL?></td>
4750 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo ENTITY::hsc($CONF['AdminURL']) ?>" /></td>
4752 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4753 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo ENTITY::hsc($CONF['PluginURL']) ?>" /></td>
4755 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4756 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo ENTITY::hsc($CONF['SkinsURL']) ?>" /></td>
4758 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4759 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo ENTITY::hsc($CONF['ActionURL']) ?>" /></td>
4761 <td><?php echo _SETTINGS_LOCALE?> <?php help('locale'); ?>
4764 <select name="Locale" tabindex="10050">
4766 $locales = i18n::get_available_locale_list();
4767 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4769 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4773 echo "<option value=\"\">en_Latn_US</option>\n";
4776 foreach ( $locales as $locale )
4778 if ( $locale == 'en_Latn_US' )
4782 if ( $locale == i18n::get_current_locale() )
4784 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4788 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4796 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4798 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4800 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo ENTITY::hsc($CONF['DisableSiteURL'])?>" />
4803 <td><?php echo _SETTINGS_DIRS?></td>
4804 <td><?php echo ENTITY::hsc($DIR_NUCLEUS) ?>
4805 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4807 <td><?php echo _SETTINGS_DBLOGIN?></td>
4808 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4812 echo _SETTINGS_JSTOOLBAR
4813 /* =_SETTINGS_DISABLEJS
4815 I temporary changed the meaning of DisableJsTools, until I can find a good
4816 way to select the javascript version to use
4820 1 : all javascript disabled
4821 2 : 'simpler' javascript (for mozilla/opera/mac)
4825 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4826 <select name="DisableJsTools" tabindex="10075">
4827 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4828 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4829 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4830 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4831 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4832 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4837 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4840 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4841 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4843 echo ' ', _SETTINGS_URLMODE_HELP;
4849 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
4852 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
4858 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
4861 if (!array_key_exists('DefaultListSize',$CONF)) {
4862 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
4863 $CONF['DefaultListSize'] = 10;
4866 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo ENTITY::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
4869 <td><?php echo _SETTINGS_ADMINCSS?>
4873 <select name="AdminCSS" tabindex="10080">
4874 <?php // show a dropdown list of all available admin css files
4875 global $DIR_NUCLEUS;
4877 $dirhandle = opendir($DIR_NUCLEUS."styles/");
4879 while ($filename = readdir($dirhandle) )
4882 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
4883 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
4885 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
4888 $name = $matches[1];
4889 echo "<option value=\"$name\"";
4891 if ($name == $CONF['AdminCSS'])
4893 echo " selected=\"selected\"";
4896 echo ">$name</option>";
4902 closedir($dirhandle);
4909 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4911 <td><?php echo _SETTINGS_MEDIADIR?></td>
4912 <td><?php echo ENTITY::hsc($DIR_MEDIA) ?>
4913 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4914 <?php if (!is_dir($DIR_MEDIA))
4915 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4916 if (!is_readable($DIR_MEDIA))
4917 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4918 if (!is_writeable($DIR_MEDIA))
4919 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4923 <td><?php echo _SETTINGS_MEDIAURL?></td>
4925 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo ENTITY::hsc($CONF['MediaURL']) ?>" />
4928 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4929 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4931 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4933 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo ENTITY::hsc($CONF['AllowedTypes']) ?>" />
4936 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4938 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo ENTITY::hsc($CONF['MaxUploadSize']) ?>" />
4941 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4942 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4945 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4947 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4948 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4950 <td><?php echo _SETTINGS_ALLOWCREATE?>
4951 <?php help('allowaccountcreation'); ?>
4953 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4956 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4957 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4959 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4962 <td><?php echo _SETTINGS_MEMBERMSGS?>
4963 <?php help('messageservice'); ?>
4965 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
4968 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
4969 <?php help('messageservice'); ?>
4971 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
4974 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
4975 <?php help('protectmemnames'); ?>
4977 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
4983 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
4985 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
4986 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo ENTITY::hsc($CONF['CookiePrefix'])?>" /></td>
4988 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
4989 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo ENTITY::hsc($CONF['CookieDomain'])?>" /></td>
4991 <td><?php echo _SETTINGS_COOKIEPATH?></td>
4992 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo ENTITY::hsc($CONF['CookiePath'])?>" /></td>
4994 <td><?php echo _SETTINGS_COOKIESECURE?></td>
4995 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
4997 <td><?php echo _SETTINGS_COOKIELIFE?></td>
4998 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
4999 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5002 <td><?php echo _SETTINGS_LASTVISIT?></td>
5003 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5008 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5010 <td><?php echo _SETTINGS_UPDATE?></td>
5011 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5018 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5021 'GeneralSettingsFormExtras',
5029 * ADMIN::action_settingsupdate()
5030 * Update $CONFIG and redirect
5035 function action_settingsupdate() {
5036 global $member, $CONF;
5038 $member->isAdmin() or $this->disallow();
5040 // check if email address for admin is valid
5041 if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
5043 $this->error(_ERROR_BADMAILADDRESS);
5047 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5048 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5049 $this->updateConfig('IndexURL', postVar('IndexURL'));
5050 $this->updateConfig('AdminURL', postVar('AdminURL'));
5051 $this->updateConfig('PluginURL', postVar('PluginURL'));
5052 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5053 $this->updateConfig('ActionURL', postVar('ActionURL'));
5054 $this->updateConfig('Locale', postVar('Locale'));
5055 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5056 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5057 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5058 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5059 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5060 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5061 $this->updateConfig('SiteName', postVar('SiteName'));
5062 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5063 $this->updateConfig('DisableSite', postVar('DisableSite'));
5064 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5065 $this->updateConfig('LastVisit', postVar('LastVisit'));
5066 $this->updateConfig('MediaURL', postVar('MediaURL'));
5067 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5068 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5069 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5070 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5071 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5072 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5073 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5074 $this->updateConfig('CookiePath', postVar('CookiePath'));
5075 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5076 $this->updateConfig('URLMode', postVar('URLMode'));
5077 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5078 $this->updateConfig('DebugVars', postVar('DebugVars'));
5079 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5080 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5082 // load new config and redirect (this way, the new locale will be used is necessary)
5083 // note that when changing cookie settings, this redirect might cause the user
5084 // to have to log in again.
5086 redirect($CONF['AdminURL'] . '?action=manage');
5091 * ADMIN::action_systemoverview()
5092 * Output system overview
5097 function action_systemoverview()
5099 global $member, $nucleus, $CONF;
5103 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5105 if ( $member->isLoggedIn() && $member->isAdmin() )
5107 // Information about the used PHP and MySQL installation
5108 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
5110 // Version of PHP MySQL
5111 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
5114 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5119 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5120 echo '<td>' . phpversion() . "</td>\n";
5123 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5124 echo '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5127 echo "</table>\n\n";
5129 // Important PHP settings
5130 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
5133 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5138 echo '<td>magic_quotes_gpc' . "</td>\n";
5139 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5140 echo '<td>' . $mqg . "</td>\n";
5143 echo '<td>magic_quotes_runtime' . "</td>\n";
5144 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5145 echo '<td>' . $mqr . "</td>\n";
5148 echo '<td>register_globals' . "</td>\n";
5149 $rg = ini_get('register_globals') ? 'On' : 'Off';
5150 echo '<td>' . $rg . "</td>\n";
5153 echo "</table>\n\n";
5155 // Information about GD library
5156 $gdinfo = gd_info();
5157 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
5160 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5164 foreach ( $gdinfo as $key=>$value )
5166 if ( is_bool($value) )
5168 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5172 $value = ENTITY::hsc($value);
5175 echo '<td>' . $key . "</td>\n";
5176 echo '<td>' . $value . "</td>\n";
5180 echo "</table>\n\n";
5182 // Check if special modules are loaded
5184 phpinfo(INFO_MODULES);
5185 $im = ob_get_contents();
5187 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
5190 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5194 echo '<td>mod_rewrite' . "</td>\n";
5195 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5196 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5197 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5198 echo '<td>' . $modrewrite . "</td>\n";
5201 echo "</table>\n\n";
5203 // Information about the used Nucleus CMS
5204 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5206 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5207 $np = getNucleusPatchLevel();
5208 echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
5211 echo '<th colspan="2">Nucleus CMS' . "</th>\n";
5216 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5217 echo '<td>' . $nv . "</td>\n";
5220 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5221 echo '<td>' . $np . "</td>\n";
5224 echo "</table>\n\n";
5226 // Important settings of the installation
5227 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
5230 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5235 echo '<td>' . '$CONF[' . "'Self']</td>\n";
5236 echo '<td>' . $CONF['Self'] . "</td>\n";
5239 echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
5240 echo '<td>' . $CONF['ItemURL'] . "</td>\n";
5243 echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5244 $ohs = $CONF['alertOnHeadersSent'] ?
5245 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5246 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5247 echo '<td>' . $ohs . "</td>\n";
5250 echo "<td>i18n::get_current_charset()</td>\n";
5251 echo '<td>' . i18n::get_current_charset() . "</td>\n";
5254 echo "</table>\n\n";
5256 // Link to the online version test at the Nucleus CMS website
5257 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5258 if ( $nucleus['codename'] != '')
5260 $codenamestring = ' "' . $nucleus['codename'] . '"';
5264 $codenamestring = '';
5266 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5267 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5268 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5269 echo 'Nucleus CMS ' . $nv . $codenamestring;
5274 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5280 * ADMIN::updateConfig()
5282 * @param string $name
5283 * @param string $val
5284 * @return integer return the ID in which the latest query posted
5286 function updateConfig($name, $val)
5288 $name = sql_real_escape_string($name);
5289 $val = trim(sql_real_escape_string($val));
5291 $query = "UPDATE %s SET value='%s' WHERE name='%s'";
5292 $query = sprintf($query, sql_table('config'), $val, $name);
5293 sql_query($query) or die("Query error: " . sql_error());
5294 return sql_insert_id();
5299 * @param string $msg message that will be shown
5301 function error($msg)
5305 echo "<h2>Error!</h2>\n";
5308 echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
5315 * add error log and show error page
5322 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5323 $this->error(_ERROR_DISALLOWED);
5328 * Output admin page head
5333 function pagehead($extrahead = '')
5335 global $member, $nucleus, $CONF, $manager;
5340 'extrahead' => &$extrahead,
5341 'action' => $this->action));
5343 $baseUrl = ENTITY::hsc($CONF['AdminURL']);
5344 if ( !array_key_exists('AdminCSS',$CONF) )
5346 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5347 $CONF['AdminCSS'] = 'original';
5350 /* HTTP 1.1 application for no caching */
5351 header("Cache-Control: no-cache, must-revalidate");
5352 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5354 $root_element = 'html';
5355 $charset = i18n::get_current_charset();
5356 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5358 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5359 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5360 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5362 echo '<title>' . ENTITY::hsc($CONF['SiteName']) . " - Admin</title>\n";
5363 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5364 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
5365 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
5366 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
5367 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
5368 echo "{$extrahead}\n";
5371 echo "<div id=\"adminwrapper\">\n";
5372 echo "<div class=\"header\">\n";
5373 echo '<h1>' . ENTITY::hsc($CONF['SiteName']) . "</h1>\n";
5375 echo "<div id=\"container\">\n";
5376 echo "<div id=\"content\">\n";
5377 echo "<div class=\"loginname\">\n";
5378 if ( $member->isLoggedIn() )
5380 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5381 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5385 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5387 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5390 if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
5392 $codenamestring = ' "' . $nucleus['codename'].'"';
5396 $codenamestring = '';
5399 if ( $member->isLoggedIn() && $member->isAdmin() )
5401 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5402 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5404 $newestVersion = getLatestVersion();
5405 $newestCompare = str_replace('/','.',$newestVersion);
5406 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5407 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5410 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5411 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5417 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5426 * Output admin page foot include quickmenu
5433 global $action, $member, $manager;
5437 array('action' => $this->action)
5440 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5442 echo '<h2>' . _LOGOUT . "</h2>\n";
5444 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5445 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5449 echo "<div class=\"foot\">\n";
5450 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5452 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5455 echo "<!-- content -->\n";
5456 echo "<div id=\"quickmenu\">\n";
5458 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5461 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5464 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5465 echo "<form method=\"get\" action=\"index.php\">\n";
5467 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5469 $showAll = requestVar('showall');
5471 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5473 // Super-Admins have access to all blogs! (no add item support though)
5474 $query = 'SELECT bnumber as value, bname as text'
5475 . ' FROM ' . sql_table('blog')
5476 . ' ORDER BY bname';
5480 $query = 'SELECT bnumber as value, bname as text'
5481 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5482 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5483 . ' ORDER BY bname';
5485 $template['name'] = 'blogid';
5486 $template['tabindex'] = 15000;
5487 $template['extra'] = _QMENU_ADD_SELECT;
5488 $template['selected'] = -1;
5489 $template['shorten'] = 10;
5490 $template['shortenel'] = '';
5491 $template['javascript'] = 'onchange="return form.submit()"';
5492 showlist($query,'select',$template);
5497 echo "<h2>{$member->getDisplayName()}</h2>\n";
5499 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5500 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5501 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5504 // ---- general settings ----
5505 if ( $member->isAdmin() )
5507 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5509 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5510 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5511 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5512 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5513 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5514 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5515 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5518 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5520 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5521 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5522 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5526 $aPluginExtras = array();
5530 'options' => &$aPluginExtras));
5532 if ( count($aPluginExtras) > 0 )
5534 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5536 foreach ( $aPluginExtras as $aInfo )
5538 echo '<li><a href="' . ENTITY::hsc($aInfo['url']) . '" title="' . ENTITY::hsc($aInfo['tooltip']) . '">' . ENTITY::hsc($aInfo['title']) . "</a></li>\n";
5543 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5546 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5550 // introduction text on login screen
5551 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5554 echo "<!-- quickmenu -->\n";
5557 echo "<!-- content -->\n";
5560 echo "<!-- container -->\n";
5563 echo "<!-- adminwrapper -->\n";
5572 * @todo document this
5574 function action_regfile() {
5575 global $member, $CONF;
5577 $blogid = intRequestVar('blogid');
5579 $member->teamRights($blogid) or $this->disallow();
5581 // header-code stolen from phpMyAdmin
5582 // REGEDIT and bookmarklet code stolen from GreyMatter
5584 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5587 header('Content-Type: application/octetstream');
5588 header('Content-Disposition: filename="nucleus.reg"');
5589 header('Pragma: no-cache');
5590 header('Expires: 0');
5593 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5594 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5595 echo '"contexts"=hex:31';
5599 * @todo document this
5601 function action_bookmarklet() {
5602 global $member, $manager;
5604 $blogid = intRequestVar('blogid');
5606 $member->teamRights($blogid) or $this->disallow();
5608 $blog =& $manager->getBlog($blogid);
5609 $bm = getBookmarklet($blogid);
5613 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5617 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
5620 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
5623 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
5625 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
5628 <?php echo '<a href="' . ENTITY::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, ENTITY::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
5631 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
5634 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5635 $url = $manager->addTicketToUrl($url);
5637 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . ENTITY::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
5641 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
5644 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
5646 <?php echo _BOOKMARKLET_DELETEBAR ?>
5650 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
5654 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
5655 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
5656 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
5657 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
5658 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
5667 * @todo document this
5669 function action_actionlog() {
5670 global $member, $manager;
5672 $member->isAdmin() or $this->disallow();
5676 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5678 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5681 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5682 <p><a href="<?php echo ENTITY::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5684 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5686 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5687 $template['content'] = 'actionlist';
5688 $amount = showlist($query,'table',$template);
5695 * @todo document this
5697 function action_banlist() {
5698 global $member, $manager;
5700 $blogid = intRequestVar('blogid');
5702 $member->blogAdminRights($blogid) or $this->disallow();
5704 $blog =& $manager->getBlog($blogid);
5708 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5710 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5712 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5713 $template['content'] = 'banlist';
5714 $amount = showlist($query,'table',$template);
5719 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5720 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5728 * @todo document this
5730 function action_banlistdelete() {
5731 global $member, $manager;
5733 $blogid = intRequestVar('blogid');
5734 $iprange = requestVar('iprange');
5736 $member->blogAdminRights($blogid) or $this->disallow();
5738 $blog =& $manager->getBlog($blogid);
5739 $banBlogName = ENTITY::hsc($blog->getName());
5743 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5745 <form method="post" action="index.php">
5747 <h3><?php echo _BAN_IPRANGE?></h3>
5750 <?php echo _CONFIRMTXT_BAN?> <?php echo ENTITY::hsc($iprange) ?>
5751 <input name="iprange" type="hidden" value="<?php echo ENTITY::hsc($iprange)?>" />
5754 <h3><?php echo _BAN_BLOGS?></h3>
5757 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5758 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
5759 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
5761 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5764 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5767 <?php $manager->addTicketHidden() ?>
5768 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5769 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5778 * @todo document this
5780 function action_banlistdeleteconfirm() {
5781 global $member, $manager;
5783 $blogid = intPostVar('blogid');
5784 $allblogs = postVar('allblogs');
5785 $iprange = postVar('iprange');
5787 $member->blogAdminRights($blogid) or $this->disallow();
5792 if (BAN::removeBan($blogid, $iprange))
5793 array_push($deleted, $blogid);
5795 // get blogs fot which member has admin rights
5796 $adminblogs = $member->getAdminBlogs();
5797 foreach ($adminblogs as $blogje) {
5798 if (BAN::removeBan($blogje, $iprange))
5799 array_push($deleted, $blogje);
5803 if (sizeof($deleted) == 0)
5804 $this->error(_ERROR_DELETEBAN);
5808 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5809 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5810 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5813 foreach ($deleted as $delblog) {
5814 $b =& $manager->getBlog($delblog);
5815 echo "<li>" . ENTITY::hsc($b->getName()). "</li>";
5824 * @todo document this
5826 function action_banlistnewfromitem() {
5827 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5831 * @todo document this
5833 function action_banlistnew($blogid = '') {
5834 global $member, $manager;
5837 $blogid = intRequestVar('blogid');
5839 $ip = requestVar('ip');
5841 $member->blogAdminRights($blogid) or $this->disallow();
5843 $blog =& $manager->getBlog($blogid);
5847 <h2><?php echo _BAN_ADD_TITLE?></h2>
5850 <form method="post" action="index.php">
5852 <h3><?php echo _BAN_IPRANGE?></h3>
5854 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5857 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
5858 <?php echo _BAN_EXAMPLE_TEXT ?>
5864 $iprangeVal = ENTITY::hsc($ip);
5866 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
5867 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
5869 <input name="iprange" type="radio" value="custom" id="ip_custom" />
5870 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
5871 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
5874 echo "<input name='iprange' value='custom' type='hidden' />";
5875 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5880 <h3><?php echo _BAN_BLOGS?></h3>
5882 <p><?php echo _BAN_BLOGS_TEXT?></p>
5885 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5886 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo ENTITY::hsc($blog->getName())?>'</label>
5888 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5891 <h3><?php echo _BAN_REASON_TITLE?></h3>
5893 <p><?php echo _BAN_REASON_TEXT?></p>
5895 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5897 <h3><?php echo _BAN_ADD_TITLE?></h3>
5900 <input name="action" type="hidden" value="banlistadd" />
5901 <?php $manager->addTicketHidden() ?>
5902 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5907 <?php $this->pagefoot();
5911 * @todo document this
5913 function action_banlistadd() {
5916 $blogid = intPostVar('blogid');
5917 $allblogs = postVar('allblogs');
5918 $iprange = postVar('iprange');
5919 if ($iprange == "custom")
5920 $iprange = postVar('customiprange');
5921 $reason = postVar('reason');
5923 $member->blogAdminRights($blogid) or $this->disallow();
5925 // TODO: check IP range validity
5928 if (!BAN::addBan($blogid, $iprange, $reason))
5929 $this->error(_ERROR_ADDBAN);
5931 // get blogs fot which member has admin rights
5932 $adminblogs = $member->getAdminBlogs();
5934 foreach ($adminblogs as $blogje) {
5935 if (!BAN::addBan($blogje, $iprange, $reason))
5939 $this->error(_ERROR_ADDBAN);
5942 $this->action_banlist();
5947 * @todo document this
5949 function action_clearactionlog() {
5952 $member->isAdmin() or $this->disallow();
5956 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5960 * @todo document this
5962 function action_backupoverview() {
5963 global $member, $manager;
5965 $member->isAdmin() or $this->disallow();
5969 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5971 <h2><?php echo _BACKUPS_TITLE?></h2>
5973 <h3><?php echo _BACKUP_TITLE?></h3>
5975 <p><?php echo _BACKUP_INTRO?></p>
5977 <form method="post" action="index.php"><p>
5978 <input type="hidden" name="action" value="backupcreate" />
5979 <?php $manager->addTicketHidden() ?>
5981 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
5983 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
5985 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
5989 <div class="note"><?php echo _BACKUP_NOTE?></div>
5992 <h3><?php echo _RESTORE_TITLE?></h3>
5994 <div class="note"><?php echo _RESTORE_NOTE?></div>
5996 <p><?php echo _RESTORE_INTRO?></p>
5998 <form method="post" action="index.php" enctype="multipart/form-data"><p>
5999 <input type="hidden" name="action" value="backuprestore" />
6000 <?php $manager->addTicketHidden() ?>
6001 <input name="backup_file" type="file" tabindex="30" />
6003 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
6004 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
6005 <br /><?php echo _RESTORE_WARNING?>
6008 <?php $this->pagefoot();
6012 * @todo document this
6014 function action_backupcreate() {
6015 global $member, $DIR_LIBS;
6017 $member->isAdmin() or $this->disallow();
6019 // use compression ?
6020 $useGzip = intval(postVar('gzip'));
6022 include($DIR_LIBS . 'backup.php');
6024 // try to extend time limit
6025 // (creating/restoring dumps might take a while)
6026 @set_time_limit(1200);
6029 $bu->do_backup($useGzip);
6034 * @todo document this
6036 function action_backuprestore() {
6037 global $member, $DIR_LIBS;
6039 $member->isAdmin() or $this->disallow();
6041 if (intPostVar('letsgo') != 1)
6042 $this->error(_ERROR_BACKUP_NOTSURE);
6044 include($DIR_LIBS . 'backup.php');
6046 // try to extend time limit
6047 // (creating/restoring dumps might take a while)
6048 @set_time_limit(1200);
6051 $message = $bu->do_restore();
6053 $this->error($message);
6057 <h2><?php echo _RESTORE_COMPLETE?></h2>
6058 <?php $this->pagefoot();
6063 * @todo document this
6065 function action_pluginlist() {
6066 global $member, $manager;
6069 $member->isAdmin() or $this->disallow();
6073 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6075 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6077 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6080 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6082 $template['content'] = 'pluginlist';
6083 $template['tabindex'] = 10;
6084 showlist($query, 'table', $template);
6087 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
6089 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
6091 <form method="post" action="index.php"><div>
6092 <input type="hidden" name="action" value="pluginupdate" />
6093 <?php $manager->addTicketHidden() ?>
6094 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
6097 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
6100 // find a list of possibly non-installed plugins
6101 $candidates = array();
6103 global $DIR_PLUGINS;
6105 $dirhandle = opendir($DIR_PLUGINS);
6107 while ($filename = readdir($dirhandle) )
6110 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
6111 # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
6113 if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6116 $name = $matches[1];
6117 // only show in list when not yet installed
6118 $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
6120 if (sql_num_rows($res) == 0)
6122 array_push($candidates, $name);
6129 closedir($dirhandle);
6131 if (sizeof($candidates) > 0)
6134 <p><?php echo _PLUGS_ADD_TEXT?></p>
6136 <form method='post' action='index.php'><div>
6137 <input type='hidden' name='action' value='pluginadd' />
6138 <?php $manager->addTicketHidden() ?>
6139 <select name="filename" tabindex="30">
6141 foreach($candidates as $name)
6143 echo '<option value="NP_',$name,'">',ENTITY::hsc($name),'</option>';
6147 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
6154 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6162 * @todo document this
6164 function action_pluginhelp() {
6165 global $member, $manager, $DIR_PLUGINS, $CONF;
6168 $member->isAdmin() or $this->disallow();
6170 $plugid = intGetVar('plugid');
6172 if (!$manager->pidInstalled($plugid))
6173 $this->error(_ERROR_NOSUCHPLUGIN);
6175 $plugName = getPluginNameFromPid($plugid);
6179 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6181 echo '<h2>',_PLUGS_HELP_TITLE,': ',ENTITY::hsc($plugName),'</h2>';
6183 $plug =& $manager->getPlugin($plugName);
6184 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6186 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6187 @readfile($helpFile);
6189 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6190 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6198 * @todo document this
6200 function action_pluginadd() {
6201 global $member, $manager, $DIR_PLUGINS;
6204 $member->isAdmin() or $this->disallow();
6206 $name = postVar('filename');
6208 if ($manager->pluginInstalled($name))
6209 $this->error(_ERROR_DUPPLUGIN);
6210 if (!checkPlugin($name))
6211 $this->error(_ERROR_PLUGFILEERROR . ' (' . ENTITY::hsc($name) . ')');
6213 // get number of currently installed plugins
6214 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6215 $numCurrent = sql_num_rows($res);
6217 // plugin will be added as last one in the list
6218 $newOrder = $numCurrent + 1;
6227 // do this before calling getPlugin (in case the plugin id is used there)
6228 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6230 $iPid = sql_insert_id();
6232 $manager->clearCachedInfo('installedPlugins');
6234 // Load the plugin for condition checking and instalation
6235 $plugin =& $manager->getPlugin($name);
6237 // check if it got loaded (could have failed)
6240 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6241 $manager->clearCachedInfo('installedPlugins');
6242 $this->error(_ERROR_PLUGIN_LOAD);
6245 // check if plugin needs a newer Nucleus version
6246 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
6248 // uninstall plugin again...
6249 $this->deleteOnePlugin($plugin->getID());
6251 // ...and show error
6252 $this->error(_ERROR_NUCLEUSVERSIONREQ . ENTITY::hsc($plugin->getMinNucleusVersion()));
6255 // check if plugin needs a newer Nucleus version
6256 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
6258 // uninstall plugin again...
6259 $this->deleteOnePlugin($plugin->getID());
6261 // ...and show error
6262 $this->error(_ERROR_NUCLEUSVERSIONREQ . ENTITY::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6265 $pluginList = $plugin->getPluginDep();
6266 foreach ($pluginList as $pluginName)
6269 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6270 if (sql_num_rows($res) == 0)
6272 // uninstall plugin again...
6273 $this->deleteOnePlugin($plugin->getID());
6275 $this->error(sprintf(_ERROR_INSREQPLUGIN, ENTITY::hsc($pluginName)));
6279 // call the install method of the plugin
6285 'plugin' => &$plugin
6289 // update all events
6290 $this->action_pluginupdate();
6294 * @todo document this
6296 function action_pluginupdate() {
6297 global $member, $manager, $CONF;
6300 $member->isAdmin() or $this->disallow();
6302 // delete everything from plugin_events
6303 sql_query('DELETE FROM '.sql_table('plugin_event'));
6305 // loop over all installed plugins
6306 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6307 while($o = sql_fetch_object($res)) {
6309 $plug =& $manager->getPlugin($o->pfile);
6312 $eventList = $plug->getEventList();
6313 foreach ($eventList as $eventName)
6314 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
6318 redirect($CONF['AdminURL'] . '?action=pluginlist');
6319 // $this->action_pluginlist();
6323 * @todo document this
6325 function action_plugindelete() {
6326 global $member, $manager;
6329 $member->isAdmin() or $this->disallow();
6331 $pid = intGetVar('plugid');
6333 if (!$manager->pidInstalled($pid))
6334 $this->error(_ERROR_NOSUCHPLUGIN);
6338 <h2><?php echo _DELETE_CONFIRM?></h2>
6340 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6342 <form method="post" action="index.php"><div>
6343 <?php $manager->addTicketHidden() ?>
6344 <input type="hidden" name="action" value="plugindeleteconfirm" />
6345 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6346 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6353 * @todo document this
6355 function action_plugindeleteconfirm() {
6356 global $member, $manager, $CONF;
6359 $member->isAdmin() or $this->disallow();
6361 $pid = intPostVar('plugid');
6363 $error = $this->deleteOnePlugin($pid, 1);
6365 $this->error($error);
6368 redirect($CONF['AdminURL'] . '?action=pluginlist');
6369 // $this->action_pluginlist();
6373 * @todo document this
6375 function deleteOnePlugin($pid, $callUninstall = 0) {
6378 $pid = intval($pid);
6380 if (!$manager->pidInstalled($pid))
6381 return _ERROR_NOSUCHPLUGIN;
6383 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6385 /* // call the unInstall method of the plugin
6386 if ($callUninstall) {
6387 $plugin =& $manager->getPlugin($name);
6388 if ($plugin) $plugin->unInstall();
6391 // check dependency before delete
6392 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6393 while($o = sql_fetch_object($res)) {
6394 $plug =& $manager->getPlugin($o->pfile);
6397 $depList = $plug->getPluginDep();
6398 foreach ($depList as $depName)
6400 if ($name == $depName)
6402 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6408 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6410 // call the unInstall method of the plugin
6411 if ($callUninstall) {
6412 $plugin =& $manager->getPlugin($name);
6413 if ($plugin) $plugin->unInstall();
6416 // delete all subscriptions
6417 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6419 // delete all options
6420 // get OIDs from plugin_option_desc
6421 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6423 while ($o = sql_fetch_object($res)) {
6424 array_push($aOIDs, $o->oid);
6427 // delete from plugin_option and plugin_option_desc
6428 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6429 if (count($aOIDs) > 0)
6430 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6432 // update order numbers
6433 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6434 $o = sql_fetch_object($res);
6435 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6438 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6440 $manager->clearCachedInfo('installedPlugins');
6441 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6447 * @todo document this
6449 function action_pluginup() {
6450 global $member, $manager, $CONF;
6453 $member->isAdmin() or $this->disallow();
6455 $plugid = intGetVar('plugid');
6457 if (!$manager->pidInstalled($plugid))
6458 $this->error(_ERROR_NOSUCHPLUGIN);
6460 // 1. get old order number
6461 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6462 $o = sql_fetch_object($res);
6463 $oldOrder = $o->porder;
6465 // 2. calculate new order number
6466 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6468 // 3. update plug numbers
6469 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6470 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6472 //$this->action_pluginlist();
6473 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6474 redirect($CONF['AdminURL'] . '?action=pluginlist');
6478 * @todo document this
6480 function action_plugindown() {
6481 global $member, $manager, $CONF;
6484 $member->isAdmin() or $this->disallow();
6486 $plugid = intGetVar('plugid');
6487 if (!$manager->pidInstalled($plugid))
6488 $this->error(_ERROR_NOSUCHPLUGIN);
6490 // 1. get old order number
6491 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6492 $o = sql_fetch_object($res);
6493 $oldOrder = $o->porder;
6495 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6496 $maxOrder = sql_num_rows($res);
6498 // 2. calculate new order number
6499 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6501 // 3. update plug numbers
6502 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6503 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6505 //$this->action_pluginlist();
6506 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6507 redirect($CONF['AdminURL'] . '?action=pluginlist');
6511 * ADMIN::action_pluginoptions()
6513 * Output Plugin option page
6516 * @param string $message message when fallbacked
6520 public function action_pluginoptions($message = '')
6522 global $member, $manager;
6525 $member->isAdmin() or $this->disallow();
6527 $pid = (integer) requestVar('plugid');
6528 if ( !$manager->pidInstalled($pid) )
6530 $this->error(_ERROR_NOSUCHPLUGIN);
6533 $pname = getPluginNameFromPid($pid);
6535 /* just for including translation */
6536 $manager->getPlugin($pname);
6538 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
6539 $this->pagehead($extrahead);
6540 echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
6541 echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, ENTITY::hsc($pname)) . "</h2>\n";
6543 if ( isset($message) )
6548 echo "<form action=\"index.php\" method=\"post\">\n";
6550 echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
6551 echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
6552 $manager->addTicketHidden();
6554 $aOptions = array();
6556 $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
6557 $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
6558 $result = sql_query($query);
6559 while ( $object = sql_fetch_object($result) )
6561 array_push($aOIDs, $object->oid);
6562 $aOptions[$object->oid] = array(
6563 'oid' => $object->oid,
6564 'value' => $object->odef,
6565 'name' => $object->oname,
6566 'description' => $object->odesc,
6567 'type' => $object->otype,
6568 'typeinfo' => $object->oextra,
6572 // fill out actual values
6573 if ( count($aOIDs) > 0 )
6575 $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
6576 $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
6577 $result = sql_query($query);
6578 while ( $object = sql_fetch_object($result) )
6580 $aOptions[$object->oid]['value'] = $object->ovalue;
6585 $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
6586 $manager->notify('PrePluginOptionsEdit',$data);
6588 $template['content'] = 'plugoptionlist';
6589 $amount = showlist($aOptions,'table',$template);
6592 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6602 * ADMIN::action_pluginoptionsupdate()
6604 * Update plugin options and fallback to plugin option page
6610 public function action_pluginoptionsupdate()
6612 global $member, $manager;
6615 $member->isAdmin() or $this->disallow();
6617 $pid = (integer) requestVar('plugid');
6618 if ( !$manager->pidInstalled($pid) )
6620 $this->error(_ERROR_NOSUCHPLUGIN);
6623 $aOptions = requestArray('plugoption');
6624 NucleusPlugin::apply_plugin_options($aOptions);
6626 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6628 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6633 * ADMIN::_insertPluginOptions()
6635 * Output plugin option field
6638 * @param string $context plugin option context
6639 * @param integer $contextid plugin option context id
6642 public function _insertPluginOptions($context, $contextid = 0)
6644 // get all current values for this contextid
6645 // (note: this might contain doubles for overlapping contextids)
6646 $aIdToValue = array();
6647 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6648 while ( $object = sql_fetch_object($res) )
6650 $aIdToValue[$object->oid] = $object->ovalue;
6653 // get list of oids per pid
6654 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6655 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
6656 $res = sql_query($query);
6657 $aOptions = array();
6658 while ( $object = sql_fetch_object($res) )
6660 if (in_array($object->oid, array_keys($aIdToValue)))
6662 $value = $aIdToValue[$object->oid];
6666 $value = $object->odef;
6669 array_push($aOptions, array(
6670 'pid' => $object->pid,
6671 'pfile' => $object->pfile,
6672 'oid' => $object->oid,
6674 'name' => $object->oname,
6675 'description' => $object->odesc,
6676 'type' => $object->otype,
6677 'typeinfo' => $object->oextra,
6678 'contextid' => $contextid,
6683 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6686 foreach ($aOptions as $aOption)
6689 if ( $iPrevPid != $aOption['pid'] )
6691 $iPrevPid = $aOption['pid'];
6692 if ( !defined('_PLUGIN_OPTIONS_TITLE') )
6694 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
6696 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, ENTITY::hsc($aOption['pfile'])).'</th></tr>';
6699 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
6700 if ( @$meta['access'] != 'hidden' )
6703 listplug_plugOptionRow($aOption);
6711 * ADMIN::input_yesno()
6712 * Output input elements with radio attribute for yes/no options
6714 * @param string $name name attribute
6715 * @param string $value_current current value attribute
6716 * @param integer $tabindex tab index
6717 * @param string $value_yes value attribute for yes option
6718 * @param string $value_no value attribute for no option
6719 * @param string $text_yes child text element for yes option
6720 * @param string $text_no child text element for no option
6721 * @param boolean $isAdmin have admin right or not
6724 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
6726 $id = preg_replace('#\[|\]#', '-', $name);
6727 $id_yes = $id . $value_yes;
6728 $id_no = $id . $value_no;
6731 echo '<input type="radio" id="' . ENTITY::hsc($id_yes) . '" name="' . ENTITY::hsc($name) . '" value="' . ENTITY::hsc($value_yes) . '"';
6732 if ( $name=="admin" )
6734 echo ' onclick="selectCanLogin(true);"';
6736 if ( $value_current == $value_yes )
6738 echo " tabindex='$tabindex' checked='checked'";
6741 echo '<label for="' . ENTITY::hsc($id_yes) . '">' . ENTITY::hsc($text_yes) . "</label>\n";
6744 echo '<input type="radio" id="' . ENTITY::hsc($id_no) . '" name="' . ENTITY::hsc($name) . '" value="' . ENTITY::hsc($value_no) . '"';
6745 if ( $name=="admin" )
6747 echo ' onclick="selectCanLogin(false);"';
6749 if ( $value_current != $value_yes )
6751 echo " tabindex='$tabindex' checked='checked'";
6753 if ($isAdmin && $name=="canlogin")
6755 echo ' disabled="disabled"';
6758 echo '<label for="' . ENTITY::hsc($id_no) . '">' . ENTITY::hsc($text_no) . "</label>\n";