OSDN Git Service

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