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