OSDN Git Service

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