OSDN Git Service

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