OSDN Git Service

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