OSDN Git Service

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