OSDN Git Service

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