OSDN Git Service

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