OSDN Git Service

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