OSDN Git Service

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