OSDN Git Service

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