OSDN Git Service

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