OSDN Git Service

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