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