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