OSDN Git Service

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