OSDN Git Service

FIX: リファレンスにまつわるコードを修正
[nucleus-jp/nucleus-next.git] / nucleus / libs / AdminActions.php
1 <?php
2 /**
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2012 The Nucleus Group
5  *
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)
11  */
12 /**
13  * @license http://nucleuscms.org/license.txt GNU General Public License
14  * @copyright Copyright (C) 2002-2012 The Nucleus Group
15  * @version $Id: AdminActions.php 1661 2012-02-12 11:55:39Z sakamocchi $
16  */
17
18 class AdminActions extends BaseActions
19 {
20         private $skintype;
21         
22         /**
23          * AdminActions::$default_actions
24          * list of whole action names with which this class can deal
25          */
26         static private $default_actions = array(
27                 'actionurl',
28                 'addtickettourl',
29                 'adminurl',
30                 'codename',
31                 'customhelplink',
32                 'date',
33                 'extrahead',
34                 'headmessage',
35                 'helplink',
36                 'member',
37                 'newestcompare',
38                 'pagehead',
39                 'pagefoot',
40                 'qmenuaddselect',
41                 'quickmenu',
42                 'sitevar',
43                 'sprinttext',
44                 'ticket',
45                 'version',
46                 'versioncheckurl'
47         );
48         
49         /**
50          * AdminActions::$normal_skin_types
51          * friendly name for wrapped page types
52          */
53         static private $normal_skin_types = array(
54                 'actionlog'                             => _ADM_SKPRT_ACTIONLOG,
55                 'activate'                              => _ADM_SKPRT_ACTIVATE,
56                 'activatesetpwd'                => _ADM_SKPRT_ACTIVATESETPWD,
57                 'addnewlog'                             => _ADM_SKPRT_ADDNEWLOG,
58                 'adminerrorpage'                => _ADM_SKPRT_ADMINERRORPAGE,
59                 'adminskindelete'               => _ADM_SKPRT_ADMINSKINDELETE,
60                 'adminskinedit'                 => _ADM_SKPRT_ADMINSKINEDIT,
61                 'adminskinedittype'             => _ADM_SKPRT_ADMINSKINEDITTYPE,
62                 'adminskiniedoimport'   => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
63                 'adminskinieimport'             => _ADM_SKPRT_ADMINSKINIEIMPORT,
64                 'adminskinieoverview'   => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
65                 'adminskinoverview'             => _ADM_SKPRT_ADMINSKINOVERVIEW,
66                 'adminskinremovetype'   => _ADM_SKPRT_ADMINSKINREMOVETYPE,
67                 'admintemplatedelete'   => _ADM_SKPRT_ADMINTEMPLATEDELETE,
68                 'admintemplateedit'             => _ADM_SKPRT_ADMINTEMPLATEEDIT,
69                 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
70                 'backupoverview'                => _ADM_SKPRT_BACKUPOVERVIEW,
71                 'backuprestore'                 => _ADM_SKPRT_BACKUPRESTORE,
72                 'banlist'                               => _ADM_SKPRT_BANLIST,
73                 'banlistdelete'                 => _ADM_SKPRT_BANLISTDELETE,
74                 'banlistdeleteconfirm'  => _ADM_SKPRT_BANLISTDELETECONFIRM,
75                 'banlistnew'                    => _ADM_SKPRT_BANLISTNEW,
76                 'batchcategory'                 => _ADM_SKPRT_BATCHCATEGORY,
77                 'batchcomment'                  => _ADM_SKPRT_BATCHCOMMENT,
78                 'batchdelete'                   => _ADM_SKPRT_BATCHDELETE,
79                 'batchitem'                             => _ADM_SKPRT_BATCHITEM,
80                 'batchmember'                   => _ADM_SKPRT_BATCHMEMBER,
81                 'batchmove'                             => _ADM_SKPRT_BATCHMOVE,
82                 'batchmovecat'                  => _ADM_SKPRT_BATCHMOVECAT,
83                 'batchteam'                             => _ADM_SKPRT_BATCHTEAM,
84                 'blogcommentlist'               => _ADM_SKPRT_BLOGCOMMENTLIST,
85                 'blogsettings'                  => _ADM_SKPRT_BLOGSETTINGS,
86                 'bookmarklet'                   => _ADM_SKPRT_BOOKMARKLET,
87                 'browseowncomments'             => _ADM_SKPRT_BROWSEOWNCOMMENTS,
88                 'browseownitems'                => _ADM_SKPRT_BROWSEOWNITEMS,
89                 'categorydelete'                => _ADM_SKPRT_CATEGORYDELETE,
90                 'categoryedit'                  => _ADM_SKPRT_CATEGORYEDIT,
91                 'commentdelete'                 => _ADM_SKPRT_COMMENTDELETE,
92                 'commentedit'                   => _ADM_SKPRT_COMMENTEDIT,
93                 'createitem'                    => _ADM_SKPRT_CREATEITEM,
94                 'createnewlog'                  => _ADM_SKPRT_CREATENEWLOG,
95                 'createaccountinput'    => _ADM_SKPRT_CREATEACCOUNTINPUT,
96                 'createaccountsuccess'  => _ADM_SKPRT_CREATEACCOUNTSUCCESS,
97                 'createaccountdisable'  => _ADM_SKPRT_CREATEACCOUNTDISALLOWED,
98                 'deleteblog'                    => _ADM_SKPRT_DELETEBLOG,
99                 'editmembersettings'    => _ADM_SKPRT_EDITMEMBERSETTINGS,
100                 'forgotpassword'                => _ADM_SKPRT_FORGOTPASSWORD,
101                 'itemcommentlist'               => _ADM_SKPRT_ITEMCOMMENTLIST,
102                 'itemdelete'                    => _ADM_SKPRT_ITEMDELETE,
103                 'itemedit'                              => _ADM_SKPRT_ITEMEDIT,
104                 'itemlist'                              => _ADM_SKPRT_ITEMLIST,
105                 'itemmove'                              => _ADM_SKPRT_ITEMMOVE,
106                 'manage'                                => _ADM_SKPRT_MANAGE,
107                 'manageteam'                    => _ADM_SKPRT_MANAGETEAM,
108                 'memberdelete'                  => _ADM_SKPRT_MEMBERDELETE,
109                 'overview'                              => _ADM_SKPRT_OVERVIEW,
110                 'pagefoot'                              => _ADM_SKPRT_PAGEFOOT,
111                 'pagehead'                              => _ADM_SKPRT_PAGEHEAD,
112                 'plugindelete'                  => _ADM_SKPRT_PLUGINDELETE,
113                 'pluginhelp'                    => _ADM_SKPRT_PLUGINHELP,
114                 'pluginlist'                    => _ADM_SKPRT_PLUGINLIST,
115                 'pluginoptions'                 => _ADM_SKPRT_PLUGINOPTIONS,
116                 'settingsedit'                  => _ADM_SKPRT_SETTINGSEDIT,
117                 'showlogin'                             => _ADM_SKPRT_SHOWLOGIN,
118                 'skindelete'                    => _ADM_SKPRT_SKINDELETE,
119                 'skinedit'                              => _ADM_SKPRT_SKINEDIT,
120                 'skinedittype'                  => _ADM_SKPRT_SKINEDITTYPE,
121                 'skiniedoimport'                => _ADM_SKPRT_SKINIEDOIMPORT,
122                 'skinieimport'                  => _ADM_SKPRT_SKINIEIMPORT,
123                 'skinieoverview'                => _ADM_SKPRT_SKINIEOVERVIEW,
124                 'skinoverview'                  => _ADM_SKPRT_SKINOVERVIEW,
125                 'skinremovetype'                => _ADM_SKPRT_SKINREMOVETYPE,
126                 'systemoverview'                => _ADM_SKPRT_SYSTEMOVERVIEW,
127                 'teamdelete'                    => _ADM_SKPRT_TEAMDELETE,
128                 'templatedelete'                => _ADM_SKPRT_TEMPLATEDELETE,
129                 'templateedit'                  => _ADM_SKPRT_TEMPLATEEDIT,
130                 'templateoverview'              => _ADM_SKPRT_TEMPLATEOVERVIEW,
131                 'usermanagement'                => _ADM_SKPRT_USERMANAGEMENT
132         );
133         
134         /**
135          * AdminActions::getNormalSkinTypes()
136          *
137          * @static
138          * @param       void
139          * @return      array   list of friendly names for page actions
140          */
141         static public function getNormalSkinTypes()
142         {
143                 return self::$normal_skin_types;
144         }
145         
146         /**
147          * AdminActions::__construct()
148          * Constructor for a new Actions object
149          *
150          * @param       string  $type
151          * @return      void
152          */
153         public function __construct($type)
154         {
155                 // call constructor of superclass first
156                 parent::__construct();
157                 
158                 /* alias */
159                 if ( $type == 'admntemplateoverview' )
160                 {
161                         $this->skintype = 'admintemplateoverview';
162                 }
163                 else
164                 {
165                         $this->skintype = $type;
166                 }
167         
168                 return;
169         }
170         
171         /**
172          * AdminActions::getAvailableActions()
173          *
174          * @param       void
175          * @return      array   allowed actions for the page type
176          */
177         public function getAvailableActions()
178         {
179                 $extra_actions = array();
180                 
181                 switch ( $this->skintype )
182                 {
183                         case 'actionlog':
184                                 $extra_actions = array(
185                                 'actionloglist',
186                                 );
187                                 break;
188                         case 'activate':
189                                 $extra_actions = array(
190                                 'activationmessage',
191                                 'eventformextra',
192                                 );
193                                 break;
194                         case 'activatesetpwd':
195                                 $extra_actions = array(
196                                 /* nothing special */
197                                 );
198                                 break;
199                         case 'addnewlog':
200                                 $extra_actions = array(
201                                 'getblogsetting',
202                                 'blogsetting',
203                                 'requestblogid',
204                                 );
205                                 break;
206                         case 'adminerrorpage':
207                                 $extra_actions = array(
208                                 /* nothing special */
209                                 );
210                                 break;
211                         case 'adminskindelete':
212                                 $extra_actions = array(
213                                 'editskintype',
214                                 );
215                                 break;
216                         case 'adminskinedit':
217                                 $extra_actions = array(
218                                 'editskin',
219                                 'normalskinlist',
220                                 'specialskinlist',
221                                 );
222                                 break;
223                         case 'adminskinedittype':
224                                 $extra_actions = array(
225                                 'editskintype',
226                                 'skintypehelp',
227                                 'allowedskinactions',
228                                 'skineditallowedlist',
229                                 );
230                                 break;
231                         case 'adminskiniedoimport':
232                                 $extra_actions = array(
233                                 'importskininfo',
234                                 );
235                                 break;
236                         case 'adminskinieimport':
237                                 $extra_actions = array(
238                                 'importskininfo',
239                                 );
240                                 break;
241                         case 'adminskinieoverview':
242                                 $extra_actions = array(
243                                 'selectlocalskinfiles',
244                                 'skinielist',
245                                 );
246                                 break;
247                         case 'adminskinoverview':
248                                 $extra_actions = array(
249                                 'skinoverview',
250                                 );
251                                 break;
252                         case 'adminskinremovetype':
253                                 $extra_actions = array(
254                                 'editskintype',
255                                 );
256                                 break;
257                         case 'admintemplatedelete':
258                                 $extra_actions = array(
259                                 'editadmintemplateinfo',
260                                 );
261                         case 'admintemplateedit':
262                                 $extra_actions = array(
263                                 'edittemplateinfo',
264                                 );
265                                 break;
266                         case 'admintemplateoverview':
267                                 $extra_actions = array(
268                                 'templateoverview',
269                                 );
270                                 break;
271                         case 'backupoverview':
272                                 $extra_actions = array(
273                                 /* nothing special */
274                                 );
275                                 break;
276                         case 'backuprestore':
277                                 $extra_actions = array(
278                                 /* nothing special */
279                                 );
280                                 break;
281                         case 'banlist':
282                                 $extra_actions = array(
283                                 'adminbloglink',
284                                 'adminbanlist',
285                                 'requestblogid',
286                                 );
287                                 break;
288                         case 'banlistdelete':
289                                 $extra_actions = array(
290                                 'requestiprange',
291                                 'requestblogid',
292                                 );
293                                 break;
294                         case 'banlistdeleteconfirm':
295                                 $extra_actions = array(
296                                 'banlistdeletedlist',
297                                 'requestblogid',
298                                 );
299                                 break;
300                         case 'banlistnew':
301                                 $extra_actions = array(
302                                 'iprangeinput',
303                                 'requestblogid',
304                                 'blogsetting',
305                                 );
306                                 break;
307                         case 'batchcategory':
308                                 $extra_actions = array(
309                                 'adminbatchaction',
310                                 'adminbatchlist',
311                                 );
312                                 break;
313                         case 'batchcomment':
314                                 $extra_actions = array(
315                                 'adminbatchaction',
316                                 'adminbatchlist',
317                                 );
318                                 break;
319                         case 'batchdelete':
320                                 $extra_actions = array(
321                                 'batchdeletetype',
322                                 'batchdeletelist',
323                                 );
324                                 break;
325                         case 'batchitem':
326                                 $extra_actions = array(
327                                 'adminbatchaction',
328                                 'adminbatchlist',
329                                 );
330                                 break;
331                         case 'batchmember':
332                                 $extra_actions = array(
333                                 'adminbatchaction',
334                                 'adminbatchlist',
335                                 );
336                                 break;
337                         case 'batchmove':
338                                 $extra_actions = array(
339                                 'batchmovetitle',
340                                 'batchmovetype',
341                                 'batchmovelist',
342                                 'movedistselect',
343                                 'batchmovebtn',
344                                 );
345                                 break;
346                         case 'batchmovecat':
347                                 $extra_actions = array(
348                                 'batchmovetitle',
349                                 'batchmovetype',
350                                 'batchmovelist',
351                                 'movedistselect',
352                                 'batchmovebtn',
353                                 );
354                                 break;
355                         case 'batchteam':
356                                 $extra_actions = array(
357                                 'requestblogid',
358                                 'adminbatchaction',
359                                 'adminbatchlist',
360                                 );
361                                 break;
362                         case 'blogcommentlist':
363                                 $extra_actions = array(
364                                 'adminbloglink',
365                                 'commentnavlist',
366                                 'adminbatchlist',
367                                 );
368                                 break;
369                         case 'blogsettings':
370                                 $extra_actions = array(
371                                 'adminbloglink',
372                                 'blogcatlist',
373                                 'blognotifysetting',
374                                 'blogsetting',
375                                 'blogsettingyesno',
376                                 'blogteammembers',
377                                 'blogtime',
378                                 'defcatselect',
379                                 'defskinselect',
380                                 'pluginextras',
381                                 'pluginoptions',
382                                 'requestblogid',
383                                 );
384                                 break;
385                         case 'bookmarklet':
386                                 $extra_actions = array(
387                                 'bookmarkletadmin',
388                                 );
389                                 break;
390                         case 'browseowncomments':
391                                 $extra_actions = array(
392                                 'commentnavlist',
393                                 );
394                                 break;
395                         case 'browseownitems':
396                                 $extra_actions = array(
397                                 'itemnavlist',
398                                 );
399                                 break;
400                         case 'categorydelete':
401                                 $extra_actions = array(
402                                 'categorysetting',
403                                 'requestblogid',
404                                 );
405                                 break;
406                         case 'categoryedit':
407                                 $extra_actions = array(
408                                 'requestblogid',
409                                 'categorysetting',
410                                 'editdesturl',
411                                 'pluginoptions'
412                                 );
413                                 break;
414                         case 'commentdelete':
415                                 $extra_actions = array(
416                                 'deletecomment',
417                                 );
418                                 break;
419                         case 'commentedit':
420                                 $extra_actions = array(
421                                 'editcomment',
422                                 );
423                                 break;
424                         case 'createaccountinput':
425                                 $extra_actions = array(
426                                 'contents',
427                                 'pluginextras',
428                                 'eventformextra',
429                                 );
430                                 break;
431                         case 'createaccountsuccess':
432                                 $extra_actions = array(
433                                 'contents',
434                                 );
435                                 break;
436                         case 'createaccountdisable':
437                                 $extra_actions = array(
438                                 /* nothing special */
439                                 );
440                                 break;
441                         case 'createitem':
442                                 $extra_actions = array(
443                                 'adminbloglink',
444                                 'blogid',
445                                 'contents',
446                                 'categories',
447                                 'currenttime',
448                                 'init',
449                                 'pluginoptions',
450                                 'pluginextras'
451                                 );
452                                 break;
453                         case 'createnewlog':
454                                 $extra_actions = array(
455                                 'defskinselect',
456                                 'blogtime',
457                                 );
458                                 break;
459                         case 'deleteblog':
460                                 $extra_actions = array(
461                                 'blogsetting',
462                                 'requestblogid',
463                                 );
464                                 break;
465                         case 'editmembersettings':
466                                 $extra_actions = array(
467                                 'defskinselect',
468                                 'editmember',
469                                 'localeselectoptions',
470                                 'pluginoptions',
471                                 'defadminskinselect',
472                                 'defbookmarkletselect',
473                                 'pluginextras',
474                                 );
475                                 break;
476                         case 'forgotpassword':
477                                 $extra_actions = array(
478                                 /* nothing special */
479                                 );
480                                 break;
481                         case 'itemcommentlist':
482                                 $extra_actions = array(
483                                 'requestblogid',
484                                 'commentnavlist',
485                                 );
486                                 break;
487                         case 'itemdelete':
488                                 $extra_actions = array(
489                                 'deleteitemtitle',
490                                 'deleteitembody',
491                                 'deleteitemid',
492                                 );
493                                 break;
494                         case 'itemedit':
495                                 $extra_actions = array(
496                                 'init',
497                                 'contents',
498                                 'checkedonval',
499                                 'categories',
500                                 'currenttime',
501                                 'itemtime',
502                                 'pluginoptions',
503                                 'pluginextras'
504                                 );
505                                 break;
506                         case 'itemlist':
507                                 $extra_actions = array(
508                                 'adminbloglink',
509                                 'ilistaddnew',
510                                 'itemnavlist',
511                                 );
512                                 break;
513                         case 'itemmove':
514                                 $extra_actions = array(
515                                 'moveitemid',
516                                 'movedistselect',
517                                 );
518                                 break;
519                         case 'manage':
520                                 $extra_actions = array(
521                                 /* nothing special */
522                                 );
523                                 break;
524                         case 'manageteam':
525                                 $extra_actions = array(
526                                 'requestblogid',
527                                 'blogsetting',
528                                 'blogteamlist',
529                                 'newmemberselect',
530                                 'inputyesno',
531                                 );
532                                 break;
533                         case 'memberdelete':
534                                 $extra_actions = array(
535                                 'editmember',
536                                 );
537                                 break;
538                         case 'overview':
539                                 $extra_actions = array(
540                                 'yrbloglist',
541                                 );
542                                 break;
543                         case 'plugindelete':
544                                 $extra_actions = array(
545                                 'editpluginfo',
546                                 );
547                                 break;
548                         case 'pluginhelp':
549                                 $extra_actions = array(
550                                 'helpplugname',
551                                 'pluginhelp',
552                                 );
553                                 break;
554                         case 'pluginlist':
555                                 $extra_actions = array(
556                                 'pluginlistlist',
557                                 'newpluginlist',
558                                 );
559                                 break;
560                         case 'pluginoptions':
561                                 $extra_actions = array(
562                                 'editpluginfo',
563                                 'editplugoptionslist',
564                                 );
565                                 break;
566                         case 'settingsedit':
567                                 $extra_actions = array(
568                                 'defblogselect',
569                                 'defskinselect',
570                                 'configsettingsedit',
571                                 'configsettingsyesno',
572                                 'outputspecialdirs',
573                                 'jstoolbaroptions',
574                                 'localeselectoptions',
575                                 'mediadirwarning',
576                                 'pluginextras',
577                                 'defadminskinselect',
578                                 'defbookmarkletselect',
579                                 );
580                                 break;
581                         case 'showlogin':
582                                 $extra_actions = array(
583                                 'passrequestvars',
584                                 );
585                                 break;
586                         case 'skindelete':
587                                 $extra_actions = array(
588                                 'editskintype',
589                                 );
590                                 break;
591                         case 'skinedit':
592                                 $extra_actions = array(
593                                 'editskin',
594                                 'normalskinlist',
595                                 'specialskinlist'
596                                 );
597                                 break;
598                         case 'skinedittype':
599                                 $extra_actions = array(
600                                 'editskintype',
601                                 'skintypehelp',
602                                 'allowedskinactions',
603                                 'skineditallowedlist'
604                                 );
605                                 break;
606                         case 'skiniedoimport':
607                                 $extra_actions = array(
608                                 'importskininfo',
609                                 );
610                                 break;
611                         case 'skinieimport':
612                                 $extra_actions = array(
613                                 'importskininfo',
614                                 );
615                                 break;
616                         case 'skinieoverview':
617                                 $extra_actions = array(
618                                 'selectlocalskinfiles',
619                                 'skinielist',
620                                 );
621                                 break;
622                         case 'skinoverview':
623                                 $extra_actions = array(
624                                 'skinoverview',
625                                 );
626                                 break;
627                         case 'skinremovetype':
628                                 $extra_actions = array(
629                                 'editskintype',
630                                 );
631                                 break;
632                         case 'systemoverview':
633                                 $extra_actions = array(
634                                 'systemsettings',
635                                 );
636                                 break;
637                         case 'teamdelete':
638                                 $extra_actions = array(
639                                 'editmember',
640                                 'blogsetting',
641                                 'requestblogid',
642                                 );
643                                 break;
644                         case 'templatedelete':
645                                 $extra_actions = array(
646                                 'edittemplateinfo',
647                                 );
648                                 break;
649                         case 'templateedit':
650                                 $extra_actions = array(
651                                 'edittemplateinfo',
652                                 );
653                                 break;
654                         case 'templateoverview':
655                                 $extra_actions = array(
656                                 'templateoverview',
657                                 );
658                                 break;
659                         case 'usermanagement':
660                                 $extra_actions = array(
661                                 'editmemberlist',
662                                 'inputyesno',
663                                 );
664                                 break;
665                         case 'importAdmin':
666                                 $extra_actions = array(
667                                 'charset',
668                                 'adminurl',
669                                 'extrahead',
670                                 'member',
671                                 'versioncheckurl',
672                                 'version',
673                                 'codename',
674                                 'newestcompare',
675                                 'selectlocalskinfiles',
676                                 'skinielist',
677                                 );
678                                 break;
679                         default:
680                                 break;
681                 }
682                 
683                 $defined_actions = array_merge(self::$default_actions, $extra_actions);
684                 
685                 return array_merge($defined_actions, parent::getAvailableActions());
686         }
687         
688         /**
689          * AdminActions::parse_actionloglist()
690          * Parse skinvar actionloglist
691          *
692          * @param       string  $template_name  name of template to use
693          * @return      void
694          */
695         public function parse_actionloglist($template_name = '')
696         {
697                 $query = "SELECT * FROM %s ORDER BY timestamp DESC;";
698                 $query = sprintf($query, sql_table('actionlog'));
699                 
700                 $resource = DB::getResult($query);
701                 if ( $resource->rowCount() > 0 )
702                 {
703                         $template['content'] = 'actionlist';
704                         $action_list = showlist($resource, 'table', $template, $template_name);
705                         $this->parser->parse($action_list);
706                 }
707                 else
708                 {
709                         /* TODO: nothing to be shown */
710                 }
711                 return;
712         }
713         
714         /**
715          * AdminActions::parse_activationmessage()
716          * Parse skinvar activationmessage
717          *
718          * @param       string  $type                   type of message
719          * @param       string  $template_name  name of template to use
720          * @return      void
721          */
722         public function parse_activationmessage($type, $template_name = '')
723         {
724                 global $CONF, $manager;
725                 
726                 $template = array();
727                 
728                 if ( !empty($template_name))
729                 {
730                         $template =& $manager->getTemplate($template_name);
731                 }
732                 
733                 $key = postVar('ackey');
734                 if ( !$key )
735                 {
736                         Admin::error(_ERROR_ACTIVATE);
737                 }
738                 
739                 $info = MEMBER::getActivationInfo($key);
740                 if ( !$info )
741                 {
742                         Admin::error(_ERROR_ACTIVATE);
743                 }
744                 
745                 $mem =& $manager->getMember($info->vmember);
746                 if ( !$mem )
747                 {
748                         Admin::error(_ERROR_ACTIVATE);
749                 }
750                 switch ( $info->vtype )
751                 {
752                         case 'forgot':
753                                 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
754                                 {
755                                         $title = $template['ACTIVATE_FORGOT_TITLE'];
756                                 }
757                                 else
758                                 {
759                                         $title = _ACTIVATE_FORGOT_TITLE;
760                                 }
761                                 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
762                                 {
763                                         $text = $template['ACTIVATE_FORGOT_TEXT'];
764                                 }
765                                 else
766                                 {
767                                         $text = _ACTIVATE_FORGOT_TEXT;
768                                 }
769                                 break;
770                         case 'register':
771                                 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
772                                 {
773                                         $title = $template['ACTIVATE_REGISTER_TITLE'];
774                                 }
775                                 else
776                                 {
777                                         $title = _ACTIVATE_REGISTER_TITLE;
778                                 }
779                                 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
780                                 {
781                                         $text = $template['ACTIVATE_REGISTER_TEXT'];
782                                 }
783                                 else
784                                 {
785                                         $text = _ACTIVATE_REGISTER_TEXT;
786                                 }
787                                 break;
788                         case 'addresschange':
789                                 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
790                                 {
791                                         $title = $template['ACTIVATE_CHANGE_TITLE'];
792                                 }
793                                 else
794                                 {
795                                         $title = _ACTIVATE_CHANGE_TITLE;
796                                 }
797                                 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
798                                 {
799                                         $text = $template['ACTIVATE_CHANGE_TEXT'];
800                                 }
801                                 else
802                                 {
803                                         $text = _ACTIVATE_CHANGE_TEXT;
804                                 }
805                                 break;
806                 }
807                 $aVars = array(
808                         'memberName'    => Entity::hsc($mem->getDisplayName()),
809                         'realName'              => Entity::hsc($mem->getRealName()),
810                 );
811                 switch ( $type )
812                 {
813                         case 'title':
814                                 echo Template::fill($title, $aVars);
815                                 break;
816                         case 'text':
817                                 echo Template::fill($text,  $aVars);
818                                 break;
819                         case 'ackey':
820                                 echo Entity::hsc($key);
821                                 break;
822                 }
823                 return;
824         }
825         
826         /**
827          * AdminActions::parse_addtickettourl()
828          * Parse skinvar addtickettourl
829          *
830          * @param       string  $url    URI for ticket
831          * @return      void
832          */
833         public function parse_addtickettourl($url)
834         {
835                 global $manager;
836                 $url = $manager->addTicketToUrl($url);
837                 echo Entity::hsc($url);
838                 return;
839         }
840         
841         /**
842          * AdminActions::parse_adminbanlist()
843          * Parse skinvar adminbanlist
844          *
845          * @param       string  $template_name  name of template to use
846          * @return      void
847          */
848         public function parse_adminbanlist($template_name = '')
849         {
850                 $blogid = intRequestVar('blogid');
851                 
852                 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
853                 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
854                 
855                 $resource = DB::getResult($query);
856                 if ( $resource->rowCount() > 0 )
857                 {
858                         $template['content'] = 'banlist';
859                         $ban_list = showlist($resource, 'table', $template, $template_name);
860                         $this->parser-parse($ban_list);
861                 }
862                 else
863                 {
864                         echo _BAN_NONE;
865                 }
866                 return;
867         }
868         
869         /**
870          * AdminActions::parse_adminbatchaction()
871          * Parse skinvar adminbatchaction
872          *
873          * @param       void
874          * @return      void
875          */
876         public function parse_adminbatchaction()
877         {
878                 echo Entity::hsc(requestVar('batchaction'));
879                 return;
880         }
881         
882         /**
883          * AdminActions::parse_adminbatchlist()
884          * Parse skinvar adminbatchlist
885          *
886          * @param       string  $template_name  name of template to use
887          * @return      void
888          */
889         public function parse_adminbatchlist($template_name = '')
890         {
891                 global $manager;
892                 $templates = array();
893                 
894                 if ( !empty($template_name) )
895                 {
896                         $templates =& $manager->getTemplate($template_name);
897                 }
898                 
899                 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
900                 {
901                         $template = '<li><%text(_BATCH_EXECUTING)%>&nbsp;'
902                         . '<b><%adminbatchaction%></b>&nbsp;'
903                         . '<%batchlisttype%>&nbsp;'
904                         . '<b><%batchid%></b>...&nbsp;'
905                         . '<b><%batchlistmsg%></b>'
906                         . "</li>\n";
907                 }
908                 else
909                 {
910                         $template = $templates['ADMIN_BATCHLIST'];
911                 }
912                 
913                 $selected = requestIntArray('batch');
914                 $action = requestVar('batchaction');
915                 
916                 switch ( $this->skintype )
917                 {
918                         case 'batchitem':
919                                 $batchlisttype  = _BATCH_ONITEM;
920                                 $deleteaction   = 'deleteOneItem';
921                                 $moveaction             = 'moveOneItem';
922                                 $destid                 = intRequestVar('destcatid');
923                                 break;
924                         case 'batchcomment':
925                                 $batchlisttype  = _BATCH_ONCOMMENT;
926                                 $deleteaction   = 'deleteOneComment';
927                                 break;
928                         case 'batchmember':
929                                 $batchlisttype  = _BATCH_ONMEMBER;
930                                 $deleteaction   = 'deleteOneMember';
931                                 $setadminsql    = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
932                                 $unsetchksql    = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
933                                 $unsetupsql             = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
934                                 $unseterrmsg    = _ERROR_ATLEASTONEADMIN;
935                                 break;
936                         case 'batchteam':
937                                 $blogid                 = intRequestVar('blogid');
938                                 $batchlisttype  = _BATCH_ONTEAM;
939                                 $deleteaction   = 'deleteOneTeamMember';
940                                 $setadminsql    = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
941                                 $unsetchksql    = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
942                                 $unseterrmsg    = _ERROR_ATLEASTONEBLOGADMIN;
943                                 $unsetupsql             = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
944                                 break;
945                         case 'batchcategory':
946                                 $batchlisttype  = _BATCH_ONCATEGORY;
947                                 $deleteaction   = 'deleteOneCategory';
948                                 $moveaction             = 'moveOneCategory';
949                                 $destid                 = intRequestVar('destblogid');
950                                 break;
951                 }
952                 
953                 // walk over all selectedids and perform action
954                 foreach ( $selected as $selectedid )
955                 {
956                         $error = '';
957                         $selectedid = intval($selectedid);
958                         switch ( $action )
959                         {
960                                 case 'delete':
961                                         if ( $this->skintype != 'batchteam' )
962                                         {
963                                                 $params = array($selectedid);
964                                                 $error = call_user_func_array(array('Admin', $deleteaction), $params);
965                                         }
966                                         else
967                                         {
968                                                 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
969                                         }
970                                         break;
971                                 case 'move':
972                                         $params = array($selectedid, $destid);
973                                         $error = call_user_func_array(array('Admin', $moveaction), $params);
974                                         break;
975                                 case 'setadmin':
976                                         // always succeeds
977                                         DB::execute("UPDATE {$setadminsql} {$selectedid};");
978                                         $error = '';
979                                         break;
980                                 case 'unsetadmin':
981                                         // there should always remain at least one super-admin
982                                         $r = DB::getResult($unsetchksql);
983                                         if ( $r->rowCount() < 2 )
984                                         {
985                                                 $error = $unseterrmsg;
986                                         }
987                                         else
988                                         {
989                                                 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
990                                         }
991                                         break;
992                                 default:
993                                         $error = _BATCH_UNKNOWN . Entity::hsc($action);
994                         }
995                                 
996                         $data = array(
997                                 'batchid'                       => $selectedid,
998                                 'batchlisttype'         => Entity::hsc($batchlisttype),
999                                 'adminbatchaction'      => Entity::hsc($action),
1000                                 'batchlistmsg'          => $error ? $error : _BATCH_SUCCESS,
1001                         );
1002                                 
1003                         $this->parser->parse(Template::fill($template, $data));
1004                         echo '<br />';
1005                 }
1006                 return;
1007         }
1008         
1009         /**
1010          * AdminActions::parse_adminbloglink()
1011          * Parse skinvar adminbloglink
1012          *
1013          * @param       string  $template_name  name of template to use
1014          * @return      void
1015          */
1016         public function parse_adminbloglink($template_name = '')
1017         {
1018                 global $manager;
1019                 $blogid =  intRequestVar('blogid');
1020                 $blog   =& $manager->getBlog($blogid);
1021                 $templates = array();
1022                 
1023                 if ( !empty($template_name) )
1024                 {
1025                         $templates =& $manager->getTemplate($template_name);
1026                 }
1027                 
1028                 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1029                 {
1030                         $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1031                 }
1032                 else
1033                 {
1034                         $template = $templates['ADMIN_BLOGLINK'];
1035                 }
1036                 
1037                 $data = array(
1038                         'url'                                   => Entity::hsc($blog->getURL()),
1039                         'adminbloglinktitle'    => _BLOGLIST_TT_VISIT,
1040                         'blogname'                              => Entity::hsc($blog->getName())
1041                 );
1042                 
1043                 echo Template::fill($template, $data);
1044                 return;
1045         }
1046         
1047         /**
1048          * AdminActions::parse_adminerrormesg()
1049          * Parse skinvar adminerrormesg
1050          *
1051          * @param       void
1052          * @return      void
1053          */
1054         public function parse_adminerrormesg()
1055         {
1056                 global $CONF;
1057                 $message = '';
1058                 
1059                 if ( requestVar('errormessage') )
1060                 {
1061                         $message = requestVar('errormessage');
1062                 }
1063                 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1064                 {
1065                         $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1066                 }
1067                 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1068                 {
1069                         $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1070                 }
1071                 echo Entity::hsc($message);
1072                 return;
1073         }
1074         
1075         /**
1076          * AdminActions::parse_allowedskinactions()
1077          * Parse skinvar allowedskinactions
1078          *
1079          * @param       void
1080          * @return      void
1081          */
1082         public function parse_allowedskinactions()
1083         {
1084                 global $manager;
1085                 
1086                 $type = strtolower(trim(requestVar('type')));
1087                 $skinid = intRequestVar('skinid');
1088                 
1089                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1090                 {
1091                         $skin =& $manager->getSkin($skinid);
1092                         $tag = 'skinvar';
1093                 }
1094                 else
1095                 {
1096                         $skin =& $manager->getSkin($skinid, 'AdminActions');
1097                         $tag = 'adminskinvar';
1098                 }
1099                 
1100                 $actions = $skin->getAllowedActionsForType($type);
1101                 sort($actions);
1102                 
1103                 while ( $current = array_shift($actions) )
1104                 {
1105                         echo helplink("{$tag}-{$current}") . "$current</a>\n";
1106                         
1107                         if ( count($actions) != 0 )
1108                         {
1109                                 echo ", ";
1110                         }
1111                 }
1112                 return;
1113         }
1114         
1115         /**
1116          * AdminActions::parse_banlistdeletedlist()
1117          * Parse skinvar banlistdeletedlist
1118          *
1119          * @param       string  $template_name  name of template to use
1120          * @return      void
1121          */
1122         public function parse_banlistdeletedlist($template_name = '')
1123         {
1124                 global $manager;
1125                 
1126                 $templates = array();
1127                 if ( $template_name )
1128                 {
1129                         $templates =& $manager->getTemplate($template_name);
1130                 }
1131                 
1132                 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1133                 {
1134                         $template = "<li><%blogname%></li>\n";
1135                 }
1136                 else
1137                 {
1138                         $template = $templates['BANLIST_DELETED_LIST'];
1139                 }
1140                 
1141                 $deleted = requestArray('delblogs');
1142                 foreach ( $deleted as $delblog )
1143                 {
1144                         $blog =& $manager->getBlog($delblog);
1145                         $data =  array(
1146                                 'blogname' => Entity::hsc($blog->getName())
1147                         );
1148                         echo Template::fill($template, $data);
1149                 }
1150                 
1151                 return;
1152         }
1153         
1154         /**
1155          * AdminActions::parse_batchdeletelist()
1156          * Parse skinvar batchdeletelist
1157          *
1158          * @param       void
1159          * @return      void
1160          */
1161         public function parse_batchdeletelist()
1162         {
1163                 $selected = requestIntArray('batch');
1164                 $index  = 0;
1165                 
1166                 foreach ( $selected as $select )
1167                 {
1168                         echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1169                 }
1170                 // add hidden vars for team & comment
1171                 if ( requestVar('action') == 'batchteam' )
1172                 {
1173                         echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1174                 }
1175                 if ( requestVar('action') == 'batchcomment' )
1176                 {
1177                         echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1178                 }
1179                 return;
1180         }
1181
1182         /**
1183          * AdminActions::parse_defadminskinselect()
1184          * Parse skinvar defadminskinselect
1185          *
1186          * @param       string  $template_name  name of template to use
1187          * @return      void
1188          */
1189         public function parse_defadminskinselect($template_name)
1190         {
1191                 global $CONF, $action, $manager;
1192                 
1193                 if ( $action == 'editmembersettings' )
1194                 {
1195                         global $member;
1196                         $default = $member->adminskin;
1197                 }
1198                 elseif ( $action == 'memberedit' )
1199                 {
1200                         $mem = $manager->getMember(intRequestVar('memberid'));
1201                         $default = $mem->adminskin;
1202                 }
1203                 else
1204                 {
1205                         $default = $CONF['AdminSkin'];
1206                 }
1207                 
1208                 $query  = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1209                 $query = sprintf($query, sql_table('skin_desc'));
1210                 $template = array(
1211                                 'name'          => 'adminskin',
1212                                 'tabindex'      => 10080,
1213                                 'selected'      => $default
1214                 );
1215                 
1216                 if ( $this->skintype != 'settingsedit' )
1217                 {
1218                         $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1219                 }
1220                 
1221                 $skin_select = showlist($query, 'select', $template, $template_name);
1222                 $this->parser->parse($skin_select);
1223                 return;
1224         }
1225         
1226         /**
1227          * AdminActions::parse_defbookmarkletselect()
1228          * Parse skinvar defbookmarkletselect
1229          *
1230          * @param       string  $template_name  name of template to use
1231          * @return      void
1232          */
1233         public function parse_defbookmarkletselect($template_name)
1234         {
1235                 global $CONF, $action, $manager;
1236                 
1237                 if ( $action == 'editmembersettings' )
1238                 {
1239                         global $member;
1240                         $default = $member->bookmarklet;
1241                 }
1242                 elseif ( $action == 'memberedit' )
1243                 {
1244                         $mem = $manager->getMember(intRequestVar('memberid'));
1245                         $default = $mem->bookmarklet;
1246                 }
1247                 else
1248                 {
1249                         $default = $CONF['BookmarkletSkin'];
1250                 }
1251                 
1252                 $query  = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1253                 $query = sprintf($query, sql_table('skin_desc'));
1254         
1255                 $template = array(
1256                                 'name'          => 'bookmarklet',
1257                                 'tabindex'      => 10085,
1258                                 'selected'      => $default
1259                 );
1260                 
1261                 if ( $this->skintype != 'settingsedit' )
1262                 {
1263                         $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1264                 }
1265                 
1266                 $bookmarklet_select = showlist($query, 'select', $template, $template_name);
1267                 $this->parser->parse($bookmarklet_select);
1268                 return;
1269         }
1270         
1271         /**
1272          * AdminActions::parse_batchdeletetype()
1273          * Parse skinvar batchdeletetype
1274          *
1275          * @param       void
1276          * @return      void
1277          */
1278         public function parse_batchdeletetype()
1279         {
1280                 echo Entity::hsc(requestVar('action'));
1281                 return;
1282         }
1283         
1284         /**
1285          * AdminActions::parse_batchmovebtn()
1286          * Parse skinvar batchmovebtn
1287          *
1288          * @param       void
1289          * @return      void
1290          */
1291         public function parse_batchmovebtn()
1292         {
1293                 $actionType = requestVar('action');
1294                 switch ( $actionType )
1295                 {
1296                         case 'batchitem':
1297                                 echo _MOVE_BTN;
1298                                 break;
1299                         case 'batchcategory':
1300                                 echo _MOVECAT_BTN;
1301                                 break;
1302                 }
1303                 return;
1304         }
1305         
1306         /**
1307          * AdminActions::parse_batchmovelist()
1308          * Parse skinvar batchmovelist
1309          *
1310          * @param       void
1311          * @param       void
1312          */
1313         public function parse_batchmovelist()
1314         {
1315                 $selected = requestIntArray('batch');
1316                 $count    = 0;
1317                 foreach ( $selected as $select )
1318                 {
1319                         echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1320                         $count++;
1321                 }
1322                 return;
1323         }
1324         
1325         /**
1326          * AdminActions::parse_batchmovetitle()
1327          * Parse skinvar batchmovetitle
1328          *
1329          * @param       void
1330          * @return      void
1331          */
1332         public function parse_batchmovetitle()
1333         {
1334                 $actionType = requestVar('action');
1335                 switch ( $actionType )
1336                 {
1337                         case 'batchitem':
1338                                 echo _MOVE_TITLE;
1339                                 break;
1340                         case 'batchcategory':
1341                                 echo _MOVECAT_TITLE;
1342                                 break;
1343                 }
1344                 return;
1345         }
1346         
1347         /**
1348          * AdminActions::parse_batchmovetype()
1349          * Parse skinvar batchmovetype
1350          *
1351          * @param       void
1352          * @return      void
1353          */
1354         public function parse_batchmovetype()
1355         {
1356                 echo Entity::hsc(requestVar('action'));
1357                 return;
1358         }
1359         
1360         /**
1361          * AdminActions::parse_blogcatlist()
1362          * Parse skinvar blogcatlist
1363          *
1364          * @param       void
1365          * @return      void
1366          */
1367         public function parse_blogcatlist($template_name = '')
1368         {
1369                 global $manager;
1370                 $blogid = intRequestVar('blogid');
1371                 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1372                 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1373                 
1374                 $resource = DB::getResult($query);
1375                 if ( $resource->rowCount() > 0 )
1376                 {
1377                         $template['content']  = 'categorylist';
1378                         $template['tabindex'] = 200;
1379                         $category_list = listplug_batchlist('category', $resource, 'table', $template, $template_name);
1380                         $this->parser->parse($category_list);
1381                 }
1382                 else
1383                 {
1384                         /* TODO: nothing to be shown */
1385                 }
1386                 $resource->closeCursor();
1387                 
1388                 return;
1389         }
1390         
1391         /**
1392          * AdminActions::parse_blogid()
1393          * Parse skinvar blogid
1394          *
1395          * @param       void
1396          * @return      void
1397          */
1398         public function parse_blogid()
1399         {
1400                 echo intRequestVar('blogid');
1401                 return;
1402         }
1403         
1404         /**
1405          * AdminActions::parse_blognotifysetting()
1406          * Parse skinvar blognotifysetting
1407          *
1408          * @param       void
1409          * @return      void
1410          */
1411         public function parse_blognotifysetting($type)
1412         {
1413                 global $manager;
1414                 $blogid =  intRequestVar('blogid');
1415                 $blog   =& $manager->getBlog($blogid);
1416                 
1417                 switch ( $type )
1418                 {
1419                         case 'comment':
1420                                 if ( !$blog->notifyOnComment() )
1421                                 {
1422                                         return;
1423                                 }
1424                                 break;
1425                         case 'vote':
1426                                 if ( !$blog->notifyOnVote() )
1427                                 {
1428                                         return;
1429                                 }
1430                                 break;
1431                         case 'newitem':
1432                                 if ( !$blog->notifyOnNewItem() )
1433                                 {
1434                                         return;
1435                                 }
1436                                 break;
1437                 }
1438                 echo ' checked="checked"';
1439                 return;
1440         }
1441         
1442         /**
1443          * AdminActions::parse_blogsetting()
1444          * Parse skinvar blogsetting
1445          *
1446          * @param       string  $which  name of weblog setting
1447          * @return      void
1448          */
1449         public function parse_blogsetting($which)
1450         {
1451                 echo $this->parse_getblogsetting($which);
1452                 return;
1453         }
1454         
1455         /**
1456          * AdminActions::parse_blogsettingyesno()
1457          * Parse skinvar blogsettingyesno
1458          *
1459          * @param       string  $type                   type of weblog setting
1460          * @param       string  $template_name  name of template to use
1461          * @return      void
1462          */
1463         public function parse_blogsettingyesno($type, $template_name = '')
1464         {
1465                 global $manager;
1466
1467                 $blogid =  intRequestVar('blogid');
1468                 $blog   =& $manager->getBlog($blogid);
1469
1470                 switch ( $type )
1471                 {
1472                         case 'convertbreaks':
1473                                 $checkedval = $blog->convertBreaks();
1474                                 $tabindex   = 55;
1475                                 break;
1476                         case 'allowpastposting':
1477                                 $checkedval = $blog->allowPastPosting();
1478                                 $tabindex   = 57;
1479                                 break;
1480                         case 'comments':
1481                                 $checkedval = $blog->commentsEnabled();
1482                                 $tabindex   = 60;
1483                                 break;
1484                         case 'public':
1485                                 $checkedval = $blog->isPublic();
1486                                 $tabindex   = 70;
1487                                 break;
1488                         case 'reqemail':
1489                                 $checkedval = $blog->emailRequired();
1490                                 $tabindex   = 72;
1491                                 break;
1492                         case 'searchable':
1493                                 $checkedval = $blog->getSearchable();
1494                                 $tabindex   = 122;
1495                                 break;
1496                 }
1497                 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1498                 return;
1499         }
1500         
1501         /**
1502          * AdminActions::parse_blogteamlist()
1503          * Parse skinvar blogteamlist
1504          *
1505          * @param       string  $template_name  name of template to use
1506          * @return      void
1507          */
1508         public function parse_blogteamlist($template_name = '')
1509         {
1510                 global $manager;
1511                 $blogid = intRequestVar('blogid');
1512                 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1513                 . "FROM %s, %s "
1514                 . "WHERE tmember=mnumber AND tblog= %d";
1515                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1516                 
1517                 $resource = DB::getResult($query);
1518                 if ( $resource->rowCount() > 0 )
1519                 {
1520                         $template['content']  = 'teamlist';
1521                         $template['tabindex'] = 10;
1522                         
1523                         $team_list = listplug_batchlist('team', $resource, 'table', $template, $template_name);
1524                         $this->parser->parse($team_list);
1525                 }
1526                 else
1527                 {
1528                         echo _LISTS_NOMORE;
1529                 }
1530                 $resource->closeCursor();
1531                 
1532                 return;
1533         }
1534         
1535         /**
1536          * AdminActions::parse_blogteammembers()
1537          * Parse skinvar blogteammembers
1538          *
1539          * @param       void
1540          * @return      void
1541          */
1542         public function parse_blogteammembers()
1543         {
1544                 $blogid = intRequestVar('blogid');
1545                 $query  = "SELECT mname, mrealname "
1546                 . "FROM %s, %s "
1547                 . "WHERE mnumber=tmember AND tblog=%d;";
1548                 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1549                 $res = DB::getResult($query);
1550                 $memberNames = array();
1551                 foreach ( $res as $row )
1552                 {
1553                         $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1554                 }
1555                 echo implode(',', $memberNames);
1556         }
1557         
1558         /**
1559          * AdminActions::parse_blogtime()
1560          * Parse skinvar blogtime
1561          *
1562          * @param       string  $type   type of time
1563          * @param       string  $format format for time expression
1564          * @param       integer $offset offset of time
1565          * @return      void
1566          */
1567         public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1568         {
1569                 global $manager;
1570                 
1571                 if ( $type != 'blogtime' )
1572                 {
1573                         /* return server time */
1574                         $timestamp = time() + $offset;
1575                 }
1576                 else
1577                 {
1578                         $bid = intRequestVar('blogid');
1579                         $b =& $manager->getBlog($bid);
1580                         $timestamp = $b->getCorrectTime() + $offset;
1581                 }
1582                 
1583                 echo i18n::formatted_datetime($format, $timestamp);
1584                 return;
1585         }
1586         
1587         /**
1588          * AdminActions::parse_bookmarkletadmin()
1589          * Parse skinvar bookmarkletadmin
1590          *
1591          * @param       void
1592          * @return      void
1593          */
1594         public function parse_bookmarkletadmin()
1595         {
1596                 global $manager;
1597                 
1598                 $blogid = intRequestVar('blogid');
1599                 
1600                 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1601                 return;
1602         }
1603         
1604         /**
1605          * AdminActions::parse_categories()
1606          * Parse skinvar categories
1607          *
1608          * create category dropdown box
1609          *
1610          * @param       string  $type   name of setting for category
1611          * @return      void
1612          */
1613         public function parse_categories($startidx = 0)
1614         {
1615                 global $manager;
1616                 
1617                 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1618                 {
1619                         $catid = Admin::$blog->getDefaultCategory();
1620                 }
1621                 else
1622                 {
1623                         $catid = Admin::$contents['catid'];
1624                 }
1625                 
1626                 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1627                 
1628                 return;
1629         }
1630
1631         /**
1632          * AdminActions::parse_categorysetting()
1633          * Parse skinvar categorysetting
1634          *
1635          * @param       string  $type   type in category setting
1636          * @return      void
1637          */
1638         public function parse_categorysetting($type)
1639         {
1640                 $catid  = intRequestVar('catid');
1641                 if ( $type == 'id' )
1642                 {
1643                         echo $catid;
1644                         return;
1645                 }
1646                 $blogid = intRequestVar('blogid');
1647                 $query  = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1648                 $query  = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1649                 $row    = DB::getRow($query);
1650                 
1651                 if ( $type != 'name' )
1652                 {
1653                         echo Entity::hsc($row['cdesc']);
1654                 }
1655                 else
1656                 {
1657                         echo Entity::hsc($row['cname']);
1658                 }
1659                 
1660                 return;
1661         }
1662         
1663         /**
1664          * AdminActions::parse_codename()
1665          * Parse templatevar codename
1666          *
1667          * @param       $value
1668          * @param       $name
1669          *
1670          */
1671         public function parse_checkedonval($value, $name)
1672         {
1673                 global $manager;
1674                 
1675                 $item = false;
1676                 $itemid = intRequestVar('itemid');
1677                 $item =& $manager->getItem($itemid, 1, 1);
1678                 
1679                 if ( $item )
1680                 {
1681                         $blog =& $manager->getBlog($item['blogid']);
1682                         
1683                         if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1684                         {
1685                                 $item['body'] = removeBreaks($item['body']);
1686                                 $item['more'] = removeBreaks($item['more']);
1687                         }
1688                 }
1689                 
1690                 $contents = array();
1691                 if ( requestVar('action') == 'itemedit' )
1692                 {
1693                         $contents = $item;
1694                 }
1695                 if ( !isset($contents[$name]) )
1696                 {
1697                         $contents[$name] = '';
1698                 }
1699                 if ($contents[$name] == $value)
1700                 {
1701                         echo 'checked="checked"';
1702                 }
1703                 return;
1704         }
1705         
1706         /**
1707          * AdminActions::parse_codename()
1708          * Parse templatevar codename
1709          *
1710          * @param       void
1711          * @return      void
1712          *
1713          * TODO: is this need???
1714          */
1715         public function parse_codename()
1716         {
1717                 global $nucleus;
1718                 echo $nucleus['codename'];
1719                 return;
1720         }
1721         
1722         /**
1723          * AdminActions::parse_commentnavlist()
1724          * Parse skinvar commentnavlist
1725          *
1726          * @param       string  $template_name  name of template to use
1727          * @return      void
1728          */
1729         public function parse_commentnavlist($template_name = '')
1730         {
1731                 global $CONF, $manager, $member;
1732                 
1733                 // start index
1734                 if ( postVar('start') )
1735                 {
1736                         $start = intPostVar('start');
1737                 }
1738                 else
1739                 {
1740                         $start = 0;
1741                 }
1742                 
1743                 // amount of items to show
1744                 if ( postVar('amount') )
1745                 {
1746                         $amount = intPostVar('amount');
1747                 }
1748                 else
1749                 {
1750                         $amount = (integer) $CONF['DefaultListSize'];
1751                         if ( $amount < 1 )
1752                         {
1753                                 $amount = 10;
1754                         }
1755                 }
1756                 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1757                        . 'FROM %s '
1758                        . 'LEFT OUTER JOIN %s ON  mnumber=cmember '
1759                        . 'WHERE ';
1760                 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1761                 
1762                 if ( $this->skintype == 'itemcommentlist' )
1763                 {
1764                         $itemid                                 = intRequestVar('itemid');
1765                         $query                                  .= " citem={$itemid}";
1766                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
1767                         $bid                                    = 0;
1768                         $nonComments                    = _NOCOMMENTS;
1769                 }
1770                 elseif ( $this->skintype == 'browseowncomments' )
1771                 {
1772                         $itemid                                 = 0;
1773                         $query                                  .= ' cmember=' . $member->getID();
1774                         $template['canAddBan']  = 0;
1775                         $bid                                    = 0;
1776                         $nonComments                    = _NOCOMMENTS_YOUR;
1777                 }
1778                 elseif ( $this->skintype == 'blogcommentlist' )
1779                 {
1780                         $itemid                                 = 0;
1781                         $query                                  .= ' cblog=' . intRequestVar('blogid');
1782                         $template['canAddBan']  = $member->blogAdminRights(intRequestVar('blogid'));
1783                         $bid                                    = intRequestVar('blogid');
1784                         $nonComments                    = _NOCOMMENTS_BLOG;
1785                 }
1786                 
1787                 $search = postVar('search');
1788                 if ( !empty($search) )
1789                 {
1790                         $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1791                 }
1792                 
1793                 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1794                 
1795                 $resource = DB::getResult($query);
1796                 if ( $resource->rowCount() > 0 )
1797                 {
1798                         $template['action'] = $this->skintype;
1799                         $template['start'] = $start;
1800                         $template['amount'] = $amount;
1801                         $template['minamount'] = 0;
1802                         $template['maxamount'] = 1000;
1803                         $template['blogid'] = $bid;
1804                         $template['search'] = $search;
1805                         $template['itemid'] = $itemid;
1806                                 
1807                         $template['content'] = 'commentlist';
1808                                 
1809                         $navlist = listplug_navlist('comment', $resource, 'table', $template, $template_name);
1810                         $this->parser->parse($navlist);
1811                 }
1812                 else
1813                 {
1814                         /* TODO: nothing to be shown */
1815                 }
1816                 $resource->closeCursor();
1817                 
1818                 return;
1819         }
1820         
1821         /**
1822          * AdminActions::parse_configsettingsedit()
1823          * Parse skinvar configsettingsedit
1824          *
1825          * @param       string  $type   type of global configuration
1826          * @return      void
1827          */
1828         public function parse_configsettingsedit($type)
1829         {
1830                 global $CONF;
1831                 switch ( $type )
1832                 {
1833                         case 'DefaultListSize':
1834                                 if ( !array_key_exists('DefaultListSize', $CONF) )
1835                                 {
1836                                         $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1837                                         $query = sprintf($query, sql_table('config'));
1838                                         DB::execute($query);
1839                                         $CONF['DefaultListSize'] = 10;
1840                                 }
1841                                 elseif ( intval($CONF['DefaultListSize']) < 1 )
1842                                 {
1843                                         $CONF['DefaultListSize'] = 10;
1844                                 }
1845                                 echo intval($CONF['DefaultListSize']);
1846                                 break;
1847                         case 'SessionCookie':
1848                                 $value = $CONF['SessionCookie'];
1849                                 $txt1  = _SETTINGS_COOKIESESSION;
1850                                 $txt2  = _SETTINGS_COOKIEMONTH;
1851                                 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1852                                 break;
1853                         case 'URLMode':
1854                                 $value = $CONF['URLMode'];
1855                                 $txt1  = _SETTINGS_URLMODE_NORMAL;
1856                                 $txt2  = _SETTINGS_URLMODE_PATHINFO;
1857                                 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1858                                 break;
1859                         default:
1860                                 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1861                                 {
1862                                         echo  Entity::hsc($CONF[$type]);
1863                                 }
1864                                 break;
1865                 }
1866                 return;
1867         }
1868         
1869         /**
1870          * AdminActions::parse_configsettingsyesno()
1871          * Parse skinvar configsettingsyesno
1872          *
1873          * @param       string  $type           type of global setting
1874          * @param       integer $tabindex       tabindex attribute of input element
1875          * @return      void
1876          */
1877         public function parse_configsettingsyesno($type, $tabindex)
1878         {
1879                 global $CONF;
1880                 if ( array_key_exists($type, $CONF) )
1881                 {
1882                         $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1883                 }
1884                 return;
1885         }
1886         
1887         /**
1888          * AdminActions::parse_contents()
1889          * Parse skinvar contents
1890          *
1891          * @param       string  $which          part for item
1892          * @return      void
1893          */
1894         public function parse_contents($which)
1895         {
1896                 if ( !array_key_exists($which, Admin::$contents) )
1897                 {
1898                         Admin::$contents[$which] = '';
1899                 }
1900                 echo Entity::hsc(Admin::$contents[$which]);
1901         }
1902         
1903         /**
1904          * AdminActions::parse_currenttime()
1905          * Parse skinvar currenttime
1906          *
1907          * @param       string  $what
1908          */
1909         // for future items
1910         public function parse_currenttime($what)
1911         {
1912                 $nu = getdate(Admin::$blog->getCorrectTime());
1913                 echo $nu[$what];
1914         }
1915         
1916         /**
1917          * AdminActions::parse_customhelplink()
1918          * Parse skinvar customhelplink
1919          *
1920          * @param       string  $topic          name of topic
1921          * @param       string  $tplName        name of template
1922          * @param       string  $url            string as URI
1923          * @param       string  $iconURL        string as URI for icon
1924          * @param       string  $alt            alternative text for image element
1925          * @param       string  $title          title for anchor element
1926          * @return      void
1927          */
1928         public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1929         {
1930                 $this->customHelp($topic, $url, $iconURL);
1931                 return;
1932         }
1933         
1934         /**
1935          * AdminActions::parse_date()
1936          * Parse skinvar date
1937          */
1938         public function parse_date($format = 'c')
1939         {
1940                 global $CONF, $manager;
1941                 /* TODO: offset is based on i18n::get_current_locale()? */
1942                 echo i18n::formatted_datetime($format, time());
1943                 return;
1944         }
1945         
1946         /**
1947          * AdminActions::parse_normalskinlist()
1948          * Parse skinvar defaultadminskintypes
1949          *
1950          * @param       string  $template_name  name of template
1951          * @return      void
1952          */
1953         public function parse_normalskinlist($template_name = '')
1954         {
1955                 global $CONF, $manager;
1956                 
1957                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1958                 {
1959                         $skin =& $manager->getSkin($CONF['BaseSkin']);
1960                         /* TODO: removeaction? */
1961                         $template['editaction'] = 'skinedittype';
1962                 }
1963                 else
1964                 {
1965                         $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1966                         $template['editaction'] = 'adminskinedittype';
1967                         /* TODO: removeaction? */
1968                 }
1969                 
1970                 $temporary = $skin->getNormalTypes();
1971                 $normal_skintype = array();
1972                 foreach ( $temporary as $type => $label )
1973                 {
1974                         $normal_skintype[] = array(
1975                                 'skintype'              => $type,
1976                                 'skintypename'  => $label
1977                         );
1978                 }
1979                 
1980                 $template['tabindex'] = 10;
1981                 $template['skinid'] = intRequestVar('skinid');
1982                 $template['skinname'] = $skin->getName();
1983                 $skin_list = showlist($normal_skintype, 'list_normalskinlist', $template, $template_name);
1984                 $this->parser->parse($skin_list);
1985                 
1986                 return;
1987         }
1988         
1989         /**
1990          * AdminActions::parse_defblogselect()
1991          * Parse skinvar defblogselect
1992          *
1993          * @param       string  $template_name  name of template
1994          * @return      void
1995          */
1996         public function parse_defblogselect($template_name = '')
1997         {
1998                 global $CONF;
1999                 
2000                 $query = "SELECT bname as text, bnumber as value FROM %s;";
2001                 $query = sprintf($query, sql_table('blog'));
2002                 
2003                 $template['name'] = 'DefaultBlog';
2004                 $template['selected'] = $CONF['DefaultBlog'];
2005                 $template['tabindex'] = 10;
2006                 $blog_select = showlist($query, 'select', $template, $template_name);
2007                 $this->parser->parse($blog_select);
2008                 
2009                 return;
2010         }
2011         
2012         /**
2013          * AdminActions::parse_defcatselect()
2014          * Parse skinvar defcatselect
2015          *
2016          * @param       string  $template_name  name of template
2017          * @return      void
2018          */
2019         public function parse_defcatselect($template_name = '')
2020         {
2021                 global $manager;
2022                 
2023                 $blogid = intRequestVar('blogid');
2024                 $blog =& $manager->getBlog($blogid);
2025                 
2026                 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2027                 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2028                 
2029                 $template['name']        = 'defcat';
2030                 $template['selected'] = $blog->getDefaultCategory();
2031                 $template['tabindex'] = 110;
2032                 
2033                 $category_select = showlist($query, 'select', $template, $template_name);
2034                 $this->parser->parse($category_select);
2035                 
2036                 return;
2037         }
2038         
2039         /**
2040          * AdminActions::parse_defskinselect()
2041          * Parse skinvar defskinselect
2042          *
2043          * @param       string  $type                   type of skin
2044          * @param       string  $template_name  name of template
2045          * @return      void
2046          */
2047         public function parse_defskinselect($type = 'blog', $template_name = '')
2048         {
2049                 global $CONF, $manager, $member;
2050                 
2051                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2052                 {
2053                         $blogid = intRequestVar('blogid');
2054                         if ( !$blogid )
2055                         {
2056                                 $template['selected'] = $CONF['BaseSkin'];
2057                         }
2058                         else
2059                         {
2060                                 $blog =& $manager->getBlog($blogid);
2061                                 $template['selected'] = $blog->getDefaultSkin();
2062                         }
2063                                 
2064                         if ( $type != 'blog' )
2065                         {
2066                                 $template['name'] = 'BaseSkin';
2067                         }
2068                         else
2069                         {
2070                                 $template['name'] = 'defskin';
2071                         }
2072                                 
2073                         $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2074                 }
2075                 else
2076                 {
2077                         /* TODO: member object will have its own adminskin id */
2078                         $template['selected'] = $CONF['AdminSkin'];
2079                         $template['name'] = 'AdminSkin';
2080                         $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2081                 }
2082                 
2083                 $query = sprintf($query, sql_table('skin_desc'));
2084                 $template['tabindex'] = 50;
2085                 
2086                 $skin_select = showlist($query, 'select', $template, $template_name);
2087                 $this->parser->parse($skin_select);
2088                 
2089                 return;
2090         }
2091         
2092         /**
2093          * AdminActions::parse_deletecomment()
2094          * Parse skinvar deletecomment
2095          *
2096          * @param       string  $type   type of infomation for comment
2097          * @return      void
2098          */
2099         public function parse_deletecomment($type = 'id')
2100         {
2101                 $commentid      = intRequestVar('commentid');
2102                 $comment        = COMMENT::getComment($commentid);
2103                 
2104                 switch ( $type )
2105                 {
2106                         case 'id':
2107                                 echo intRequestVar('commentid');
2108                                 break;
2109                         case 'author':
2110                                 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2111                                 {
2112                                         echo $comment['member'];
2113                                 }
2114                                 else
2115                                 {
2116                                         echo $comment['user'];
2117                                 }
2118                                 break;
2119                         case 'body':
2120                                 $body = strip_tags($comment['body']);
2121                                 echo Entity::hsc(shorten($body, 300, '...'));
2122                 }
2123                 return;
2124         }
2125         
2126         /**
2127          * AdminActions::parse_deleteitembody()
2128          * Parse skinvar deleteitembody
2129          *
2130          * @param       void
2131          * @return      void
2132          */
2133         public function parse_deleteitembody()
2134         {
2135                 global $manager;
2136                 
2137                 $itemid =  intRequestVar('itemid');
2138                 $item =& $manager->getItem($itemid, 1, 1);
2139                 
2140                 $body =  strip_tags($item['body']);
2141                 
2142                 echo Entity::hsc(shorten($body, 300, '...'));
2143                 
2144                 return;
2145         }
2146         
2147         /**
2148          * AdminActions::parse_deleteitemid()
2149          * Parse skinvar deleteitemid
2150          *
2151          * @param       void
2152          * @return      void
2153          */
2154         public function parse_deleteitemid()
2155         {
2156                 echo (integer) intRequestVar('itemid');
2157                 return;
2158         }
2159         
2160         /**
2161          * AdminActions::parse_deleteitemtitle()
2162          * Parse skinvar deleteitemtitle
2163          *
2164          * @param       void
2165          * @return      void
2166          */
2167         public function parse_deleteitemtitle()
2168         {
2169                 global $manager;
2170                 
2171                 $itemid = intRequestVar('itemid');
2172                 $item =& $manager->getItem($itemid, 1, 1);
2173                 
2174                 echo Entity::hsc(strip_tags($item['title']));
2175                 
2176                 return;
2177         }
2178         
2179         /**
2180          * AdminActions::parse_editcomment()
2181          * Parse skinvar editcomment
2182          *
2183          * @param       string  $type   type of comment setting
2184          * @return      void
2185          */
2186         public function parse_editcomment($type = 'id')
2187         {
2188                 global $manager;
2189                 
2190                 $comment = Admin::$contents;
2191                 
2192                 switch ( $type )
2193                 {
2194                         case 'id':
2195                                 echo intRequestVar('commentid');
2196                                 break;
2197                         case 'user':
2198                                 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2199                                 {
2200                                         echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2201                                 }
2202                                 else
2203                                 {
2204                                         echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2205                                 }
2206                                 break;
2207                         case 'date':
2208                                 echo date("Y-m-d @ H:i", $comment['timestamp']);
2209                                 break;
2210                         case 'body':
2211                                 $comment['body'] = str_replace('<br />', '', $comment['body']);
2212                                 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2213                                 echo $comment['body'];
2214                                 break;
2215                         case 'cmail':
2216                                 echo $comment['userid'];
2217                                 break;
2218                         case 'url':
2219                                 echo $comment['userid'];
2220                                 break;
2221                         default:
2222                                 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2223                                 {
2224                                         echo $comment[$type];
2225                                 }
2226                                 break;
2227                 }
2228                 return;
2229         }
2230         
2231         /**
2232          * AdminActions::parse_editdesturl()
2233          * Parse skinvar editdesturl
2234          */
2235         public function parse_editdesturl()
2236         {
2237                 if ( requestVar('desturl') )
2238                 {
2239                         echo Entity::hsc(requestVar('desturl'));
2240                 }
2241                 return;
2242         }
2243         
2244         /**
2245          * AdminActions::parse_editmemberlist()
2246          * Parse skinvar editmemberlist
2247          *
2248          * @param       string  $template_name  name of template
2249          * @return      void
2250          */
2251         public function parse_editmemberlist($template_name = '')
2252         {
2253                 global $manager;
2254                 // show list of members with actions
2255                 $query = 'SELECT * FROM %s;';
2256                 $query =  sprintf($query, sql_table('member'));
2257                 
2258                 $resource = DB::getResult($query);
2259                 if ( $resource->rowCount() > 0 )
2260                 {
2261                         $template['content'] = 'memberlist';
2262                         $template['tabindex'] = 10;
2263                         
2264                         $member_list = listplug_batchlist('member', $resource, 'table', $template, $template_name);
2265                         $this->parser->parse($member_list);
2266                 }
2267                 else
2268                 {
2269                         echo _LISTS_NOMORE;
2270                 }
2271                 $resource->closeCursor();
2272                 
2273                 return;
2274         }
2275         
2276         /**
2277          * AdminActions::parse_editmember()
2278          * Parse skinvar editmember
2279          *
2280          * @param       string  $type                   type of information for member
2281          * @return      string  $tempateName    name of template to use
2282          * @return      void
2283          */
2284         public function parse_editmember($type = 'id', $template_name = '')
2285         {
2286                 global $CONF, $manager, $member;
2287                 
2288                 $memberid = intRequestVar('memberid');
2289                 $mem =& $manager->getMember($memberid);
2290                 
2291                 switch ( $type )
2292                 {
2293                         case 'id':
2294                                 echo intRequestVar('memberid');
2295                                 break;
2296                         case 'displayname':
2297                                 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2298                                 {
2299                                         echo Entity::hsc($mem->getDisplayName());
2300                                 }
2301                                 else
2302                                 {
2303                                         $dispName = Entity::hsc($mem->getDisplayName());
2304                                         if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2305                                         {
2306                                                 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2307                                         }
2308                                         else
2309                                         {
2310                                                 echo $dispName;
2311                                         }
2312                                 }
2313                                 break;
2314                         case 'realname':
2315                                 echo Entity::hsc($mem->getRealName());
2316                                 break;
2317                         case 'email':
2318                                 echo Entity::hsc($mem->getEmail());
2319                                 break;
2320                         case 'url':
2321                                 echo Entity::hsc($mem->getURL());
2322                                 break;
2323                         case 'admin':
2324                                 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2325                                 break;
2326                         case 'canlogin':
2327                                 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2328                                 break;
2329                         case 'notes':
2330                                 echo Entity::hsc($mem->getNotes());
2331                                 break;
2332                         case 'autosave':
2333                                 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2334                                 break;
2335                         default:
2336                                 break;
2337                 }
2338                 return;
2339         }
2340         
2341         /**
2342          * AdminActions::parse_editpluginfo()
2343          * Parse skinvar editpluginfo
2344          *
2345          * @param       string  $type   type of plugin info
2346          * @return      void
2347          */
2348         public function parse_editpluginfo($type)
2349         {
2350                 global $manager;
2351                 
2352                 $pid = intRequestVar('plugid');
2353                 switch ( $type )
2354                 {
2355                         case 'id':
2356                                 echo $pid;
2357                                 break;
2358                         case 'name':
2359                                 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2360                                 break;
2361                 }
2362                 return;
2363         }
2364         
2365         /**
2366          * AdminActions::parse_editplugoptionslist()
2367          * Parse skinvar editplugoptionslist
2368          *
2369          * @param       string  $template_name  name of template
2370          * @return      void
2371          */
2372         public function parse_editplugoptionslist($template_name = '')
2373         {
2374                 global $manager;
2375                 
2376                 $pid = intRequestVar('plugid');
2377                 $aOptions = array();
2378                 $aOIDs  = array();
2379                 
2380                 $query  = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2381                 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2382                 $resource = DB::getResult($query);
2383                 
2384                 foreach ( $resource as $row )
2385                 {
2386                         $aOIDs[] = $row['oid'];
2387                         $aOptions[$row['oid']] = array(
2388                                 'oid'                   => $row['oid'],
2389                                 'value'                 => $row['odef'],
2390                                 'name'                  => $row['oname'],
2391                                 'description'   => $row['odesc'],
2392                                 'type'                  => $row['otype'],
2393                                 'typeinfo'              => $row['oextra'],
2394                                 'contextid'             => 0
2395                         );
2396                 }
2397                 
2398                 // fill out actual values
2399                 if ( count($aOIDs) > 0 )
2400                 {
2401                         $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2402                         $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2403                                 
2404                         $result = DB::getResult($query);
2405                         foreach ( $result as $row )
2406                         {
2407                                 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2408                         }
2409                 }
2410         
2411                 // call plugins
2412                 $data = array(
2413                         'context'       =>  'global',
2414                         'plugid'        =>  $pid,
2415                         'options'       => &$aOptions
2416                 );
2417                 $manager->notify('PrePluginOptionsEdit', $data);
2418                 
2419                 if ( sizeof($aOptions) > 0 )
2420                 {
2421                         $template['content'] = 'plugoptionlist';
2422                         $option_list = showlist($aOptions, 'table', $template, $template_name);
2423                         $this->parser->parse($option_list);
2424                 }
2425                 else
2426                 {
2427                         echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2428                 }
2429                 return;
2430         }
2431         
2432         /**
2433          * AdminActions::parse_editskin()
2434          * Parse skinvar editskin
2435          *
2436          * @param       string  $type   type of skin
2437          * @return      void
2438          */
2439         public function parse_editskin($type = 'id')
2440         {
2441                 global $manager;
2442                 
2443                 $skinid = intRequestVar('skinid');
2444                 
2445                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2446                 {
2447                         $skin =& $manager->getSKIN($skinid);
2448                 }
2449                 else
2450                 {
2451                         $skin =& $manager->getSKIN($skinid, 'AdminActions');
2452                 }
2453                 
2454                 switch ( $type )
2455                 {
2456                         case 'id':
2457                                 echo intRequestVar('skinid');
2458                                 break;
2459                         case 'name':
2460                                 echo Entity::hsc($skin->getName());
2461                                 break;
2462                         case 'desc':
2463                                 echo Entity::hsc($skin->getDescription());
2464                                 break;
2465                         case 'type':
2466                                 echo Entity::hsc($skin->getContentType());
2467                                 break;
2468                         case 'prefix':
2469                                 echo Entity::hsc($skin->getIncludePrefix());
2470                                 break;
2471                         case 'mode':
2472                                 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2473                         default:
2474                                 break;
2475                 }
2476                 return;
2477         }
2478         
2479         /**
2480          * AdminActions::parse_editskintype()
2481          * Parse skinvar editskintype
2482          *
2483          * @param       string  $type   name of type for skin type
2484          * @return      void
2485          */
2486         public function parse_editskintype($stype = 'id')
2487         {
2488                 global $manager;
2489                 
2490                 static $skin = NULL;
2491                 static $types = array();
2492                 
2493                 if ( $skin == NULL )
2494                 {
2495                         $skinid = intRequestVar('skinid');
2496                         
2497                         if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2498                         {
2499                                 $skin =& $manager->getSkin($skinid);
2500                         }
2501                         else
2502                         {
2503                                 $skin =& $manager->getSkin($skinid, 'AdminActions');
2504                         }
2505                         
2506                         $types = $skin->getNormalTypes();
2507                 }
2508                 
2509                 $type = strtolower(trim(requestVar('type')));
2510                 
2511                 switch ( $stype )
2512                 {
2513                         case 'id':
2514                                 echo $skin->getID();
2515                                 break;
2516                         case 'name':
2517                                 echo Entity::hsc($skin->getName());
2518                                 break;
2519                         case 'desc':
2520                                 echo Entity::hsc($skin->getDescription());
2521                                 break;
2522                         case 'type':
2523                                 echo Entity::hsc($skin->getContentType());
2524                                 break;
2525                         case 'content':
2526                                 echo Entity::hsc($skin->getContentFromDB($type));
2527                                 break;
2528                         case 'skintype':
2529                                 if ( !array_key_exists($type, $types) )
2530                                 {
2531                                         $skinType = ucfirst($type);
2532                                 }
2533                                 else
2534                                 {
2535                                         $skinType = $types[$type];
2536                                 }
2537                                 echo Entity::hsc($skinType);
2538                                 break;
2539                         case 'skintyperaw':
2540                                 echo Entity::hsc($type);
2541                                 break;
2542                         case 'prefix':
2543                                 echo Entity::hsc($skin->getIncludePrefix());
2544                                 break;
2545                         case 'mode':
2546                                 if ( !$skin->getIncludeMode() != 'skindir' )
2547                                 {
2548                                         $incMode = _PARSER_INCMODE_NORMAL;
2549                                 }
2550                                 else
2551                                 {
2552                                         $incMode = _PARSER_INCMODE_SKINDIR;
2553                                 }
2554                                 echo Entity::hsc($incMode);
2555                                 break;
2556                         default:
2557                                 break;
2558                 }
2559                 return;
2560         }
2561         
2562         /**
2563          * AdminActions::parse_adminurl()
2564          * Parse skinvar adminurl
2565          * (shortcut for admin url)
2566          *
2567          * @param       void
2568          * @return      void
2569          */
2570         public function parse_adminurl()
2571         {
2572                 $this->parse_sitevar('adminurl');
2573                 return;
2574         }
2575         
2576         /**
2577          * AdminActions::parse_edittemplateinfo()
2578          * Parse skinvar edittemplateinfo
2579          *
2580          * @param       string  $format         format to output
2581          * @param       string  $typedesc       type of template
2582          * @param       string  $typename       type name of template
2583          * @param       string  $help           help text
2584          * @param       string  $tabindex       index value for tabindex attribute of input element
2585          * @param       string  $big            textarea size
2586          * @param       string  $tplt           name of template to be filled
2587          * @return      boolean
2588          */
2589         public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2590         {
2591                 global $manager;
2592                 static $id = NULL;
2593                 static $name = NULL;
2594                 static $desc = NULL;
2595                 
2596                 if ( $id == NULL )
2597                 {
2598                         $id = intRequestVar('templateid');
2599                 }
2600                 
2601                 if ( $name == NULL )
2602                 {
2603                         $name = Template::getNameFromId($id);
2604                 }
2605                 
2606                 if ( $desc == NULL )
2607                 {
2608                         $desc = Template::getDesc($id);
2609                 }
2610                 
2611                 $template =& $manager->getTemplate($name);
2612                 
2613                 switch ( $format )
2614                 {
2615                         case 'id':
2616                                 echo (integer) $id;
2617                                 break;
2618                         case 'name':
2619                                 echo Entity::hsc($name);
2620                                 break;
2621                         case 'desc':
2622                                 echo Entity::hsc($desc);
2623                                 break;
2624                         case 'extratemplate':
2625                                 $tabidx = 600;
2626                                 $pluginfields = array();
2627                                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2628                                 {
2629                                         $data = array('fields' => &$pluginfields);
2630                                         $manager->notify('TemplateExtraFields', $data);
2631                                 }
2632                                 else
2633                                 {
2634                                         $data = array('fields' => &$pluginfields);
2635                                         $manager->notify('AdminTemplateExtraFields', $data);
2636                                 }
2637                                 
2638                                 foreach ( $pluginfields as $ptkey => $ptvalue )
2639                                 {
2640                                         $tmplt = array();
2641                                         if ( $desc )
2642                                         {
2643                                                 $tmplt =& $manager->getTemplate($desc);
2644                                         }
2645                                                 
2646                                         /* extra plugin field */
2647                                         if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2648                                         {
2649                                                 $base = "<tr>\n"
2650                                                       . "<th colspan=\"2\"><%explugtplname%></th>\n"
2651                                                       . "</tr>";
2652                                         }
2653                                         else
2654                                         {
2655                                                 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2656                                         }
2657                                         $data = array(
2658                                                 'explugtplname' => Entity::hsc($ptkey)
2659                                         );
2660                                         echo Template::fill($base, $data);
2661                                                 
2662                                         foreach ( $ptvalue as $ptname => $ptdesc )
2663                                         {
2664                                                 if ( !array_key_exists($ptname, $template) )
2665                                                 {
2666                                                         $content = '';
2667                                                 }
2668                                                 else
2669                                                 {
2670                                                         $content = $template[$ptname];
2671                                                 }
2672                                                 $tempate_textarea = listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name);
2673                                                 $this->parser->parse($tempate_textarea);
2674                                                 continue;
2675                                         }
2676                                 }
2677                                 break;
2678                         default:
2679                                 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2680                                 $typename = defined($typename) ? constant($typename) : $typename;
2681                                 
2682                                 if ( !array_key_exists($typename, $template) )
2683                                 {
2684                                         $content = '';
2685                                 }
2686                                 else
2687                                 {
2688                                         $content = $template[$typename];
2689                                 }
2690                                 $tempate_textarea = listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name);
2691                                 $this->parser->parse($tempate_textarea);
2692                                 break;
2693                 }
2694                 
2695                 return;
2696         }
2697         
2698         /**
2699          * AdminActions::parse_eventformextra()
2700          * Parse skinvar eventformextra
2701          *
2702          * @param       string  $type   name of type for event form extra
2703          * @return      void
2704          */
2705         public function parse_eventformextra($type = 'activation')
2706         {
2707                 global $manager;
2708                 
2709                 $data = array();
2710                 
2711                 switch ( $type )
2712                 {
2713                         case 'activation':
2714                                 $key = requestVar('ackey');
2715                                 if ( !$key )
2716                                 {
2717                                         Admin::error(_ERROR_ACTIVATE);
2718                                 }
2719                                 $info = MEMBER::getActivationInfo($key);
2720                                 if ( !$info )
2721                                 {
2722                                         Admin::error(_ERROR_ACTIVATE);
2723                                 }
2724                                 $mem  =& $manager->getMember($info->vmember);
2725                                 if ( !$mem )
2726                                 {
2727                                         Admin::error(_ERROR_ACTIVATE);
2728                                 }
2729                                 $data = array(
2730                                         'type'          => 'activation',
2731                                         'member'        => $mem
2732                                 );
2733                                 break;
2734                         case 'membermailform-notloggedin':
2735                                 $data = array('type' => 'membermailform-notloggedin',);
2736                                 break;
2737                 }
2738                 $manager->notify('FormExtra', $data);
2739                 return;
2740         }
2741         
2742         /**
2743          * AdminActions::parse_extrahead()
2744          * Parse skinvar extrahead
2745          */
2746         public function parse_extrahead()
2747         {
2748                 global $manager;
2749                 
2750                 $data = array(
2751                         'extrahead'     => &Admin::$extrahead,
2752                         'action'        => Admin::$action
2753                 );
2754                 
2755                 $manager->notify('AdminPrePageHead', $data);
2756                 
2757                 $this->parser->parse(Admin::$extrahead);
2758                 return;
2759         }
2760         
2761         /**
2762          * AdminActions::parse_member()
2763          * Parse skinvar member
2764          * (includes a member info thingie)
2765          *
2766          * @param       string  $what   which memberdata is needed
2767          * @return      void
2768          */
2769         public function parse_member($what)
2770         {
2771                 global $memberinfo, $member, $CONF;
2772                 
2773                 // 1. only allow the member-details-page specific variables on member pages
2774                 if ( $this->skintype == 'member' )
2775                 {
2776                         switch( $what )
2777                         {
2778                                 case 'name':
2779                                         echo Entity::hsc($memberinfo->getDisplayName());
2780                                         break;
2781                                 case 'realname':
2782                                         echo Entity::hsc($memberinfo->getRealName());
2783                                         break;
2784                                 case 'notes':
2785                                         echo Entity::hsc($memberinfo->getNotes());
2786                                         break;
2787                                 case 'url':
2788                                         echo Entity::hsc($memberinfo->getURL());
2789                                         break;
2790                                 case 'email':
2791                                         echo Entity::hsc($memberinfo->getEmail());
2792                                         break;
2793                                 case 'id':
2794                                         echo Entity::hsc($memberinfo->getID());
2795                                         break;
2796                         }
2797                 }
2798                 
2799                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2800                 if ( $member->isLoggedIn() )
2801                 {
2802                         switch( $what )
2803                         {
2804                                 case 'yourname':
2805                                         echo $member->getDisplayName();
2806                                         break;
2807                                 case 'yourrealname':
2808                                         echo $member->getRealName();
2809                                         break;
2810                                 case 'yournotes':
2811                                         echo $member->getNotes();
2812                                         break;
2813                                 case 'yoururl':
2814                                         echo $member->getURL();
2815                                         break;
2816                                 case 'youremail':
2817                                         echo $member->getEmail();
2818                                         break;
2819                                 case 'yourid':
2820                                         echo $member->getID();
2821                                         break;
2822                                 case 'yourprofileurl':
2823                                         if ( $CONF['URLMode'] == 'pathinfo' )
2824                                         {
2825                                                 echo Link::create_member_link($member->getID());
2826                                         }
2827                                         else
2828                                         {
2829                                                 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2830                                         }
2831                                         break;
2832                         }
2833                 }
2834                 return;
2835         }
2836         
2837         /**
2838          * AdminActions::parse_version()
2839          * Parse skinvar version
2840          * (include nucleus versionnumber)
2841          *
2842          * @param       void
2843          * @return      void
2844          */
2845         public function parse_version()
2846         {
2847                 global $nucleus;
2848                 echo 'Nucleus CMS ' . $nucleus['version'];
2849                 return;
2850         }
2851         
2852         /**
2853          * AdminActions::parse_sitevar()
2854          * Parse skinvar sitevar
2855          * (include a sitevar)
2856          *
2857          * @param       string  $which
2858          * @return      void
2859          */
2860         public function parse_sitevar($which)
2861         {
2862                 global $CONF;
2863                 switch ( $which )
2864                 {
2865                         case 'url':
2866                                 echo $CONF['IndexURL'];
2867                                 break;
2868                         case 'name':
2869                                 echo $CONF['SiteName'];
2870                                 break;
2871                         case 'admin':
2872                                 echo $CONF['AdminEmail'];
2873                                 break;
2874                         case 'adminurl':
2875                                 echo $CONF['AdminURL'];
2876                                 break;
2877                 }
2878                 return;
2879         }
2880         
2881         /**
2882          * AdminActions::parse_actionurl()
2883          * Parse $CONF;
2884          *
2885          * @param       void
2886          * @return      void
2887          */
2888         public function parse_actionurl()
2889         {
2890                 global $CONF;
2891                 echo Entity::hsc($CONF['ActionURL']);
2892                 return;
2893         }
2894         
2895         /**
2896          * AdminActions::parse_getblogsetting()
2897          * Parse skinvar getblogsetting
2898          */
2899         public function parse_getblogsetting($which)
2900         {
2901                 global $blog, $manager;
2902                 
2903                 if ( $blog )
2904                 {
2905                         $b =& $blog;
2906                 }
2907                 elseif ( $bid = intRequestVar('blogid') )
2908                 {
2909                         $b =& $manager->getBlog($bid);
2910                 }
2911                 else
2912                 {
2913                         return;
2914                 }
2915         
2916                 switch ( $which )
2917                 {
2918                         case 'id':
2919                                 return Entity::hsc($b->getID());
2920                                 break;
2921                         case 'url':
2922                                 return Entity::hsc($b->getURL());
2923                                 break;
2924                         case 'name':
2925                                 return Entity::hsc($b->getName());
2926                                 break;
2927                         case 'desc':
2928                                 return Entity::hsc($b->getDescription());
2929                                 break;
2930                         case 'short':
2931                                 return Entity::hsc($b->getShortName());
2932                                 break;
2933                         case 'notifyaddress':
2934                                 return Entity::hsc($b->getNotifyAddress());
2935                                 break;
2936                         case 'maxcomments':
2937                                 return Entity::hsc($b->getMaxComments());
2938                                 break;
2939                         case 'updatefile':
2940                                 return Entity::hsc($b->getUpdateFile());
2941                                 break;
2942                         case 'timeoffset':
2943                                 return Entity::hsc($b->getTimeOffset());
2944                                 break;
2945                 }
2946                 return;
2947         }
2948         
2949         /**
2950          * AdminActions::parse_geteditpluginfo()
2951          * Parse skinvar geteditpluginfo
2952          *
2953          * @param       string  $type   name of setting for edit plugin info
2954          * @return      void
2955          */
2956         public function parse_geteditpluginfo($type)
2957         {
2958                 global $manager;
2959                 $pid = intRequestVar('plugid');
2960                 switch ( $type )
2961                 {
2962                         case 'id':
2963                                 return $pid;
2964                                 break;
2965                         case 'name':
2966                                 return Entity::hsc($manager->getPluginNameFromPid($pid));
2967                                 break;
2968                 }
2969                 return;
2970         }
2971         
2972         /**
2973          * AdminActions::parse_getmember()
2974          * Parse skinvar getmember
2975          * (includes a member info thingie)
2976          *
2977          * @param       string  $what   name of setting for member
2978          * @return      void
2979          */
2980         public function parse_getmember($what)
2981         {
2982                 global $memberinfo, $member;
2983                 // 1. only allow the member-details-page specific variables on member pages
2984                 if ( $this->skintype == 'member' )
2985                 {
2986                         switch ( $what )
2987                         {
2988                                 case 'name':
2989                                         return Entity::hsc($memberinfo->getDisplayName());
2990                                         break;
2991                                 case 'realname':
2992                                         return Entity::hsc($memberinfo->getRealName());
2993                                         break;
2994                                 case 'notes':
2995                                         return Entity::hsc($memberinfo->getNotes());
2996                                         break;
2997                                 case 'url':
2998                                         return Entity::hsc($memberinfo->getURL());
2999                                         break;
3000                                 case 'email':
3001                                         return Entity::hsc($memberinfo->getEmail());
3002                                         break;
3003                                 case 'id':
3004                                         return Entity::hsc($memberinfo->getID());
3005                                         break;
3006                         }
3007                 }
3008                 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3009                 if ( $member->isLoggedIn() )
3010                 {
3011                         switch ( $what )
3012                         {
3013                                 case 'yourname':
3014                                         return $member->getDisplayName();
3015                                         break;
3016                                 case 'yourrealname':
3017                                         return $member->getRealName();
3018                                         break;
3019                                 case 'yournotes':
3020                                         return $member->getNotes();
3021                                         break;
3022                                 case 'yoururl':
3023                                         return $member->getURL();
3024                                         break;
3025                                 case 'youremail':
3026                                         return $member->getEmail();
3027                                         break;
3028                                 case 'yourid':
3029                                         return $member->getID();
3030                                         break;
3031                         }
3032                 }
3033                 return;
3034         }
3035         
3036         /**
3037          * AdminActions::parse_headmessage()
3038          * Parse skinvar headmessage
3039          *
3040          * @param       void
3041          * @return      void
3042          */
3043         public function parse_headmessage()
3044         {
3045                 if ( !empty(Admin::$headMess) )
3046                 {
3047                         echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3048                 }
3049                 return;
3050         }
3051         
3052         /**
3053          * AdminActions::parse_helplink()
3054          * Parse skinvar helplink
3055          *
3056          * @param       string  $topic  name of topic for help
3057          * @return      void
3058          */
3059         public function parse_helplink($topic = '')
3060         {
3061                 if ( !empty($topic) )
3062                 {
3063                         help($topic);
3064                 }
3065                 return;
3066         }
3067         
3068         /**
3069          * AdminActions::parse_helpplugname()
3070          * Parse skinvar helpplugname
3071          *
3072          * @param       void
3073          * @return      void
3074          */
3075         public function parse_helpplugname()
3076         {
3077                 $plugid = intGetVar('plugid');
3078                 Entity::hsc($manager->getPluginNameFromPid($plugid));
3079                 return;
3080         }
3081         
3082         /**
3083          * AdminActions::parse_ilistaddnew()
3084          * Parse skinvar ilistaddnew
3085          *
3086          * @param       void
3087          * @return      void
3088          */
3089         public function parse_ilistaddnew()
3090         {
3091                 $blogid = intRequestVar('blogid');
3092                 if ( intPostVar('start') == 0 )
3093                 {
3094                         echo '<p><a href="index.php?action=createitem&amp;blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3095                 }
3096                 return;
3097         }
3098         
3099         /**
3100          * AdminActions::parse_importskininfo()
3101          * Parse skinvar importskininfo
3102          *
3103          * @param       string  $type   name of information for imported skin
3104          * @return      void
3105          */
3106         public function parse_importskininfo($type)
3107         {
3108                 switch ( $type )
3109                 {
3110                         case 'info':
3111                                 echo Entity::hsc(Admin::$contents['skininfo']);
3112                                 break;
3113                         case 'snames':
3114                                 $dataArr = Admin::$contents['skinnames'];
3115                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3116                                 break;
3117                         case 'tnames':
3118                                 $dataArr = Admin::$contents['tpltnames'];
3119                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3120                                 break;
3121                         case 'sclashes':
3122                                 $dataArr = Admin::$contents['skinclashes'];
3123                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3124                                 break;
3125                         case 'tclashes':
3126                                 $dataArr = Admin::$contents['tpltclashes'];
3127                                 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3128                                 break;
3129                         case 'skinfile':
3130                                 echo Entity::hsc(Admin::$contents['skinfile']);
3131                                 break;
3132                         case 'mode':
3133                                 echo Entity::hsc(Admin::$contents['mode']);
3134                                 break;
3135                 }
3136                 return;
3137         }
3138         
3139         /**
3140          * AdminActions::parse_init()
3141          * some init stuff for all forms
3142          *
3143          * @param       void
3144          * @return      void
3145          */
3146         public function parse_init()
3147         {
3148                 global $manager;
3149                 
3150                 $authorid = '';
3151                 if ( requestVar('action') == 'itemedit' )
3152                 {
3153                         $authorid = Admin::$contents['authorid'];
3154                 }
3155                 
3156                 Admin::$blog->insertJavaScriptInfo($authorid);
3157                 return;
3158         }
3159         
3160         /**
3161          * AdminActions::parse_inputyesno()
3162          * Parse skinvar inputyesno
3163          *
3164          * @param       string  $name
3165          * @param       string  $checkedval
3166          * @param       string  $tabindex
3167          * @param       string  $value1
3168          * @param       string  $value2
3169          * @param       string  $yesval
3170          * @param       string  $noval
3171          * @param       string  $isAdmin
3172          * @param       string  $template_name
3173          * @return      void
3174          */
3175         public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3176         {
3177                 $input_yesno = listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name);
3178                 $this->parser->parse($input_yesno);
3179                 return;
3180         }
3181         
3182         /**
3183          * AdminActions::parse_insertpluginfo()
3184          * Parse templatevar insertpluginfo
3185          */
3186         public function parse_insertpluginfo($type)
3187         {
3188                 switch ( $type )
3189                 {
3190                         case 'id':
3191                                 return Admin::$aOptions['pid'];
3192                                 break;
3193                         case 'name':
3194                                 return Entity::hsc(Admin::$aOptions['pfile']);
3195                                 break;
3196                 }
3197                 return;
3198         }
3199         
3200         /**
3201          * AdminActions::parse_insplugoptcontent()
3202          * Parse skinvar insplugoptcontent
3203          *
3204          * @param       void
3205          * @return      void
3206          */
3207         public function parse_insplugoptcontent()
3208         {
3209                 $meta = NucleusPlugin::getOptionMeta(Admin::$aOptions['typeinfo']);
3210                 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3211                 {
3212                         echo '<tr>';
3213                         listplug_plugOptionRow(Admin::$aOptions);
3214                         echo '</tr>';
3215                 }
3216                 return;
3217         }
3218         
3219         /**
3220          * AdminActions::parse_iprangeinput()
3221          * Parse skinvar iprangeinput
3222          *
3223          * @param       void
3224          * @return      void
3225          */
3226         public function parse_iprangeinput()
3227         {
3228                 if ( requestVar('ip') )
3229                 {
3230                         $iprangeVal = Entity::hsc(requestVar('ip'));
3231                         echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3232                         echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3233                         echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3234                         echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3235                         echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3236                 }
3237                 else
3238                 {
3239                         echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3240                         echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3241                 }
3242                 return;
3243         }
3244         
3245         /**
3246          * AdminActions::parse_itemnavlist()
3247          * Parse skinvar itemnavlist
3248          *
3249          * @param       string  $template_name  name of template to use
3250          * @return      void
3251          */
3252         public function parse_itemnavlist($template_name = '')
3253         {
3254                 global $CONF, $manager, $member;
3255                 
3256                 $query  = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3257                       . " FROM %s, %s, %s, %s"
3258                       . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3259                 
3260                 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3261                 
3262                 if ( $this->skintype == 'itemlist' )
3263                 {
3264                         $blog = FALSE;
3265                         if ( array_key_exists('blogid', $_REQUEST) )
3266                         {
3267                                 $blogid = intRequestVar('blogid');
3268                         }
3269                         else if ( array_key_exists('itemid', $_REQUEST) )
3270                         {
3271                                 $itemid =  intRequestVar('itemid');
3272                                 $item   = &$manager->getItem($itemid, 1, 1);
3273                                 $blogid =  (integer) $item['blogid'];
3274                         }
3275                         $blog =& $manager->getBlog($blogid);
3276                                 
3277                         $query .= " AND iblog={$blogid}";
3278                         $template['now'] = $blog->getCorrectTime(time());
3279                                 
3280                         // non-blog-admins can only edit/delete their own items
3281                         if ( !$member->blogAdminRights($blogid) )
3282                         {
3283                                 $query .= ' AND iauthor = ' . $member->getID();
3284                         }
3285                 }
3286                 elseif ( $this->skintype == 'browseownitems' )
3287                 {
3288                         $query .= ' AND iauthor   = ' . $member->getID();
3289                         $blogid = 0;
3290                         $template['now'] = time();
3291                 }
3292                 
3293                 // search through items
3294                 $search = postVar('search');
3295                 
3296                 if ( !empty($search) )
3297                 {
3298                         $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3299                         . '  OR  (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3300                         . '  OR  (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3301                 }
3302                 
3303                 if ( postVar('start') )
3304                 {
3305                         $start = intPostVar('start');
3306                 }
3307                 else
3308                 {
3309                         $start = 0;
3310                 }
3311                 
3312                 // amount of items to show
3313                 if ( postVar('amount') )
3314                 {
3315                         $amount = intPostVar('amount');
3316                 }
3317                 else
3318                 {
3319                         $amount = (integer) $CONF['DefaultListSize'];
3320                         if ( $amount < 1 )
3321                         {
3322                                 $amount = 10;
3323                         }
3324                 }
3325                 
3326                 $query .= ' ORDER BY itime DESC'
3327                         . " LIMIT {$start},{$amount}";
3328                 
3329                 $resource = DB::getResult($query);
3330                 if ( $resource->rowCount() > 0 )
3331                 {
3332                         $template['action'] = $this->skintype;
3333                         $template['start'] = $start;
3334                         $template['amount'] = $amount;
3335                         $template['minamount'] = 0;
3336                         $template['maxamount'] = 1000;
3337                         $template['blogid'] = $blogid;
3338                         $template['search'] = $search;
3339                         $template['itemid'] = 0;
3340                                 
3341                         $template['content'] = 'itemlist';
3342                                 
3343                         $navlist = listplug_navlist('item', $query, 'table', $template, $template_name);
3344                         $this->parser->parse($navlist);
3345                 }
3346                 else
3347                 {
3348                         /* TODO: nothing to be shown */
3349                 }
3350                 $resource->closeCursor();
3351
3352                 return;
3353         }
3354         
3355         /**
3356          * AdminActions::parse_itemtime()
3357          * date change on edit item
3358          *
3359          * @param       string  $key    key of PHP's getDate()
3360          * @return      void
3361          */
3362         public function parse_itemtime($key)
3363         {
3364                 global $manager;
3365                 
3366                 $contents = Admin::$contents;
3367                 $itemtime = getdate($contents['timestamp']);
3368                 echo $itemtime[$key];
3369                 return;
3370         }
3371         
3372         /**
3373          * AdminActions::parse_jstoolbaroptions()
3374          * Parse skinvar jstoolbaroptions
3375          *
3376          * @param       void
3377          * @return      void
3378          */
3379         public function parse_jstoolbaroptions()
3380         {
3381                 global $CONF;
3382                 $options = array(
3383                         _SETTINGS_JSTOOLBAR_NONE,
3384                         _SETTINGS_JSTOOLBAR_SIMPLE,
3385                         _SETTINGS_JSTOOLBAR_FULL
3386                 );
3387                 
3388                 $i = 1;
3389                 foreach ( $options as $option )
3390                 {
3391                         $text  = "<option value=\"%d\"%s>%s</option>\n";
3392                         $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3393                         echo sprintf($text, $i, $extra, $option);
3394                         $i++;
3395                 }
3396                 return;
3397         }
3398         /**
3399          * AdminActions::parse_localeselectoptions()
3400          * Parse skinvar localeselectoptions
3401          *
3402          * @param       void
3403          * @return      void
3404          */
3405         public function parse_localeselectoptions()
3406         {
3407                 global $CONF, $member;
3408                 
3409                 $locales = i18n::get_available_locale_list();
3410                 
3411                 /* default option */
3412                 if ( $this->skintype == 'editmembersettings' )
3413                 {
3414                         if ( !$member->getLocale() )
3415                         {
3416                                 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3417                         }
3418                         else
3419                         {
3420                                 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3421                         }
3422                 }
3423                 else
3424                 {
3425                         if ( $CONF['Locale'] == 'en_Latn_US' )
3426                         {
3427                                 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
3428                         }
3429                         else
3430                         {
3431                                 echo "<option value=\"\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
3432                         }
3433                 }
3434                 
3435                 /* optional options */
3436                 foreach ( $locales as $locale )
3437                 {
3438                         if ( $this->skintype == 'editmembersettings' )
3439                         {
3440                                 if ( $locale != $member->getLocale() )
3441                                 {
3442                                         echo "<option value=\"{$locale}\">";
3443                                 }
3444                                 else
3445                                 {
3446                                         echo "<option value=\"{$locale}\" selected=\"selected\">";
3447                                 }
3448                         }
3449                         else
3450                         {
3451                                 if ( $locale == 'en_Latn_US' )
3452                                 {
3453                                         /* already output */
3454                                         continue;
3455                                 }
3456                                 else if ( $locale != $CONF['Locale'] )
3457                                 {
3458                                         echo "<option value=\"{$locale}\">";
3459                                 }
3460                                 else
3461                                 {
3462                                         echo "<option value=\"{$locale}\" selected=\"selected\">";
3463                                 }
3464                         }
3465                         $label = '_LOCALE_' . strtoupper($locale);
3466                         if ( !defined($label) )
3467                         {
3468                                 echo $locale;
3469                         }
3470                         else
3471                         {
3472                                 echo constant($label);
3473                         }
3474                         echo "</option>\n";
3475                 }
3476                 return;
3477         }
3478         
3479         /**
3480          * AdminActions::parse_listplugplugoptionrow()
3481          * Parse templatevar listplugplugoptionrow
3482          *
3483          * @param       string  $template_name  name of template
3484          * @return      void
3485          */
3486         public function parse_listplugplugoptionrow($template_name = '')
3487         {
3488                 echo listplug_plugOptionRow(Admin::$aOptions, $template_name);
3489                 return;
3490         }
3491         
3492         /**
3493          * AdminActions::parse_mediadirwarning()
3494          * Parse skinvar mediadirwarning
3495          *
3496          * @param       void
3497          * @return      void
3498          */
3499         public function parse_mediadirwarning()
3500         {
3501                 global $DIR_MEDIA;
3502                 if ( !is_dir($DIR_MEDIA) )
3503                 {
3504                         echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3505                 }
3506                 if ( !is_readable($DIR_MEDIA) )
3507                 {
3508                         echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3509                 }
3510                 if ( !is_writeable($DIR_MEDIA) )
3511                 {
3512                         echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3513                 }
3514                 return;
3515         }
3516         
3517         /**
3518          * AdminActions::parse_movedistselect()
3519          * Parse skinvar movedistselect
3520          */
3521         public function parse_movedistselect()
3522         {
3523                 $actionType = requestVar('action');
3524                 switch ( $actionType )
3525                 {
3526                         case 'batchitem':
3527                                 $this->selectBlog('destcatid', 'category');
3528                                 break;
3529                         case 'batchcategory':
3530                                 $this->selectBlog('destblogid');
3531                                 break;
3532                         default:
3533                                 if ( $this->skintype == 'itemmove' )
3534                                 {
3535                                         $query  = "SELECT icat as result FROM %s WHERE inumber=%d;";
3536                                         $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3537                                         $catid  = DB::getValue(sprintf($query, intRequestVar('itemid')));
3538                                         $this->selectBlog('catid', 'category', $catid, 10, 1);
3539                                 }
3540                                 break;
3541                 }
3542                 return;
3543         }
3544         
3545         /**
3546          * AdminActions::parse_moveitemid()
3547          * Parse skinvar moveitemid
3548          *
3549          * @param       void
3550          * @return      void
3551          */
3552         public function parse_moveitemid()
3553         {
3554                 echo intRequestVar('itemid');
3555                 return;
3556         }
3557         
3558         /**
3559          * AdminActions::parse_newestcompare()
3560          * Parse skinvar newestcompare
3561          *
3562          * @param       void
3563          * @return      void
3564          */
3565         public function parse_newestcompare()
3566         {
3567                 global $nucleus;
3568                 
3569                 $newestVersion  = getLatestVersion();
3570                 $newestCompare  = str_replace('/', '.', $newestVersion);
3571                 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3572                 
3573                 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3574                 {
3575                         echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3576                         echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3577                 }
3578                 else
3579                 {
3580                         echo _ADMIN_SYSTEMOVERVIEW_VERSION_LATEST;
3581                 }
3582                 return;
3583         }
3584         
3585         /**
3586          * AdminActions::parse_newmemberselect()
3587          * Parse skinvar newmemberselect
3588          *
3589          * @param       string  $template_name  name of template to use
3590          * @return      void
3591          */
3592         public function parse_newmemberselect($template_name = '')
3593         {
3594                 $blogid = intRequestVar('blogid');
3595                 
3596                 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3597                 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3598                 $res = DB::getResult($query);
3599                 
3600                 $tmem = array();
3601                 foreach ( $res as $row )
3602                 {
3603                         $tmem[] = intval($row['tmember']);
3604                 }
3605                 
3606                 $query  = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3607                 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3608                 
3609                 $template = array(
3610                         'name'          => 'memberid',
3611                         'tabindex'      => 10000,
3612                         'selected'      => 0
3613                 );
3614                 $member_select = showlist($query, 'select', $template, $template_name);
3615                 $this->parser->parse($member_select);
3616                 return;
3617         }
3618         
3619         /**
3620          * AdminActions::parse_newpluginlist()
3621          * Parse skinvar newpluginlist
3622          *
3623          * @param       void
3624          * @return      void
3625          */
3626         public function parse_newpluginlist()
3627         {
3628                 $candidates = $this->newPlugCandidates;
3629                 foreach ( $candidates as $name )
3630                 {
3631                         echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3632                 }
3633                 return;
3634         }
3635         
3636         /**
3637          * AdminActions::parse_outputspecialdirs()
3638          * Parse skinvar outputspecialdirs
3639          *
3640          * @param       string  $type   type of setting for directory
3641          * @return      void
3642          */
3643         public function parse_outputspecialdirs($type)
3644         {
3645                 global $DIR_MEDIA, $DIR_NUCLEUS;
3646                 
3647                 switch ( $type )
3648                 {
3649                         case 'nucleusdir':
3650                                 echo Entity::hsc($DIR_NUCLEUS);
3651                                 break;
3652                         case 'mediadir':
3653                                 echo Entity::hsc($DIR_MEDIA);
3654                                 break;
3655                 }
3656                 return;
3657         }
3658         
3659         /**
3660          * AdminActions::parse_passrequestvars()
3661          * Parse skinvar passrequestvars
3662          *
3663          * @param       void
3664          * @return      void
3665          */
3666         public function parse_passrequestvars()
3667         {
3668                 $passvar   = Admin::$passvar;
3669                 $oldaction = postVar('oldaction');
3670                 
3671                 if ( ($oldaction != 'logout')
3672                 && ($oldaction != 'login')
3673                 && $passvar
3674                 && !postVar('customaction') )
3675                 {
3676                         passRequestVars();
3677                 }
3678                 return;
3679         }
3680         
3681         /**
3682          * AdminActions::parse_pluginextras()
3683          * Parse skinvar pluginextras
3684          *
3685          * @param       string  $type   type of plugin context
3686          * @return      void
3687          */
3688         public function parse_pluginextras($type = 'global')
3689         {
3690                 global $manager;
3691                 
3692                 switch ( $type )
3693                 {
3694                         case 'member':
3695                                 $id  = intRequestVar('memberid');
3696                                 $mem =& $manager->getMember($id);
3697                                 $data = array('member' => &$mem);
3698                                 $manager->notify('MemberSettingsFormExtras', $data);
3699                                 break;
3700                         case 'blog':
3701                                 $id  = intRequestVar('blogid');
3702                                 $blg =& $manager->getBlog($id);
3703                                 $data = array('member' => &$blg);
3704                                 $manager->notify('BlogSettingsFormExtras', $data);
3705                                 break;
3706                         case 'createaccount':
3707                                 $data = array(
3708                                         'type'          => 'createaccount.php',
3709                                         'prelabel'      => '',
3710                                         'postlabel'     => '<br />',
3711                                         'prefield'      => '',
3712                                         'postfield'     => '<br /><br />'
3713                                 );
3714                                 $manager->notify('RegistrationFormExtraFields', $data);
3715                                 break;
3716                         default:
3717                         $data = array();
3718                                 $manager->notify('GeneralSettingsFormExtras', $data);
3719                                 break;
3720                 }
3721                 return;
3722         }
3723         
3724         /**
3725          * AdminActions::parse_pluginhelp()
3726          * Parse skinvar pluginhelp
3727          *
3728          * @param       void
3729          * @return      void
3730          */
3731         public function parse_pluginhelp()
3732         {
3733                 global $manager, $DIR_PLUGINS;
3734                 
3735                 $plugid = intGetVar('plugid');
3736                 $plugName = $manager->getPluginNameFromPid($plugid);
3737                 $plug =& $manager->getPlugin($plugName);
3738                 
3739                 if ( $plug->supportsFeature('HelpPage') > 0 )
3740                 {
3741                         $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3742                         if ( @file_exists($helpfile . 'php') )
3743                         {
3744                                 @include($helpfile . 'php');
3745                                 return;
3746                         }
3747                         elseif ( @file_exists($helpfile . 'html') )
3748                         {
3749                                 @include($helpfile . 'html');
3750                                 return;
3751                         }
3752                 }
3753                 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3754                 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3755                 return;
3756         }
3757         
3758         /**
3759          * AdminActions::parse_pluginlistlist()
3760          * Parse skinvar pluginlistlist
3761          *
3762          * @param       string  $template_name  name of template to use
3763          * @return      void
3764          */
3765         public function parse_pluginlistlist($template_name = '')
3766         {
3767                 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3768                 $query = sprintf($query, sql_table('plugin'));
3769                 
3770                 $template['content']  = 'pluginlist';
3771                 $template['tabindex'] = 10;
3772                 
3773                 $plugin_list = showlist($query, 'table', $template, $template_name);
3774                 $this->parser->parse($plugin_list);
3775                 
3776                 return;
3777         }
3778         
3779         /**
3780          * AdminActions::parse_pluginoptions()
3781          * Parse skinvar pluginoptions
3782          *
3783          * @param       string  $type   type of plugin option
3784          * @return      void
3785          */
3786         public function parse_pluginoptions($context='global', $template_name='')
3787         {
3788                 global $itemid, $manager;
3789                 
3790                 switch ( $context )
3791                 {
3792                         case 'member':
3793                                 $contextid = intRequestVar('memberid');
3794                                 break;
3795                         case 'blog':
3796                                 $contextid = intRequestVar('blogid');
3797                                 break;
3798                         case 'category':
3799                                 $contextid = intRequestVar('catid');
3800                                 break;
3801                         case 'item':
3802                                 $contextid = $itemid;
3803                                 break;
3804                 }
3805                 
3806                 /* Actually registererd plugin options */
3807                 $aIdToValue = array();
3808                 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3809                 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3810                 $res = DB::getResult($query);
3811                 foreach ( $res as $row )
3812                 {
3813                         $aIdToValue[$row['oid']] = $row['ovalue'];
3814                 }
3815                 
3816                 /* Currently available plugin options */
3817                 $query  = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3818                 $query  = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3819                 $res    = DB::getResult($query);
3820                 
3821                 $options = array();
3822                 foreach ($res as $row )
3823                 {
3824                         if ( !array_key_exists($row['oid'], $aIdToValue) )
3825                         {
3826                                 $value = $row['odef'];
3827                         }
3828                         else
3829                         {
3830                                 $value = $aIdToValue[$row['oid']];
3831                         }
3832                         
3833                         $options[] = array(
3834                                 'pid'                   => $row['pid'],
3835                                 'pfile'                 => $row['pfile'],
3836                                 'oid'                   => $row['oid'],
3837                                 'value'                 => $value,
3838                                 'name'                  => $row['oname'],
3839                                 'description'   => $row['odesc'],
3840                                 'type'                  => $row['otype'],
3841                                 'typeinfo'              => $row['oextra'],
3842                                 'contextid'             => $contextid,
3843                                 'extra'                 => ''
3844                         );
3845                 }
3846                 
3847                 $data = array(
3848                         'context'       =>  $context,
3849                         'contextid'     =>  $contextid,
3850                         'options'       => &$options
3851                 );
3852                 $manager->notify('PrePluginOptionsEdit', $data);
3853                 
3854                 $template = array();
3855                 if ( $template_name )
3856                 {
3857                         $templates =& $manager->getTemplate($template_name);
3858                         if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3859                         {
3860                                 $template['title'] = "<tr>"
3861                                 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3862                                 . "</tr>\n";
3863                         }
3864                         else
3865                         {
3866                                 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3867                         }
3868                         
3869                         if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3870                         {
3871                                 $template['body'] = "<tr>"
3872                                 . "<%listplugplugoptionrow%>"
3873                                 . "</tr>\n";
3874                         }
3875                         else
3876                         {
3877                                 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3878                         }
3879                 }
3880                 
3881                 $prevPid = -1;
3882                 
3883                 foreach ( $options as $option )
3884                 {
3885                         // new plugin?
3886                         if ( $prevPid != $option['pid'] )
3887                         {
3888                                 $prevPid  = $option['pid'];
3889                                 $this->parser->parse($template['title']);
3890                         }
3891                         
3892                         $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3893                         
3894                         if ( @$meta['access'] != 'hidden' )
3895                         {
3896                                 $parsed = $this->parser->parse($template['body']);
3897                         }
3898                 }
3899         
3900                 return;
3901         }
3902         
3903         /**
3904          * AdminActions::parse_qmenuaddselect()
3905          * Parse skinvar qmanuaddselect
3906          *
3907          * @param       string  $template_name  name of template to use
3908          * @return      void
3909          */
3910         public function parse_qmenuaddselect($template_name = '')
3911         {
3912                 global $member, $blogid;
3913                 $showAll = requestVar('showall');
3914                 if ( $member->isAdmin() && ($showAll == 'yes') )
3915                 {
3916                         // Super-Admins have access to all blogs! (no add item support though)
3917                         $query =  'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3918                         $query = sprintf($query, sql_table('blog'));
3919                 }
3920                 else
3921                 {
3922                         $query =  'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3923                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3924                 }
3925                 
3926                 $template['name']               = 'blogid';
3927                 $template['tabindex']   = 15000;
3928                 $template['extra']              = _QMENU_ADD_SELECT;
3929                 $template['selected']   = 0;
3930                 $template['shorten']    = 10;
3931                 $template['shortenel']  = '';
3932                 $template['javascript'] = 'onchange="return form.submit()"';
3933                 
3934                 $selectlist = showlist($query, 'select', $template, $template_name);
3935                 $this->parser->parse($selectlist);
3936                 
3937                 return;
3938         }
3939         
3940         /**
3941          * AdminActions::parse_quickmenu()
3942          * Parse skinvar quickmenu
3943          *
3944          * @param       string  $template_name  name of template to use
3945          * @return      void
3946          */
3947         public function parse_quickmenu($template_name = '')
3948         {
3949                 global $manager;
3950                 $templates = array();
3951                 
3952                 if ( !empty($template_name) )
3953                 {
3954                         $templates = & $manager->getTemplate($template_name);
3955                 }
3956                 $pluginExtras = array();
3957                 $data = array('options' => &$pluginExtras);
3958                 $manager->notify('QuickMenu', $data);
3959                 
3960                 $template  = array();
3961                 if ( count($pluginExtras) > 0 )
3962                 {
3963                         if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3964                         {
3965                                 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3966                                 . "<ul>\n";
3967                         }
3968                         else
3969                         {
3970                                 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3971                         }
3972                         
3973                         if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3974                         {
3975                                 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3976                         }
3977                         else
3978                         {
3979                                 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3980                         }
3981                         
3982                         if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3983                         {
3984                                 $template['foot'] = "</ul>\n";
3985                         }
3986                         else
3987                         {
3988                                 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3989                         }
3990                         
3991                         $this->parser->parse($template['head']);
3992                         foreach ( $pluginExtras as $aInfo )
3993                         {
3994                                 $data = array(
3995                                         'plugadminurl'          => Entity::hsc($aInfo['url']),
3996                                         'plugadmintooltip'      => Entity::hsc($aInfo['tooltip']),
3997                                         'plugadmintitle'        => Entity::hsc($aInfo['title']),
3998                                 );
3999                                 $body = Template::fill($template['body'], $data);
4000                                 $this->parser->parse($body);
4001                         }
4002                         $this->parser->parse($template['foot']);
4003                 }
4004                 return;
4005         }
4006         
4007         /**
4008          * AdminActions::parse_requestblogid()
4009          * Parse skinvar requestblogid
4010          *
4011          * @param       void
4012          * @return      void
4013          */
4014         public function parse_requestblogid()
4015         {
4016                 echo intRequestVar('blogid');
4017                 return;
4018         }
4019         
4020         /**
4021          * AdminActions::parse_requestiprange()
4022          * Parse skinvar requestiprange
4023          *
4024          * @param       void
4025          * @return      void
4026          */
4027         public function parse_requestiprange()
4028         {
4029                 if ( requestVar('iprange') )
4030                 {
4031                         echo Entity::hsc(requestVar('iprange'));
4032                 }
4033                 elseif ( requestVar('ip') )
4034                 {
4035                         echo Entity::hsc(requestVar('ip'));
4036                 }
4037                 return;
4038         }
4039         
4040         /**
4041          * AdminActions::parse_selectlocalskinfiles()
4042          * Parse skinvar selectlocalskinfiles
4043          *
4044          * @param       void
4045          * @return      void
4046          */
4047         public function parse_selectlocalskinfiles()
4048         {
4049                 global $DIR_SKINS;
4050                 
4051                 if ( !class_exists('SkinImport', FALSE) )
4052                 {
4053                         include_libs('skinie.php');
4054                 }
4055                 
4056                 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4057                 {
4058                         $skindir = $DIR_SKINS;
4059                 }
4060                 else
4061                 {
4062                         $skindir = "{$DIR_SKINS}admin/";
4063                 }
4064                 
4065                 $candidates = SkinImport::searchForCandidates($skindir);
4066                 foreach ( $candidates as $skinname => $skinfile )
4067                 {
4068                         $skinname = Entity::hsc($skinname);
4069                         if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4070                         {
4071                                 $skinfile = Entity::hsc($skinfile);
4072                         }
4073                         else
4074                         {
4075                                 $skinfile = Entity::hsc("admin/$skinfile");
4076                         }
4077                         echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4078                 }
4079         
4080                 return;
4081         }
4082         
4083         /**
4084          * AdminActions::parse_skineditallowedlist()
4085          * Parse skinvar skineditallowedlist
4086          *
4087          * @param       string  $type                   type of skin
4088          * @param       string  $template_name  name of template
4089          * @return      void
4090          */
4091         public function parse_skineditallowedlist($type, $template_name = '')
4092         {
4093                 switch ( $type )
4094                 {
4095                         case 'blog':
4096                                 $query = "SELECT bshortname, bname FROM %s;";
4097                                 $show  = array(
4098                                         'content' => 'shortblognames'
4099                                 );
4100                                 $query = sprintf($query, sql_table('blog'));
4101                                 break;
4102                         case 'template':
4103                                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4104                                 {
4105                                         $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4106                                 }
4107                                 else
4108                                 {
4109                                         $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4110                                 }
4111                                 $show  = array(
4112                                         'content' => 'shortnames'
4113                                 );
4114                                 $query = sprintf($query, sql_table('template_desc'));
4115                                 break;
4116                 }
4117                 
4118                 $skin_list = showlist($query, 'table', $show, $template_name);
4119                 $this->parser->parse($skin_list);
4120                 return;
4121         }
4122         
4123         /**
4124          * AdminActions::parse_skinielist()
4125          * Parse skinvar skinielist
4126          *
4127          * @param       string  $type                   type of skin
4128          * @param       string  $template_name  name of template to use
4129          * @return      void
4130          */
4131         public function parse_skinielist($type, $template_name = '')
4132         {
4133                 global $manager;
4134                 
4135                 $templates = array();
4136                 if ( $template_name )
4137                 {
4138                         $templates =& $manager->getTemplate($template_name);
4139                 }
4140                 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4141                 {
4142                         $template = "<tr>\n"
4143                                   . "<td>"
4144                                   . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4145                                   . "<label for=\"<%expid%>\"><%expname%></label>\n"
4146                                   . "</td>\n"
4147                                   . "<td><%expdesc%></td>\n"
4148                                   . "</tr>\n";
4149                 }
4150                 else
4151                 {
4152                         $template = $templates['SKINIE_EXPORT_LIST'];
4153                 }
4154                 
4155                 switch ( $type )
4156                 {
4157                         case 'skin':
4158                                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4159                                 {
4160                                         $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4161                                 }
4162                                 else
4163                                 {
4164                                         $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4165                                 }
4166                                 foreach ( $res as $row )
4167                                 {
4168                                         $data = array(
4169                                                 'typeid'        => 'skin[' . $row['sdnumber'] . ']',
4170                                                 'expid'         => 'skinexp' . $row['sdnumber'],
4171                                                 'expname'       => Entity::hsc($row['sdname']),
4172                                                 'expdesc'       => Entity::hsc($row['sddesc'])
4173                                         );
4174                                         echo Template::fill($template, $data);
4175                                 }
4176                                 break;
4177                         case 'template':
4178                                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4179                                 {
4180                                         $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4181                                 }
4182                                 else
4183                                 {
4184                                         $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4185                                 }
4186                                 foreach ( $res as $row )
4187                                 {
4188                                         $data = array(
4189                                                 'typeid'        => 'template[' . $row['tdnumber'] . ']',
4190                                                 'expid'         => 'templateexp' . $row['tdnumber'],
4191                                                 'expname'       => Entity::hsc($row['tdname']),
4192                                                 'expdesc'       => Entity::hsc($row['tddesc'])
4193                                         );
4194                                         echo Template::fill($template, $data);
4195                                 }
4196                                 break;
4197                 }
4198                 return;
4199         }
4200         
4201         /**
4202          * AdminActions::parse_skinoverview()
4203          * Parse skinvar skinoverview
4204          *
4205          * @param       string  $template_name  name of template to use
4206          * @return      void
4207          */
4208         public function parse_skinoverview($template_name = '')
4209         {
4210                 global $CONF;
4211                 
4212                 $template = array();
4213                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4214                 {
4215                         $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4216                         $template['handler'] = 'Actions';
4217                         $template['editaction'] = 'skinedit';
4218                         $template['cloneaction'] = 'skinclone';
4219                         $template['deleteaction'] = 'skindelete';
4220                         $template['edittypeaction'] = 'skinedittype';
4221                         $template['default'] = $CONF['BaseSkin'];
4222                 }
4223                 else
4224                 {
4225                         $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4226                         $template['handler'] = 'AdminActions';
4227                         $template['editaction'] = 'adminskinedit';
4228                         $template['cloneaction'] = 'adminskinclone';
4229                         $template['deleteaction'] = 'adminskindelete';
4230                         $template['edittypeaction'] = 'adminskinedittype';
4231                         $template['default'] = $CONF['AdminSkin'];
4232                 }
4233                 $query = sprintf($query, sql_table('skin_desc'));
4234                 
4235                 $template['tabindex'] = 10;
4236                 $template['content'] = 'skinlist';
4237                 
4238                 $skin_list = showlist($query, 'table', $template, $template_name);
4239                 $this->parser->parse($skin_list);
4240                 
4241                 return;
4242         }
4243         
4244         /**
4245          * AdminActions::parse_skintypehelp()
4246          * Check editing skintypehelp
4247          *
4248          * @param       void
4249          * @return      void
4250          */
4251         public function parse_skintypehelp()
4252         {
4253                 $surrent_skin_type = strtolower(trim(requestVar('type')));
4254                 $page_action  = strtolower(trim(requestVar('action')));
4255                 if ( in_array($page_action, Admin::$adminskin_actions) )
4256                 {
4257                         $normal_types = array_keys(self::$normal_skin_types);
4258                 }
4259                 else
4260                 {
4261                         $normal_types = array_keys(Actions::getNormalSkinTypes());
4262                 }
4263                 
4264                 if ( in_array($surrent_skin_type, $normal_types) )
4265                 {
4266                         help('skinpart' . $surrent_skin_type);
4267                 }
4268                 else
4269                 {
4270                         help('skinpartspecial');
4271                 }
4272                 return;
4273         }
4274         
4275         /**
4276          * AdminActions::parse_specialskinlist()
4277          * Parse skinvar specialskinlist
4278          *
4279          * @param       string  $template_name  name of template to use
4280          * @return      void
4281          */
4282         public function parse_specialskinlist($template_name = '')
4283         {
4284                 global $CONF, $manager;
4285                 
4286                 $template = array();
4287                 
4288                 $skinid = intRequestVar('skinid');
4289                 
4290                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4291                 {
4292                         $skin =& $manager->getSkin($skinid);
4293                         $template['editaction'] = 'skinedittype';
4294                         $template['removeaction'] = 'skinremovetype';
4295                 }
4296                 else
4297                 {
4298                         $skin =& $manager->getSkin($skinid, 'AdminActions');
4299                         $template['editaction'] = 'adminskinedittype';
4300                         $template['removeaction'] = 'adminskinremovetype';
4301                 }
4302                 $normal_types = $skin->getNormalTypes();
4303                 $available_types = $skin->getAvailableTypes();
4304                 
4305                 $special_skintypes = array();
4306                 foreach( $available_types as $skintype => $skinname )
4307                 {
4308                         if ( !array_key_exists($skintype, $normal_types) )
4309                         {
4310                                 $special_skintypes[] = array(
4311                                         'skintype'              => $skintype,
4312                                         'skintypename'  => $skinname
4313                                 );
4314                         }
4315                 }
4316                 
4317                 if ( sizeof($special_skintypes) > 0 )
4318                 {
4319                         $template['tabindex'] = 75;
4320                         $template['skinid'] = $skin->getID();
4321                         $template['skinname'] = $skin->getName();
4322                         $skin_list = showlist($special_skintypes, 'list_specialskinlist', $template, $template_name);
4323                         $this->parser->parse($skin_list);
4324                 }
4325                 else
4326                 {
4327                         /* TODO: nothing to be shown */
4328                 }
4329         
4330                 return;
4331         }
4332         
4333         /**
4334          * AdminActions::parse_sprinttext()
4335          * Parse sprinttext
4336          *
4337          * @param       string  $which
4338          * @param       string  $val
4339          * @return      void
4340          */
4341         public function parse_sprinttext($which, $val)
4342         {
4343                 if ( !defined($which) )
4344                 {
4345                         $base = $which;
4346                 }
4347                 else
4348                 {
4349                         $base = constant($which);
4350                 }
4351                 
4352                 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4353                 {
4354                         if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4355                         {
4356                                 $met = 'parse_' . $matchies[0];
4357                         }
4358                         else
4359                         {
4360                                 $arg = trim($args[0], '()');
4361                                 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4362                         }
4363                         
4364                         if ( method_exists($this, $met) )
4365                         {
4366                                 $value = call_user_func(array($this, $met), $arg);
4367                         }
4368                 }
4369                 
4370                 if ( !isset($value) || empty($value) )
4371                 {
4372                         $value = $val;
4373                 }
4374                 echo sprintf($base, $value);
4375                 return;
4376         }
4377         
4378         /**
4379          * AdminActions::parse_systemsettings()
4380          * Parse skinvar systemsettings
4381          *
4382          * @param       string  $type                   type of settings for system
4383          * @param       string  $template_name  name of template to use
4384          * @return      void
4385          */
4386         public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4387         {
4388                 global $manager, $member, $CONF, $nucleus;
4389                 
4390                 $member->isAdmin() or Admin::disallow();
4391                 
4392                 $enable  = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4393                 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4394                 
4395                 switch ( $type )
4396                 {
4397                         case 'phpversion':
4398                                 echo phpversion();
4399                                 break;
4400                         case 'sqlserverinfo':
4401                                 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4402                                 break;
4403                         case 'sqlclientinfo':
4404                                 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4405                                 break;
4406                         case 'magicquotesgpc':
4407                                 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4408                                 break;
4409                         case 'magicquotesruntime':
4410                                 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4411                                 break;
4412                         case 'registerglobals':
4413                                 echo ini_get('register_globals') ? 'On' : 'Off';
4414                                 break;
4415                         case 'gdinfo':
4416                                 $templates = array();
4417                                 if ( $template_name )
4418                                 {
4419                                         $templates =& $manager->getTemplate($template_name);
4420                                 }
4421                                 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4422                                 {
4423                                         $template = "<tr>\n"
4424                                         . "<td><%key%></td>\n"
4425                                         . "<td><%value%></td>\n"
4426                                         . "</tr>\n";
4427                                 }
4428                                 else
4429                                 {
4430                                         $template = $templates['SYSTEMINFO_GDSETTINGS'];
4431                                 }
4432                                 
4433                                 $gdinfo = gd_info();
4434                                 
4435                                 foreach ( $gdinfo as $key => $value )
4436                                 {
4437                                         if ( is_bool($value) )
4438                                         {
4439                                                 $value = $value ? $enable : $disable;
4440                                         }
4441                                         else
4442                                         {
4443                                                 $value = Entity::hsc($value);
4444                                         }
4445                                         $data = array(
4446                                                 'key'   => $key,
4447                                                 'value' => $value,
4448                                         );
4449                                         echo Template::fill($template, $data);
4450                                 }
4451                                 break;
4452                         case 'modrewrite':
4453                                 if ( function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) )
4454                                 {
4455                                         echo $enable;
4456                                 }
4457                                 else
4458                                 {
4459                                         ob_start();
4460                                         phpinfo(INFO_MODULES);
4461                                         $im = ob_get_contents();
4462                                         ob_end_clean();
4463                                         if ( i18n::strpos($im, 'mod_rewrite') !== FALSE )
4464                                         {
4465                                                 echo $enable;
4466                                         }
4467                                         else
4468                                         {
4469                                                 echo $disable;
4470                                         }
4471                                 }
4472                                 break;
4473                         case 'nucleusversion':
4474                                 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4475                                 break;
4476                         case 'nucleuspatchlevel':
4477                                 echo getNucleusPatchLevel();
4478                                 break;
4479                         case 'confself':
4480                                 echo $CONF['Self'];
4481                                 break;
4482                         case 'confitemurl':
4483                                 echo $CONF['ItemURL'];
4484                                 break;
4485                         case 'alertonheaderssent':
4486                                 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4487                                 break;
4488                         case 'nucleuscodename':
4489                                 if ( $nucleus['codename'] != '' )
4490                                 {
4491                                         echo ' &quot;' . $nucleus['codename'] . '&quot;';
4492                                 }
4493                                 break;
4494                         case 'versioncheckurl':
4495                                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4496                                 break;
4497                 }
4498                 return;
4499         }
4500         
4501         /**
4502          * AdminActions::parse_templateoverview()
4503          * Parse skinvar templateoverview
4504          *
4505          * @param       string  $template_name  name of template to use
4506          * @return      void
4507          */
4508         public function parse_templateoverview($template_name = '')
4509         {
4510                 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4511                 {
4512                         $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4513                         $template['deleteaction'] = 'templatedelete';
4514                         $template['editaction'] = 'templateedit';
4515                         $template['cloneaction'] = 'templateclone';
4516                 }
4517                 else
4518                 {
4519                         $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4520                         $template['deleteaction'] = 'admintemplatedelete';
4521                         $template['editaction'] = 'admintemplateedit';
4522                         $template['cloneaction'] = 'admintemplateclone';
4523                 }
4524                 $query = sprintf($query, sql_table('template_desc'));
4525                 
4526                 $template['tabindex'] = 10;
4527                 $template['content'] = 'templatelist';
4528                 
4529                 $template_list = showlist($query, 'table', $template, $template_name);
4530                 $this->parser->parse($template_list);
4531                 
4532                 return;
4533         }
4534         
4535         /**
4536          * AdminActions::parse_ticket()
4537          * Parse ticket
4538          *
4539          * @param       void
4540          * @return      void
4541          */
4542         public function parse_ticket()
4543         {
4544                 global $manager;
4545                 $manager->addTicketHidden();
4546                 return;
4547         }
4548         
4549         /**
4550          * AdminActions::parse_versioncheckurl()
4551          * Parse skinvar versioncheckurl
4552          *
4553          * @param       void
4554          * @return      void
4555          */
4556         public function parse_versioncheckurl()
4557         {
4558                 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4559                 return;
4560         }
4561         
4562         /**
4563          * AdminActions::parse_yrbloglist()
4564          * Parse skinvar yrbloglist
4565          *
4566          * @param       string  $template_name  name of template to use
4567          * @return      void
4568          */
4569         public function parse_yrbloglist($template_name = '')
4570         {
4571                 global $member;
4572                 $showAll = requestVar('showall');
4573                 
4574                 if ( $member->isAdmin() && ($showAll == 'yes') )
4575                 {
4576                         // Super-Admins have access to all blogs! (no add item support though)
4577                         $query =  "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4578                         . " FROM %s"
4579                         . " ORDER BY bnumber;";
4580                         $query = sprintf($query, sql_table('blog'));
4581                 }
4582                 else
4583                 {
4584                         $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4585                         . " FROM %s,%s"
4586                         . " WHERE tblog=bnumber and tmember=%d"
4587                         . " ORDER BY bnumber;";
4588                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4589                 }
4590                 
4591                 $resource = DB::getResult($query);
4592                 if ( ($showAll != 'yes') && $member->isAdmin() )
4593                 {
4594                         $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4595                         $total = DB::getValue($query);
4596                                 
4597                         if ( $total > $resource->rowCount() )
4598                         {
4599                                 echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4600                         }
4601                 }
4602                 
4603                 if ( $resource->rowCount() > 0 )
4604                 {
4605                         $template['content']    = 'bloglist';
4606                         $template['superadmin'] = $member->isAdmin();
4607                                 
4608                         $list_resource_table = showlist($resource, 'table', $template, $template_name);
4609                         $this->parser->parse($list_resource_table);
4610                         $resource->closeCursor();
4611                                 
4612                         echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4613                                 
4614                         $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4615                         . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4616                         $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4617                                 
4618                         $resource = DB::getResult($query);
4619                         if ( $resource->rowCount() > 0 )
4620                         {
4621                                 $template['content'] = 'draftlist';
4622                                 $draft_list = showlist($resource, 'table', $template, $template_name);
4623                                 $this->parser->parse($draft_list);
4624                         }
4625                         else
4626                         {
4627                                 echo _OVERVIEW_NODRAFTS;
4628                         }
4629                 }
4630                 else
4631                 {
4632                         echo _OVERVIEW_NOBLOGS;
4633                 }
4634                 $resource->closeCursor();
4635                 
4636                 return;
4637         }
4638         
4639         /**
4640          * AdminActions::checkCondition()
4641          * Checks conditions for if statements
4642          *
4643          * @param       string  $field type of <%if%>
4644          * @param       string  $name property of field
4645          * @param       string  $value value of property
4646          * @return      boolean condition
4647          */
4648         protected function checkCondition($field, $name='', $value = '')
4649         {
4650                 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4651                 
4652                 $condition = 0;
4653                 switch ( $field )
4654                 {
4655                         case 'category':
4656                                 if ( !$blog )
4657                                 {
4658                                         if ( $blogid )
4659                                         {
4660                                                 $blog =& $manager->getBlog($blogid);
4661                                         }
4662                                         elseif ( $catid )
4663                                         {
4664                                                 $blogid = getBlogIDFromCatID($catid);
4665                                                 $blog =& $manager->getBlog($blogid);
4666                                         }
4667                                         elseif ( intRequestVar('catid') )
4668                                         {
4669                                                 $catid = intRequestVar('catid');
4670                                                 $blogid = getBlogIDFromCatID($catid);
4671                                                 $blog =& $manager->getBlog($blogid);
4672                                         }
4673                                         else
4674                                         {
4675                                                 return;
4676                                         }
4677                                 }
4678                                 $condition = ($blog && $this->ifCategory($name, $value));
4679                                 break;
4680                         case 'loggedin':
4681                                 $condition = $member->isLoggedIn();
4682                                 break;
4683                         case 'onteam':
4684                                 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4685                                 break;
4686                         case 'admin':
4687                                 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4688                                 break;
4689                         case 'superadmin':
4690                                 $condition = $member->isLoggedIn() && $member->isAdmin();
4691                                 break;
4692                         case 'allowloginedit':
4693                                 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4694                                 break;
4695                         case 'nextitem':
4696                                 $condition = ($itemidnext != '');
4697                                 break;
4698                         case 'previtem':
4699                                 $condition = ($itemidprev != '');
4700                                 break;
4701                         case 'archiveprevexists':
4702                                 $condition = ($archiveprevexists == true);
4703                                 break;
4704                         case 'archivenextexists':
4705                                 $condition = ($archivenextexists == true);
4706                                 break;
4707                         case 'skintype':
4708                                 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4709                                 break;
4710                         case 'hasplugin':
4711                                 $condition = $this->ifHasPlugin($name, $value);
4712                                 break;
4713                         case 'adminaction':
4714                                 $condition = (Admin::$action == $name);
4715                                 break;
4716                         case 'adminoldaction':
4717                                 $condition = (Admin::$action == $name);
4718                                 break;
4719                         case 'addresschange':
4720                                 $condition = ($this->ifAddresscange());
4721                                 break;
4722                         case 'bechangepass':
4723                                 $condition = ($this->beChangePassword());
4724                                 break;
4725                         case 'skincandidates':
4726                                 $condition = ($this->ifSkincandidates());
4727                                 break;
4728                         case 'nameclashes':
4729                                 $condition = Admin::$contents['nameclashes'];
4730                                 break;
4731                         case 'existsnewplugin':
4732                                 $condition = ($this->existsNewPlugin());
4733                                 break;
4734                         case 'autosave':
4735                                 if ( $value == '' )
4736                                 {
4737                                         $value = 1;
4738                                 }
4739                                 $condition = (boolean) ($member->getAutosave() == $value);
4740                                 break;
4741                         case 'blogsetting':
4742                                 if ( $value == '' )
4743                                 {
4744                                         $value = 1;
4745                                 }
4746                                 $condition = (Admin::$blog->getSetting($name) == $value);
4747                                 break;
4748                         case 'itemproperty':
4749                                 if ( $value == '' )
4750                                 {
4751                                         $value = 1;
4752                                 }
4753                                 if ( array_key_exists($name, Admin::$contents) )
4754                                 {
4755                                         $condition = (boolean) (Admin::$contents[$name] == $value);
4756                                 }
4757                                 break;
4758                         default:
4759                                 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4760                                 break;
4761                 }
4762                 return $condition;
4763         }
4764         
4765         /**
4766          * AdminActions::_ifHasPlugin()
4767          *      hasplugin,PlugName
4768          *         -> checks if plugin exists
4769          *      hasplugin,PlugName,OptionName
4770          *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
4771          *      hasplugin,PlugName,OptionName=value
4772          *         -> checks if the option OptionName from plugin PlugName is set to value
4773          *
4774          * @param       string  $name   name of plugin
4775          * @param       string  $value
4776          * @return
4777          */
4778         private function ifHasPlugin($name, $value)
4779         {
4780                 global $manager;
4781                 $condition = false;
4782                 // (pluginInstalled method won't write a message in the actionlog on failure)
4783                 if ( $manager->pluginInstalled("NP_{$name}") )
4784                 {
4785                         $plugin =& $manager->getPlugin("NP_{$name}");
4786                         if ( $plugin != NULL )
4787                         {
4788                                 if ( $value == "" )
4789                                 {
4790                                         $condition = true;
4791                                 }
4792                                 else
4793                                 {
4794                                         list($name2, $value2) = preg_split('#=#', $value, 2);
4795                                         if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4796                                         {
4797                                                 $condition = true;
4798                                         }
4799                                         else if ( $plugin->getOption($name2) == $value2 )
4800                                         {
4801                                                 $condition = true;
4802                                         }
4803                                 }
4804                         }
4805                 }
4806                 return $condition;
4807         }
4808         
4809         /**
4810          * AdminActions::beChangePassword()
4811          *
4812          * @param       void
4813          * @return      void
4814          */
4815         private function beChangePassword()
4816         {
4817                 return intRequestVar('bNeedsPasswordChange');
4818         }
4819         
4820         /**
4821          * AdminActions::ifSkincandidates()
4822          * Checks if a plugin exists and call its doIf function
4823          *
4824          * @param       void
4825          * @return      void
4826          * @return      boolean
4827          */
4828         private function ifSkincandidates()
4829         {
4830                 global $DIR_SKINS;
4831                 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4832                 return (count($candidates) > 0);
4833         }
4834         
4835         /**
4836          * AdminActions::ifPlugin()
4837          * Checks if a plugin exists and call its doIf function
4838          *
4839          * @param       string  $name   name of plugin
4840          * @param       string  $key
4841          * @param       string  $value
4842          * @return      callback
4843          */
4844         private function ifPlugin($name, $key = '', $value = '')
4845         {
4846                 global $manager;
4847                 
4848                 $plugin =& $manager->getPlugin("NP_{$name}");
4849                 if ( !$plugin )
4850                 {
4851                         return;
4852                 }
4853                 
4854                 $params = func_get_args();
4855                 array_shift($params);
4856                 
4857                 return call_user_func_array(array($plugin, 'doIf'), $params);
4858         }
4859         
4860         /**
4861          * AdminActions::ifCategory()
4862          *  Different checks for a category
4863          *
4864          * @param       string  $key    key for information of category
4865          * @param       string  $value  value for information of category
4866          * @return      boolean
4867          */
4868         private function ifCategory($key = '', $value='')
4869         {
4870                 global $blog, $catid;
4871                 
4872                 // when no parameter is defined, just check if a category is selected
4873                 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4874                 {
4875                         return $blog->isValidCategory($catid);
4876                 }
4877                 
4878                 // check category name
4879                 if ( $key == 'catname' )
4880                 {
4881                         $value = $blog->getCategoryIdFromName($value);
4882                         if ($value == $catid)
4883                         {
4884                                 return $blog->isValidCategory($catid);
4885                         }
4886                 }
4887                 
4888                 // check category id
4889                 if (($key == 'catid') && ($value == $catid))
4890                 {
4891                         return $blog->isValidCategory($catid);
4892                 }
4893                 
4894                 return FALSE;
4895         }
4896         
4897         /**
4898          * AdminActions::ifOnTeam()
4899          * Checks if a member is on the team of a blog and return his rights
4900          *
4901          * @param       string  $blogName       name of weblog
4902          * @return      boolean
4903          */
4904         private function ifOnTeam($blogName = '')
4905         {
4906                 global $blog, $member, $manager;
4907                 
4908                 // when no blog found
4909                 if ( ($blogName == '') && !is_object($blog) )
4910                 {
4911                         return 0;
4912                 }
4913                 
4914                 // explicit blog selection
4915                 if ($blogName != '')
4916                 {
4917                         $blogid = getBlogIDFromName($blogName);
4918                 }
4919                 
4920                 if (($blogName == '') || !$manager->existsBlogID($blogid))
4921                 {
4922                         // use current blog
4923                         $blogid = $blog->getID();
4924                 }
4925                 return $member->teamRights($blogid);
4926         }
4927         
4928         /**
4929          * AdminActions::ifAdmin()
4930          * Checks if a member is admin of a blog
4931          *
4932          * @param       string  $blogName       name of weblog
4933          * @return      boolean
4934          */
4935         private function ifAdmin($blogName = '')
4936         {
4937                 global $blog, $member, $manager;
4938                 
4939                 // when no blog found
4940                 if (($blogName == '') && (!is_object($blog)))
4941                 {
4942                         return 0;
4943                 }
4944                 
4945                 // explicit blog selection
4946                 if ($blogName != '')
4947                 {
4948                         $blogid = getBlogIDFromName($blogName);
4949                 }
4950                 
4951                 if (($blogName == '') || !$manager->existsBlogID($blogid))
4952                 {
4953                         // use current blog
4954                         $blogid = $blog->getID();
4955                 }
4956         
4957                 return $member->isBlogAdmin($blogid);
4958         }
4959         
4960         /**
4961          * AdminActions::ifAddresscange()
4962          * Check e-Mail address is changed
4963          *
4964          * @param       void
4965          * @return      boolean
4966          */
4967         private function ifAddresscange()
4968         {
4969                 global $manager;
4970
4971                 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4972                 if ( !$key )
4973                 {
4974                         return FALSE;
4975                 }
4976                 $info = MEMBER::getActivationInfo($key);
4977                 if ( !$info )
4978                 {
4979                         return FALSE;
4980                 }
4981                 $mem =& $manager->getMember($info->vmember);
4982                 if ( !$mem )
4983                 {
4984                         return FALSE;
4985                 }
4986                 if ( $info->vtype == 'addresschange' )
4987                 {
4988                         return TRUE;
4989                 }
4990                 return FALSE;
4991         }
4992         
4993         /**
4994          * TODO: move
4995          * AdminActions::customHelp()
4996          * shows a link to custom help file
4997          *
4998          * @param       string  $id
4999          * @param       string  $tplName
5000          * @param       string  $url
5001          * @param       string  $iconURL
5002          * @param       string  $alt
5003          * @param       string  $title
5004          * @param       $onclick
5005          *
5006          */
5007         private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5008         {
5009                 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5010         }
5011         
5012         /**
5013          * TODO: move
5014          * AdminActions::customHelp()
5015          * shows a link to custom help file
5016          *
5017          * @param       string  $id
5018          * @param       string  $tplName
5019          * @param       string  $url
5020          * @param       string  $iconURL
5021          * @param       string  $alt
5022          * @param       string  $title
5023          * @param       $onclick
5024          *
5025          */
5026         static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5027         {
5028                 global $CONF, $manager;
5029                 
5030                 $templates = array();
5031                 
5032                 if ( $tplName )
5033                 {
5034                         $templates =& $manager->getTemplate($tplName);
5035                 }
5036                 
5037                 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5038                 {
5039                         $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5040                 }
5041                 else
5042                 {
5043                         $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5044                 }
5045                 
5046                 if ( empty($url) )
5047                 {
5048                         $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5049                 }
5050                 
5051                 if ( empty($onclick) )
5052                 {
5053                         $onclick = 'onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);"';
5054                 }
5055                 elseif ( preg_match('#^onclick#', $onclick) )
5056                 {
5057                         $onclick = $onclick;
5058                 }
5059                 else
5060                 {
5061                         $onclick = 'onclick="' . $onclick . '"';
5062                 }
5063                 
5064                 $data = array(
5065                         'helpurl'               => $url,
5066                         'helptarget'    => $id,
5067                         'onclick'               => $onclick,
5068                         'title'                 => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5069                 );
5070                 return Template::fill($template, $data);
5071         }
5072         
5073         /**
5074          * TODO: move
5075          * AdminActions::customHelpHtml()
5076          */
5077         private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5078         {
5079                 global $CONF, $manager;
5080                 
5081                 $templates = array();
5082                 
5083                 if ( $tplName )
5084                 {
5085                         $templates =& $manager->getTemplate($tplName);
5086                 }
5087                 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5088                 {
5089                         $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5090                 }
5091                 else
5092                 {
5093                         $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5094                 }
5095                 
5096                 if ( empty($iconURL) )
5097                 {
5098                         $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5099                 }
5100                 
5101                 if ( function_exists('getimagesize') )
5102                 {
5103                         $size   = getimagesize($iconURL);
5104                         $width  = 'width="'  . $size[0] . '" ';
5105                         $height = 'height="' . $size[1] . '" ';
5106                 }
5107                 
5108                 $data = array(
5109                         'iconurl'       => $iconURL,
5110                         'width'         => $width,
5111                         'height'        => $height,
5112                         'alt'           => (isset($alt) && !empty($alt))         ? $alt   : _HELP_TT,
5113                         'title'         => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5114                 );
5115                 
5116                 $icon = Template::fill($template, $data);
5117                 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5118                 
5119                 return $help . $icon;
5120         }
5121         
5122         /**
5123          * AdminActions::existsNewPlugin()
5124          * Check exists new plugin
5125          *
5126          * @param       void
5127          * @return      boolean exists or not
5128          */
5129         private function existsNewPlugin()
5130         {
5131                 global $DIR_PLUGINS;
5132                 
5133                 $query = "SELECT * FROM %s;";
5134                 $query = sprintf($query, sql_table('plugin'));
5135                 $res  = DB::getResult($query);
5136                 
5137                 $installed = array();
5138                 foreach( $res as $row )
5139                 {
5140                         $installed[] = $row['pfile'];
5141                 }
5142                 
5143                 $files = scandir($DIR_PLUGINS);
5144                 
5145                 $candidates = array();
5146                 foreach ( $files as $file )
5147                 {
5148                         if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5149                         {
5150                                 if ( !in_array($matches[1], $installed) )
5151                                 {
5152                                         $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5153                                 }
5154                         }
5155                 }
5156                 $this->newPlugCandidates = $candidates;
5157                 return (count($candidates) > 0);
5158         }
5159         
5160         /**
5161          * AdminActions::pagehead()
5162          * Output admin page head
5163          *
5164          * @param       void
5165          * @return      void
5166          */
5167         public function parse_pagehead()
5168         {
5169                 global $member, $nucleus, $CONF, $manager;
5170                 
5171                 /* HTTP 1.1 application for no caching */
5172                 header("Cache-Control: no-cache, must-revalidate");
5173                 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5174                 
5175                 $content = $this->parser->skin->getContentFromDB('pagehead');
5176                 if ( !$content )
5177                 {
5178                         $root_element = 'html';
5179                         $charset = i18n::get_current_charset();
5180                         $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5181                         $xml_version_info = '1.0';
5182                         $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
5183                         $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
5184                         $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
5185                         
5186                         $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5187                                   . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5188                                   . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5189                                   . "<head>\n"
5190                                   . "<title><%sitevar(name)%> - Admin</title>\n"
5191                                   . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5192                                   . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5193                                   . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5194                                   . "<%extrahead%>"
5195                                   . "</head>"
5196                                   . "<body>"
5197                                   . "<div id=\"adminwrapper\">"
5198                                   . "<div class=\"header\">"
5199                                   . "<h1><%sitevar(name)%></h1>"
5200                                   . "</div>"
5201                                   . "<div id=\"container\">"
5202                                   . "<div id=\"content\">"
5203                                   . "<div class=\"loginname\">"
5204                                   . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5205                                   . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5206                                   . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5207                                   . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5208                                   . "<%extrahead%>\n"
5209                                   . "</head>\n"
5210                                   . "\n"
5211                                   . "<body>\n"
5212                                   . "<div id=\"adminwrapper\">\n"
5213                                   . "<div class=\"header\">\n"
5214                                   . "<h1><%sitevar(name)%></h1>\n"
5215                                   . "</div>\n"
5216                                   . "<div id=\"container\">\n"
5217                                   . "<div id=\"content\">\n"
5218                                   . "<div class=\"loginname\">\n"
5219                                   . "<%if(loggedin)%>"
5220                                   . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5221                                   . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5222                                   . "<%else%>"
5223                                   . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5224                                   . "<%endif%>"
5225                                   . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5226                                   . "("
5227                                   . "<%if(superadmin)%>"
5228                                   . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5229                                   . "<%newestcompare%><%else%><%version%><%codename%>"
5230                                   . "<%endif%>"
5231                                   . ")"
5232                                   . "</div>";
5233                 }
5234                 
5235                 $this->parser->parse($content);
5236                 return;
5237         }
5238         
5239         /**
5240          * AdminActionss::pagefoot()
5241          * Output admin page foot include quickmenu
5242          *
5243          * @param       void
5244          * @return      void
5245          */
5246         public function parse_pagefoot()
5247         {
5248                 global $action, $member, $manager, $blogid;
5249
5250                 $data = array('action' => Admin::$action);
5251                 $manager->notify('AdminPrePageFoot', $data);
5252                 
5253                 $content = $this->parser->skin->getContentFromDB('pagefoot');
5254                 if ( !$content )
5255                 {
5256                         $content = "<%if(loggedin)%>"
5257                                  . "<%ifnot(adminaction,showlogin)%>"
5258                                  . "<h2><%text(_LOGOUT)%></h2>"
5259                                  . "<ul>"
5260                                  . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5261                                  . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5262                                  . "</ul>"
5263                                  . "<%endif%>"
5264                                  . "<%endif%>"
5265                                  . "<div class=\"foot\">"
5266                                  . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> &copy; 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5267                                  . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5268                                  . "</div>"
5269                                  . "</div>"
5270                                  . "<!-- content -->"
5271                                  . "<div id=\"quickmenu\">"
5272                                  . "<%if(loggedin)%>"
5273                                  . "<%ifnot(adminaction,showlogin)%>"
5274                                  . "<ul>"
5275                                  . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5276                                  . "</ul>"
5277                                  . "<h2><%text(_QMENU_ADD)%></h2>"
5278                                  . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5279                                  . "<div>"
5280                                  . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5281                                  . "<%qmenuaddselect(admin/default)%>"
5282                                  . "</div>"
5283                                  . "</form>"
5284                                  . "<h2><%member(yourrealname)%></h2>"
5285                                  . "<ul>"
5286                                  . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5287                                  . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5288                                  . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5289                                  . "</ul>"
5290                                  . "<%if(superadmin)%>"
5291                                  . "<h2><%text(_QMENU_MANAGE)%></h2>"
5292                                  . "<ul>"
5293                                  . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5294                                  . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5295                                  . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5296                                  . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5297                                  . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5298                                  . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5299                                  . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5300                                  . "</ul>"
5301                                  . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5302                                  . "<ul>"
5303                                  . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5304                                  . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5305                                  . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5306                                  . "</ul>"
5307                                  . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5308                                  . "<ul>"
5309                                  . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5310                                  . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5311                                  . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5312                                  . "</ul>"
5313                                  . "<%endif%>"
5314                                  . "<%quickmenu(admin/default)%>"
5315                                  . "<%endif%>"
5316                                  . "<%elseif(adminaction,activate)%>"
5317                                  . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5318                                  . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5319                                  . "<%elseif(adminaction,activatesetpwd)%>"
5320                                  . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5321                                  . "<%else%>"
5322                                  . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5323                                  . "<%endif%>"
5324                                  . "</div>"
5325                                  . "<!-- content / quickmenu container -->"
5326                                  . "<div class=\"clear\"></div>"
5327                                  . "<!-- new -->"
5328                                  . "</div>"
5329                                  . "<!-- adminwrapper -->"
5330                                  . "<!-- new -->"
5331                                  . "</div>"
5332                                  . "<!-- new -->"
5333                                  . "<p style=\"text-align:right;\"><%benchmark%></p>"
5334                                  . "</body>"
5335                                  . "</html>";
5336                 }
5337                 
5338                 $this->parser->parse($content);
5339                 return;
5340         }
5341         /**
5342          * AdminActions::selectBlog()
5343          * Inserts a HTML select element with choices for all blogs to which the user has access
5344          *      mode = 'blog' => shows blognames and values are blogids
5345          *      mode = 'category' => show category names and values are catids
5346          *
5347          * @param       string  $name
5348          * @param       string  $mode
5349          * @param       integer $selected
5350          * @param       integer $tabindex
5351          * @param       integer $showNewCat
5352          * @param       integer $iForcedBlogInclude     ID for weblog always included
5353          * @param $iForcedBlogInclude
5354          *      ID of a blog that always needs to be included, without checking if the
5355          *      member is on the blog team (-1 = none)
5356          * @return      void
5357          */
5358         private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5359         {
5360                 global $member, $CONF;
5361                 
5362                 // 0. get IDs of blogs to which member can post items (+ forced blog)
5363                 $aBlogIds = array();
5364                 if ( $iForcedBlogInclude != -1 )
5365                 {
5366                         $aBlogIds[] = intval($iForcedBlogInclude);
5367                 }
5368                 
5369                 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5370                 {
5371                         $query =  "SELECT bnumber FROM %s ORDER BY bname;";
5372                         $query = sprintf($query, sql_table('blog'));
5373                 }
5374                 else
5375                 {
5376                         $query =  "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5377                         $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5378                 }
5379                 
5380                 $rblogids = DB::getResult($query);
5381                 foreach ( $rblogids as $row )
5382                 {
5383                         if ( $row['bnumber'] != $iForcedBlogInclude )
5384                         {
5385                                 $aBlogIds[] = intval($row['bnumber']);
5386                         }
5387                 }
5388                 
5389                 if ( count($aBlogIds) == 0 )
5390                 {
5391                         return;
5392                 }
5393                 
5394                 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5395                 
5396                 // 1. select blogs (we'll create optiongroups)
5397                 // (only select those blogs that have the user on the team)
5398                 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5399                 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5400                 $blogs = DB::getResult($queryBlogs);
5401                 
5402                 if ( $mode == 'category' )
5403                 {
5404                         if ( $blogs->rowCount() > 1 )
5405                         {
5406                                 $multipleBlogs = 1;
5407                         }
5408                         foreach ( $blogs as $rBlog )
5409                         {
5410                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5411                                 {
5412                                         echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5413                                 }
5414                                 
5415                                 // show selection to create new category when allowed/wanted
5416                                 if ( $showNewCat )
5417                                 {
5418                                         // check if allowed to do so
5419                                         if ( $member->blogAdminRights($rBlog['bnumber']) )
5420                                         {
5421                                                 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5422                                         }
5423                                 }
5424                                 
5425                                 // 2. for each category in that blog
5426                                 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5427                                 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5428                                 $categories = DB::getResult($catQuery);
5429                                 foreach ( $categories as $rCat )
5430                                 {
5431                                         if ( $rCat['catid'] == $selected )
5432                                         {
5433                                                 $selectText = ' selected="selected" ';
5434                                         }
5435                                         else
5436                                         {
5437                                                 $selectText = '';
5438                                         }
5439                                         echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5440                                 }
5441                                 
5442                                 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5443                                 {
5444                                         echo '</optgroup>';
5445                                 }
5446                         }
5447                 }
5448                 else
5449                 {
5450                         foreach ( $blogs as $rBlog )
5451                         {
5452                                 echo '<option value="' . $rBlog['bnumber'] . '"';
5453                                 if ( $rBlog['bnumber'] == $selected )
5454                                 {
5455                                         echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5456                                 }
5457                                 else
5458                                 {
5459                                         echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5460                                 }
5461                         }
5462                 }
5463                 echo "</select>\n";
5464                 return;
5465         }
5466 }