OSDN Git Service

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