OSDN Git Service

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