OSDN Git Service

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