OSDN Git Service

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