3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2012 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * @license http://nucleuscms.org/license.txt GNU General Public License
14 * @copyright Copyright (C) 2002-2012 The Nucleus Group
15 * @version $Id: AdminActions.php 1661 2012-02-12 11:55:39Z sakamocchi $
18 class AdminActions extends BaseActions
23 * AdminActions::$default_actions
24 * list of whole action names with which this class can deal
26 static private $default_actions = array(
50 * AdminActions::$normal_skin_types
51 * friendly name for wrapped page types
53 static private $normal_skin_types = array(
54 'actionlog' => _ADM_SKPRT_ACTIONLOG,
55 'activate' => _ADM_SKPRT_ACTIVATE,
56 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
57 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
58 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
59 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
60 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
61 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
62 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
63 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
64 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
65 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
66 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
67 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
68 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
69 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
70 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
71 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
72 'banlist' => _ADM_SKPRT_BANLIST,
73 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
74 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
75 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
76 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
77 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
78 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
79 'batchitem' => _ADM_SKPRT_BATCHITEM,
80 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
81 'batchmove' => _ADM_SKPRT_BATCHMOVE,
82 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
83 'batchteam' => _ADM_SKPRT_BATCHTEAM,
84 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
85 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
86 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
87 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
88 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
89 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
90 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
91 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
92 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
93 'createitem' => _ADM_SKPRT_CREATEITEM,
94 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
95 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT,
96 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS,
97 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED,
98 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
99 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
100 'forgotpassword' => _ADM_SKPRT_FORGOTPASSWORD,
101 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
102 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
103 'itemedit' => _ADM_SKPRT_ITEMEDIT,
104 'itemlist' => _ADM_SKPRT_ITEMLIST,
105 'itemmove' => _ADM_SKPRT_ITEMMOVE,
106 'manage' => _ADM_SKPRT_MANAGE,
107 'manageteam' => _ADM_SKPRT_MANAGETEAM,
108 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
109 'overview' => _ADM_SKPRT_OVERVIEW,
110 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
111 'pagehead' => _ADM_SKPRT_PAGEHEAD,
112 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
113 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
114 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
115 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
116 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
117 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
118 'skindelete' => _ADM_SKPRT_SKINDELETE,
119 'skinedit' => _ADM_SKPRT_SKINEDIT,
120 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
121 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
122 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
123 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
124 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
125 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
126 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
127 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
128 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
129 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
130 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
131 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT
135 * AdminActions::getNormalSkinTypes()
139 * @return array list of friendly names for page actions
141 static public function getNormalSkinTypes()
143 return self::$normal_skin_types;
147 * AdminActions::__construct()
148 * Constructor for a new Actions object
150 * @param string $type
153 public function __construct($type)
155 // call constructor of superclass first
156 parent::__construct();
159 if ( $type == 'admntemplateoverview' )
161 $this->skintype = 'admintemplateoverview';
165 $this->skintype = $type;
172 * AdminActions::getAvailableActions()
175 * @return array allowed actions for the page type
177 public function getAvailableActions()
179 $extra_actions = array();
181 switch ( $this->skintype )
184 $extra_actions = array(
189 $extra_actions = array(
194 case 'activatesetpwd':
195 $extra_actions = array(
196 /* nothing special */
200 $extra_actions = array(
206 case 'adminerrorpage':
207 $extra_actions = array(
208 /* nothing special */
211 case 'adminskindelete':
212 $extra_actions = array(
216 case 'adminskinedit':
217 $extra_actions = array(
223 case 'adminskinedittype':
224 $extra_actions = array(
227 'allowedskinactions',
228 'skineditallowedlist',
231 case 'adminskiniedoimport':
232 $extra_actions = array(
236 case 'adminskinieimport':
237 $extra_actions = array(
241 case 'adminskinieoverview':
242 $extra_actions = array(
243 'selectlocalskinfiles',
247 case 'adminskinoverview':
248 $extra_actions = array(
252 case 'adminskinremovetype':
253 $extra_actions = array(
257 case 'admintemplatedelete':
258 $extra_actions = array(
259 'editadmintemplateinfo',
261 case 'admintemplateedit':
262 $extra_actions = array(
266 case 'admintemplateoverview':
267 $extra_actions = array(
271 case 'backupoverview':
272 $extra_actions = array(
273 /* nothing special */
276 case 'backuprestore':
277 $extra_actions = array(
278 /* nothing special */
282 $extra_actions = array(
288 case 'banlistdelete':
289 $extra_actions = array(
294 case 'banlistdeleteconfirm':
295 $extra_actions = array(
296 'banlistdeletedlist',
301 $extra_actions = array(
307 case 'batchcategory':
308 $extra_actions = array(
314 $extra_actions = array(
320 $extra_actions = array(
326 $extra_actions = array(
332 $extra_actions = array(
338 $extra_actions = array(
347 $extra_actions = array(
356 $extra_actions = array(
362 case 'blogcommentlist':
363 $extra_actions = array(
370 $extra_actions = array(
386 $extra_actions = array(
390 case 'browseowncomments':
391 $extra_actions = array(
395 case 'browseownitems':
396 $extra_actions = array(
400 case 'categorydelete':
401 $extra_actions = array(
407 $extra_actions = array(
414 case 'commentdelete':
415 $extra_actions = array(
420 $extra_actions = array(
424 case 'createaccountinput':
425 $extra_actions = array(
431 case 'createaccountsuccess':
432 $extra_actions = array(
436 case 'createaccountdisable':
437 $extra_actions = array(
438 /* nothing special */
442 $extra_actions = array(
454 $extra_actions = array(
460 $extra_actions = array(
465 case 'editmembersettings':
466 $extra_actions = array(
469 'localeselectoptions',
471 'defadminskinselect',
472 'defbookmarkletselect',
475 case 'forgotpassword':
476 $extra_actions = array(
477 /* nothing special */
480 case 'itemcommentlist':
481 $extra_actions = array(
487 $extra_actions = array(
494 $extra_actions = array(
506 $extra_actions = array(
513 $extra_actions = array(
519 $extra_actions = array(
520 /* nothing special */
524 $extra_actions = array(
533 $extra_actions = array(
538 $extra_actions = array(
543 $extra_actions = array(
548 $extra_actions = array(
554 $extra_actions = array(
559 case 'pluginoptions':
560 $extra_actions = array(
562 'editplugoptionslist',
566 $extra_actions = array(
569 'configsettingsedit',
570 'configsettingsyesno',
573 'localeselectoptions',
576 'defadminskinselect',
577 'defbookmarkletselect',
581 $extra_actions = array(
586 $extra_actions = array(
591 $extra_actions = array(
598 $extra_actions = array(
601 'allowedskinactions',
602 'skineditallowedlist'
605 case 'skiniedoimport':
606 $extra_actions = array(
611 $extra_actions = array(
615 case 'skinieoverview':
616 $extra_actions = array(
617 'selectlocalskinfiles',
622 $extra_actions = array(
626 case 'skinremovetype':
627 $extra_actions = array(
631 case 'systemoverview':
632 $extra_actions = array(
637 $extra_actions = array(
643 case 'templatedelete':
644 $extra_actions = array(
649 $extra_actions = array(
653 case 'templateoverview':
654 $extra_actions = array(
658 case 'usermanagement':
659 $extra_actions = array(
665 $extra_actions = array(
674 'selectlocalskinfiles',
682 $defined_actions = array_merge(self::$default_actions, $extra_actions);
684 return array_merge($defined_actions, parent::getAvailableActions());
688 * AdminActions::parse_actionloglist()
689 * Parse skinvar actionloglist
691 * @param string $template_name name of template to use
694 public function parse_actionloglist($template_name = '')
696 $query = "SELECT * FROM %s ORDER BY timestamp DESC;";
697 $query = sprintf($query, sql_table('actionlog'));
699 $resource = DB::getResult($query);
700 if ( $resource->rowCount() > 0 )
702 $template['content'] = 'actionlist';
703 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
707 /* TODO: nothing to be shown */
713 * AdminActions::parse_activationmessage()
714 * Parse skinvar activationmessage
716 * @param string $type type of message
717 * @param string $template_name name of template to use
720 public function parse_activationmessage($type, $template_name = '')
722 global $CONF, $manager;
726 if ( !empty($template_name))
728 $template =& $manager->getTemplate($template_name);
731 $key = postVar('ackey');
734 Admin::error(_ERROR_ACTIVATE);
737 $info = MEMBER::getActivationInfo($key);
740 Admin::error(_ERROR_ACTIVATE);
743 $mem =& $manager->getMember($info->vmember);
746 Admin::error(_ERROR_ACTIVATE);
748 switch ( $info->vtype )
751 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
753 $title = $template['ACTIVATE_FORGOT_TITLE'];
757 $title = _ACTIVATE_FORGOT_TITLE;
759 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
761 $text = $template['ACTIVATE_FORGOT_TEXT'];
765 $text = _ACTIVATE_FORGOT_TEXT;
769 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
771 $title = $template['ACTIVATE_REGISTER_TITLE'];
775 $title = _ACTIVATE_REGISTER_TITLE;
777 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
779 $text = $template['ACTIVATE_REGISTER_TEXT'];
783 $text = _ACTIVATE_REGISTER_TEXT;
786 case 'addresschange':
787 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
789 $title = $template['ACTIVATE_CHANGE_TITLE'];
793 $title = _ACTIVATE_CHANGE_TITLE;
795 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
797 $text = $template['ACTIVATE_CHANGE_TEXT'];
801 $text = _ACTIVATE_CHANGE_TEXT;
806 'memberName' => Entity::hsc($mem->getDisplayName()),
807 'realName' => Entity::hsc($mem->getRealName()),
812 echo Template::fill($title, $aVars);
815 echo Template::fill($text, $aVars);
818 echo Entity::hsc($key);
825 * AdminActions::parse_addtickettourl()
826 * Parse skinvar addtickettourl
828 * @param string $url URI for ticket
831 public function parse_addtickettourl($url)
834 $url = $manager->addTicketToUrl($url);
835 echo Entity::hsc($url);
840 * AdminActions::parse_adminbanlist()
841 * Parse skinvar adminbanlist
843 * @param string $template_name name of template to use
846 public function parse_adminbanlist($template_name = '')
848 $blogid = intRequestVar('blogid');
850 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
851 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
853 $resource = DB::getResult($query);
854 if ( $resource->rowCount() > 0 )
856 $template['content'] = 'banlist';
857 $this->parser-parse(showlist($resource, 'table', $template, $template_name));
867 * AdminActions::parse_adminbatchaction()
868 * Parse skinvar adminbatchaction
873 public function parse_adminbatchaction()
875 echo Entity::hsc(requestVar('batchaction'));
880 * AdminActions::parse_adminbatchlist()
881 * Parse skinvar adminbatchlist
883 * @param string $template_name name of template to use
886 public function parse_adminbatchlist($template_name = '')
889 $templates = array();
891 if ( !empty($template_name) )
893 $templates =& $manager->getTemplate($template_name);
896 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
898 $template = '<li><%text(_BATCH_EXECUTING)%> '
899 . '<b><%adminbatchaction%></b> '
900 . '<%batchlisttype%> '
901 . '<b><%batchid%></b>... '
902 . '<b><%batchlistmsg%></b>'
907 $template = $templates['ADMIN_BATCHLIST'];
910 $selected = requestIntArray('batch');
911 $action = requestVar('batchaction');
913 switch ( $this->skintype )
916 $batchlisttype = _BATCH_ONITEM;
917 $deleteaction = 'deleteOneItem';
918 $moveaction = 'moveOneItem';
919 $destid = intRequestVar('destcatid');
922 $batchlisttype = _BATCH_ONCOMMENT;
923 $deleteaction = 'deleteOneComment';
926 $batchlisttype = _BATCH_ONMEMBER;
927 $deleteaction = 'deleteOneMember';
928 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
929 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
930 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
931 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
934 $blogid = intRequestVar('blogid');
935 $batchlisttype = _BATCH_ONTEAM;
936 $deleteaction = 'deleteOneTeamMember';
937 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
938 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
939 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
940 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
942 case 'batchcategory':
943 $batchlisttype = _BATCH_ONCATEGORY;
944 $deleteaction = 'deleteOneCategory';
945 $moveaction = 'moveOneCategory';
946 $destid = intRequestVar('destblogid');
950 // walk over all selectedids and perform action
951 foreach ( $selected as $selectedid )
954 $selectedid = intval($selectedid);
958 if ( $this->skintype != 'batchteam' )
960 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
964 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
968 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
972 DB::execute("UPDATE {$setadminsql} {$selectedid};");
976 // there should always remain at least one super-admin
977 $r = DB::getResult($unsetchksql);
978 if ( $r->rowCount() < 2 )
980 $error = $unseterrmsg;
984 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
988 $error = _BATCH_UNKNOWN . Entity::hsc($action);
992 'batchid' => $selectedid,
993 'batchlisttype' => Entity::hsc($batchlisttype),
994 'adminbatchaction' => Entity::hsc($action),
995 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
998 $this->parser->parse(Template::fill($template, $data));
1005 * AdminActions::parse_adminbloglink()
1006 * Parse skinvar adminbloglink
1008 * @param string $template_name name of template to use
1011 public function parse_adminbloglink($template_name = '')
1014 $blogid = intRequestVar('blogid');
1015 $blog =& $manager->getBlog($blogid);
1016 $templates = array();
1018 if ( !empty($template_name) )
1020 $templates =& $manager->getTemplate($template_name);
1023 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1025 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1029 $template = $templates['ADMIN_BLOGLINK'];
1033 'url' => Entity::hsc($blog->getURL()),
1034 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1035 'blogname' => Entity::hsc($blog->getName())
1038 echo Template::fill($template, $data);
1043 * AdminActions::parse_adminerrormesg()
1044 * Parse skinvar adminerrormesg
1049 public function parse_adminerrormesg()
1054 if ( requestVar('errormessage') )
1056 $message = requestVar('errormessage');
1058 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1060 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1062 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1064 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1066 echo Entity::hsc($message);
1071 * AdminActions::parse_allowedskinactions()
1072 * Parse skinvar allowedskinactions
1077 public function parse_allowedskinactions()
1081 $type = strtolower(trim(requestVar('type')));
1082 $skinid = intRequestVar('skinid');
1084 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1086 $skin =& $manager->getSkin($skinid);
1091 $skin =& $manager->getSkin($skinid, 'AdminActions');
1092 $tag = 'adminskinvar';
1095 $actions = $skin->getAllowedActionsForType($type);
1098 while ( $current = array_shift($actions) )
1100 echo helplink("{$tag}-{$current}") . "$current</a>\n";
1102 if ( count($actions) != 0 )
1111 * AdminActions::parse_banlistdeletedlist()
1112 * Parse skinvar banlistdeletedlist
1114 * @param string $template_name name of template to use
1117 public function parse_banlistdeletedlist($template_name = '')
1121 $templates = array();
1122 if ( $template_name )
1124 $templates =& $manager->getTemplate($template_name);
1127 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1129 $template = "<li><%blogname%></li>\n";
1133 $template = $templates['BANLIST_DELETED_LIST'];
1136 $deleted = requestArray('delblogs');
1137 foreach ( $deleted as $delblog )
1139 $blog =& $manager->getBlog($delblog);
1141 'blogname' => Entity::hsc($blog->getName())
1143 echo Template::fill($template, $data);
1150 * AdminActions::parse_batchdeletelist()
1151 * Parse skinvar batchdeletelist
1156 public function parse_batchdeletelist()
1158 $selected = requestIntArray('batch');
1161 foreach ( $selected as $select )
1163 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1165 // add hidden vars for team & comment
1166 if ( requestVar('action') == 'batchteam' )
1168 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1170 if ( requestVar('action') == 'batchcomment' )
1172 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1178 * AdminActions::parse_defadminskinselect()
1179 * Parse skinvar defadminskinselect
1181 * @param string $template_name name of template to use
1184 public function parse_defadminskinselect($template_name)
1186 global $CONF, $action, $manager;
1188 if ( $action == 'editmembersettings' )
1191 $default = $member->adminskin;
1193 elseif ( $action == 'memberedit' )
1195 $mem = $manager->getMember(intRequestVar('memberid'));
1196 $default = $mem->adminskin;
1200 $default = $CONF['AdminSkin'];
1203 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1204 $query = sprintf($query, sql_table('skin_desc'));
1206 'name' => 'adminskin',
1207 'tabindex' => 10080,
1208 'selected' => $default
1211 if ( $this->skintype != 'settingsedit' )
1213 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1216 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1221 * AdminActions::parse_defbookmarkletselect()
1222 * Parse skinvar defbookmarkletselect
1224 * @param string $template_name name of template to use
1227 public function parse_defbookmarkletselect($template_name)
1229 global $CONF, $action, $manager;
1231 if ( $action == 'editmembersettings' )
1234 $default = $member->bookmarklet;
1236 elseif ( $action == 'memberedit' )
1238 $mem = $manager->getMember(intRequestVar('memberid'));
1239 $default = $mem->bookmarklet;
1243 $default = $CONF['BookmarkletSkin'];
1246 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1247 $query = sprintf($query, sql_table('skin_desc'));
1250 'name' => 'bookmarklet',
1251 'tabindex' => 10085,
1252 'selected' => $default
1255 if ( $this->skintype != 'settingsedit' )
1257 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1260 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1265 * AdminActions::parse_batchdeletetype()
1266 * Parse skinvar batchdeletetype
1271 public function parse_batchdeletetype()
1273 echo Entity::hsc(requestVar('action'));
1278 * AdminActions::parse_batchmovebtn()
1279 * Parse skinvar batchmovebtn
1284 public function parse_batchmovebtn()
1286 $actionType = requestVar('action');
1287 switch ( $actionType )
1292 case 'batchcategory':
1300 * AdminActions::parse_batchmovelist()
1301 * Parse skinvar batchmovelist
1306 public function parse_batchmovelist()
1308 $selected = requestIntArray('batch');
1310 foreach ( $selected as $select )
1312 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1319 * AdminActions::parse_batchmovetitle()
1320 * Parse skinvar batchmovetitle
1325 public function parse_batchmovetitle()
1327 $actionType = requestVar('action');
1328 switch ( $actionType )
1333 case 'batchcategory':
1334 echo _MOVECAT_TITLE;
1341 * AdminActions::parse_batchmovetype()
1342 * Parse skinvar batchmovetype
1347 public function parse_batchmovetype()
1349 echo Entity::hsc(requestVar('action'));
1354 * AdminActions::parse_blogcatlist()
1355 * Parse skinvar blogcatlist
1360 public function parse_blogcatlist($template_name = '')
1363 $blogid = intRequestVar('blogid');
1364 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1365 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1367 $resource = DB::getResult($query);
1368 if ( $resource->rowCount() > 0 )
1370 $template['content'] = 'categorylist';
1371 $template['tabindex'] = 200;
1372 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template, $template_name));
1376 /* TODO: nothing to be shown */
1378 $resource->closeCursor();
1384 * AdminActions::parse_blogid()
1385 * Parse skinvar blogid
1390 public function parse_blogid()
1392 echo intRequestVar('blogid');
1397 * AdminActions::parse_blognotifysetting()
1398 * Parse skinvar blognotifysetting
1403 public function parse_blognotifysetting($type)
1406 $blogid = intRequestVar('blogid');
1407 $blog =& $manager->getBlog($blogid);
1412 if ( !$blog->notifyOnComment() )
1418 if ( !$blog->notifyOnVote() )
1424 if ( !$blog->notifyOnNewItem() )
1430 echo ' checked="checked"';
1435 * AdminActions::parse_blogsetting()
1436 * Parse skinvar blogsetting
1438 * @param string $which name of weblog setting
1441 public function parse_blogsetting($which)
1443 echo $this->parse_getblogsetting($which);
1448 * AdminActions::parse_blogsettingyesno()
1449 * Parse skinvar blogsettingyesno
1451 * @param string $type type of weblog setting
1452 * @param string $template_name name of template to use
1455 public function parse_blogsettingyesno($type, $template_name = '')
1459 $blogid = intRequestVar('blogid');
1460 $blog =& $manager->getBlog($blogid);
1464 case 'convertbreaks':
1465 $checkedval = $blog->convertBreaks();
1468 case 'allowpastposting':
1469 $checkedval = $blog->allowPastPosting();
1473 $checkedval = $blog->commentsEnabled();
1477 $checkedval = $blog->isPublic();
1481 $checkedval = $blog->emailRequired();
1485 $checkedval = $blog->getSearchable();
1489 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1494 * AdminActions::parse_blogteamlist()
1495 * Parse skinvar blogteamlist
1497 * @param string $template_name name of template to use
1500 public function parse_blogteamlist($template_name = '')
1503 $blogid = intRequestVar('blogid');
1504 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1506 . "WHERE tmember=mnumber AND tblog= %d";
1507 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1509 $resource = DB::getResult($query);
1510 if ( $resource->rowCount() > 0 )
1512 $template['content'] = 'teamlist';
1513 $template['tabindex'] = 10;
1515 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template, $template_name));
1521 $resource->closeCursor();
1527 * AdminActions::parse_blogteammembers()
1528 * Parse skinvar blogteammembers
1533 public function parse_blogteammembers()
1535 $blogid = intRequestVar('blogid');
1536 $query = "SELECT mname, mrealname "
1538 . "WHERE mnumber=tmember AND tblog=%d;";
1539 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1540 $res = DB::getResult($query);
1541 $memberNames = array();
1542 foreach ( $res as $row )
1544 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1546 echo implode(',', $memberNames);
1550 * AdminActions::parse_blogtime()
1551 * Parse skinvar blogtime
1553 * @param string $type type of time
1554 * @param string $format format for time expression
1555 * @param integer $offset offset of time
1558 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1562 if ( $type != 'blogtime' )
1564 /* return server time */
1565 $timestamp = time() + $offset;
1569 $bid = intRequestVar('blogid');
1570 $b =& $manager->getBlog($bid);
1571 $timestamp = $b->getCorrectTime() + $offset;
1574 echo i18n::formatted_datetime($format, $timestamp);
1579 * AdminActions::parse_bookmarkletadmin()
1580 * Parse skinvar bookmarkletadmin
1585 public function parse_bookmarkletadmin()
1589 $blogid = intRequestVar('blogid');
1591 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1596 * AdminActions::parse_categories()
1597 * Parse skinvar categories
1599 * create category dropdown box
1601 * @param string $type name of setting for category
1604 public function parse_categories($startidx = 0)
1608 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1610 $catid = Admin::$blog->getDefaultCategory();
1614 $catid = Admin::$contents['catid'];
1617 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1623 * AdminActions::parse_categorysetting()
1624 * Parse skinvar categorysetting
1626 * @param string $type type in category setting
1629 public function parse_categorysetting($type)
1631 $catid = intRequestVar('catid');
1632 if ( $type == 'id' )
1637 $blogid = intRequestVar('blogid');
1638 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1639 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1640 $row = DB::getRow($query);
1642 if ( $type != 'name' )
1644 echo Entity::hsc($row['cdesc']);
1648 echo Entity::hsc($row['cname']);
1655 * AdminActions::parse_codename()
1656 * Parse templatevar codename
1662 public function parse_checkedonval($value, $name)
1667 $itemid = intRequestVar('itemid');
1668 $item =& $manager->getItem($itemid, 1, 1);
1672 $blog =& $manager->getBlog($item['blogid']);
1674 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1676 $item['body'] = removeBreaks($item['body']);
1677 $item['more'] = removeBreaks($item['more']);
1681 $contents = array();
1682 if ( requestVar('action') == 'itemedit' )
1686 if ( !isset($contents[$name]) )
1688 $contents[$name] = '';
1690 if ($contents[$name] == $value)
1692 echo 'checked="checked"';
1698 * AdminActions::parse_codename()
1699 * Parse templatevar codename
1704 * TODO: is this need???
1706 public function parse_codename()
1709 echo $nucleus['codename'];
1714 * AdminActions::parse_commentnavlist()
1715 * Parse skinvar commentnavlist
1717 * @param string $template_name name of template to use
1720 public function parse_commentnavlist($template_name = '')
1722 global $CONF, $manager, $member;
1725 if ( postVar('start') )
1727 $start = intPostVar('start');
1734 // amount of items to show
1735 if ( postVar('amount') )
1737 $amount = intPostVar('amount');
1741 $amount = (integer) $CONF['DefaultListSize'];
1747 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1749 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1751 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1753 if ( $this->skintype == 'itemcommentlist' )
1755 $itemid = intRequestVar('itemid');
1756 $query .= " citem={$itemid}";
1757 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1759 $nonComments = _NOCOMMENTS;
1761 elseif ( $this->skintype == 'browseowncomments' )
1764 $query .= ' cmember=' . $member->getID();
1765 $template['canAddBan'] = 0;
1767 $nonComments = _NOCOMMENTS_YOUR;
1769 elseif ( $this->skintype == 'blogcommentlist' )
1772 $query .= ' cblog=' . intRequestVar('blogid');
1773 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1774 $bid = intRequestVar('blogid');
1775 $nonComments = _NOCOMMENTS_BLOG;
1778 $search = postVar('search');
1779 if ( !empty($search) )
1781 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1784 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1786 $resource = DB::getResult($query);
1787 if ( $resource->rowCount() > 0 )
1789 $template['action'] = $this->skintype;
1790 $template['start'] = $start;
1791 $template['amount'] = $amount;
1792 $template['minamount'] = 0;
1793 $template['maxamount'] = 1000;
1794 $template['blogid'] = $bid;
1795 $template['search'] = $search;
1796 $template['itemid'] = $itemid;
1798 $template['content'] = 'commentlist';
1800 $navlist = listplug_navlist('comment', $resource, 'table', $template, $template_name);
1801 $this->parser->parse($navlist);
1805 /* TODO: nothing to be shown */
1807 $resource->closeCursor();
1813 * AdminActions::parse_configsettingsedit()
1814 * Parse skinvar configsettingsedit
1816 * @param string $type type of global configuration
1819 public function parse_configsettingsedit($type)
1824 case 'DefaultListSize':
1825 if ( !array_key_exists('DefaultListSize', $CONF) )
1827 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1828 $query = sprintf($query, sql_table('config'));
1829 DB::execute($query);
1830 $CONF['DefaultListSize'] = 10;
1832 elseif ( intval($CONF['DefaultListSize']) < 1 )
1834 $CONF['DefaultListSize'] = 10;
1836 echo intval($CONF['DefaultListSize']);
1838 case 'SessionCookie':
1839 $value = $CONF['SessionCookie'];
1840 $txt1 = _SETTINGS_COOKIESESSION;
1841 $txt2 = _SETTINGS_COOKIEMONTH;
1842 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1845 $value = $CONF['URLMode'];
1846 $txt1 = _SETTINGS_URLMODE_NORMAL;
1847 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1848 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1851 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1853 echo Entity::hsc($CONF[$type]);
1861 * AdminActions::parse_configsettingsyesno()
1862 * Parse skinvar configsettingsyesno
1864 * @param string $type type of global setting
1865 * @param integer $tabindex tabindex attribute of input element
1868 public function parse_configsettingsyesno($type, $tabindex)
1871 if ( array_key_exists($type, $CONF) )
1873 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1879 * AdminActions::parse_contents()
1880 * Parse skinvar contents
1882 * @param string $which part for item
1885 public function parse_contents($which)
1887 if ( !array_key_exists($which, Admin::$contents) )
1889 Admin::$contents[$which] = '';
1891 echo Entity::hsc(Admin::$contents[$which]);
1895 * AdminActions::parse_currenttime()
1896 * Parse skinvar currenttime
1898 * @param string $what
1901 public function parse_currenttime($what)
1903 $nu = getdate(Admin::$blog->getCorrectTime());
1908 * AdminActions::parse_customhelplink()
1909 * Parse skinvar customhelplink
1911 * @param string $topic name of topic
1912 * @param string $tplName name of template
1913 * @param string $url string as URI
1914 * @param string $iconURL string as URI for icon
1915 * @param string $alt alternative text for image element
1916 * @param string $title title for anchor element
1919 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1921 $this->customHelp($topic, $url, $iconURL);
1926 * AdminActions::parse_date()
1927 * Parse skinvar date
1929 public function parse_date($format = 'c')
1931 global $CONF, $manager;
1932 /* TODO: offset is based on i18n::get_current_locale()? */
1933 echo i18n::formatted_datetime($format, time());
1938 * AdminActions::parse_normalskinlist()
1939 * Parse skinvar defaultadminskintypes
1941 * @param string $template_name name of template
1944 public function parse_normalskinlist($template_name = '')
1946 global $CONF, $manager;
1948 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1950 $skin =& $manager->getSkin($CONF['BaseSkin']);
1951 /* TODO: removeaction? */
1952 $template['editaction'] = 'skinedittype';
1956 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1957 $template['editaction'] = 'adminskinedittype';
1958 /* TODO: removeaction? */
1961 $temporary = $skin->getNormalTypes();
1962 $normal_skintype = array();
1963 foreach ( $temporary as $type => $label )
1965 $normal_skintype[] = array(
1966 'skintype' => $type,
1967 'skintypename' => $label
1971 $template['tabindex'] = 10;
1972 $template['skinid'] = intRequestVar('skinid');
1973 $template['skinname'] = $skin->getName();
1974 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1980 * AdminActions::parse_defblogselect()
1981 * Parse skinvar defblogselect
1983 * @param string $template_name name of template
1986 public function parse_defblogselect($template_name = '')
1990 $query = "SELECT bname as text, bnumber as value FROM %s;";
1991 $query = sprintf($query, sql_table('blog'));
1993 $template['name'] = 'DefaultBlog';
1994 $template['selected'] = $CONF['DefaultBlog'];
1995 $template['tabindex'] = 10;
1996 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2002 * AdminActions::parse_defcatselect()
2003 * Parse skinvar defcatselect
2005 * @param string $template_name name of template
2008 public function parse_defcatselect($template_name = '')
2012 $blogid = intRequestVar('blogid');
2013 $blog =& $manager->getBlog($blogid);
2015 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2016 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2018 $template['name'] = 'defcat';
2019 $template['selected'] = $blog->getDefaultCategory();
2020 $template['tabindex'] = 110;
2022 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2028 * AdminActions::parse_defskinselect()
2029 * Parse skinvar defskinselect
2031 * @param string $type type of skin
2032 * @param string $template_name name of template
2035 public function parse_defskinselect($type = 'blog', $template_name = '')
2037 global $CONF, $manager, $member;
2039 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2041 $blogid = intRequestVar('blogid');
2044 $template['selected'] = $CONF['BaseSkin'];
2048 $blog =& $manager->getBlog($blogid);
2049 $template['selected'] = $blog->getDefaultSkin();
2052 if ( $type != 'blog' )
2054 $template['name'] = 'BaseSkin';
2058 $template['name'] = 'defskin';
2061 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2065 /* TODO: member object will have its own adminskin id */
2066 $template['selected'] = $CONF['AdminSkin'];
2067 $template['name'] = 'AdminSkin';
2068 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2071 $query = sprintf($query, sql_table('skin_desc'));
2072 $template['tabindex'] = 50;
2074 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2080 * AdminActions::parse_deletecomment()
2081 * Parse skinvar deletecomment
2083 * @param string $type type of infomation for comment
2086 public function parse_deletecomment($type = 'id')
2088 $commentid = intRequestVar('commentid');
2089 $comment = COMMENT::getComment($commentid);
2094 echo intRequestVar('commentid');
2097 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2099 echo $comment['member'];
2103 echo $comment['user'];
2107 $body = strip_tags($comment['body']);
2108 echo Entity::hsc(shorten($body, 300, '...'));
2114 * AdminActions::parse_deleteitembody()
2115 * Parse skinvar deleteitembody
2120 public function parse_deleteitembody()
2124 $itemid = intRequestVar('itemid');
2125 $item =& $manager->getItem($itemid, 1, 1);
2127 $body = strip_tags($item['body']);
2129 echo Entity::hsc(shorten($body, 300, '...'));
2135 * AdminActions::parse_deleteitemid()
2136 * Parse skinvar deleteitemid
2141 public function parse_deleteitemid()
2143 echo (integer) intRequestVar('itemid');
2148 * AdminActions::parse_deleteitemtitle()
2149 * Parse skinvar deleteitemtitle
2154 public function parse_deleteitemtitle()
2158 $itemid = intRequestVar('itemid');
2159 $item =& $manager->getItem($itemid, 1, 1);
2161 echo Entity::hsc(strip_tags($item['title']));
2167 * AdminActions::parse_editcomment()
2168 * Parse skinvar editcomment
2170 * @param string $type type of comment setting
2173 public function parse_editcomment($type = 'id')
2177 $comment = Admin::$contents;
2182 echo intRequestVar('commentid');
2185 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2187 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2191 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2195 echo date("Y-m-d @ H:i", $comment['timestamp']);
2198 $comment['body'] = str_replace('<br />', '', $comment['body']);
2199 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2200 echo $comment['body'];
2203 echo $comment['userid'];
2206 echo $comment['userid'];
2209 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2211 echo $comment[$type];
2219 * AdminActions::parse_editdesturl()
2220 * Parse skinvar editdesturl
2222 public function parse_editdesturl()
2224 if ( requestVar('desturl') )
2226 echo Entity::hsc(requestVar('desturl'));
2232 * AdminActions::parse_editmemberlist()
2233 * Parse skinvar editmemberlist
2235 * @param string $template_name name of template
2238 public function parse_editmemberlist($template_name = '')
2241 // show list of members with actions
2242 $query = 'SELECT * FROM %s;';
2243 $query = sprintf($query, sql_table('member'));
2245 $resource = DB::getResult($query);
2246 if ( $resource->rowCount() > 0 )
2248 $template['content'] = 'memberlist';
2249 $template['tabindex'] = 10;
2251 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template, $template_name));
2257 $resource->closeCursor();
2263 * AdminActions::parse_editmember()
2264 * Parse skinvar editmember
2266 * @param string $type type of information for member
2267 * @return string $tempateName name of template to use
2270 public function parse_editmember($type = 'id', $template_name = '')
2272 global $CONF, $manager, $member;
2274 $memberid = intRequestVar('memberid');
2275 $mem =& $manager->getMember($memberid);
2280 echo intRequestVar('memberid');
2283 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2285 echo Entity::hsc($mem->getDisplayName());
2289 $dispName = Entity::hsc($mem->getDisplayName());
2290 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2292 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2301 echo Entity::hsc($mem->getRealName());
2304 echo Entity::hsc($mem->getEmail());
2307 echo Entity::hsc($mem->getURL());
2310 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2313 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2316 echo Entity::hsc($mem->getNotes());
2319 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2328 * AdminActions::parse_editpluginfo()
2329 * Parse skinvar editpluginfo
2331 * @param string $type type of plugin info
2334 public function parse_editpluginfo($type)
2338 $pid = intRequestVar('plugid');
2345 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2352 * AdminActions::parse_editplugoptionslist()
2353 * Parse skinvar editplugoptionslist
2355 * @param string $template_name name of template
2358 public function parse_editplugoptionslist($template_name = '')
2362 $pid = intRequestVar('plugid');
2363 $aOptions = array();
2366 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2367 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2368 $resource = DB::getResult($query);
2370 foreach ( $resource as $row )
2372 $aOIDs[] = $row['oid'];
2373 $aOptions[$row['oid']] = array(
2374 'oid' => $row['oid'],
2375 'value' => $row['odef'],
2376 'name' => $row['oname'],
2377 'description' => $row['odesc'],
2378 'type' => $row['otype'],
2379 'typeinfo' => $row['oextra'],
2384 // fill out actual values
2385 if ( count($aOIDs) > 0 )
2387 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2388 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2390 $result = DB::getResult($query);
2391 foreach ( $result as $row )
2393 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2399 'context' => 'global',
2401 'options' => &$aOptions
2403 $manager->notify('PrePluginOptionsEdit', $data);
2405 if ( sizeof($aOptions) > 0 )
2407 $template['content'] = 'plugoptionlist';
2408 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2412 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2418 * AdminActions::parse_editskin()
2419 * Parse skinvar editskin
2421 * @param string $type type of skin
2424 public function parse_editskin($type = 'id')
2428 $skinid = intRequestVar('skinid');
2430 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2432 $skin =& $manager->getSKIN($skinid);
2436 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2442 echo intRequestVar('skinid');
2445 echo Entity::hsc($skin->getName());
2448 echo Entity::hsc($skin->getDescription());
2451 echo Entity::hsc($skin->getContentType());
2454 echo Entity::hsc($skin->getIncludePrefix());
2457 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2465 * AdminActions::parse_editskintype()
2466 * Parse skinvar editskintype
2468 * @param string $type name of type for skin type
2471 public function parse_editskintype($stype = 'id')
2475 static $skin = NULL;
2476 static $types = array();
2478 if ( $skin == NULL )
2480 $skinid = intRequestVar('skinid');
2482 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2484 $skin =& $manager->getSkin($skinid);
2488 $skin =& $manager->getSkin($skinid, 'AdminActions');
2491 $types = $skin->getNormalTypes();
2494 $type = strtolower(trim(requestVar('type')));
2499 echo $skin->getID();
2502 echo Entity::hsc($skin->getName());
2505 echo Entity::hsc($skin->getDescription());
2508 echo Entity::hsc($skin->getContentType());
2511 echo Entity::hsc($skin->getContentFromDB($type));
2514 if ( !array_key_exists($type, $types) )
2516 $skinType = ucfirst($type);
2520 $skinType = $types[$type];
2522 echo Entity::hsc($skinType);
2525 echo Entity::hsc($type);
2528 echo Entity::hsc($skin->getIncludePrefix());
2531 if ( !$skin->getIncludeMode() != 'skindir' )
2533 $incMode = _PARSER_INCMODE_NORMAL;
2537 $incMode = _PARSER_INCMODE_SKINDIR;
2539 echo Entity::hsc($incMode);
2548 * AdminActions::parse_adminurl()
2549 * Parse skinvar adminurl
2550 * (shortcut for admin url)
2555 public function parse_adminurl()
2557 $this->parse_sitevar('adminurl');
2562 * AdminActions::parse_edittemplateinfo()
2563 * Parse skinvar edittemplateinfo
2565 * @param string $format format to output
2566 * @param string $typedesc type of template
2567 * @param string $typename type name of template
2568 * @param string $help help text
2569 * @param string $tabindex index value for tabindex attribute of input element
2570 * @param string $big textarea size
2571 * @param string $tplt name of template to be filled
2574 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2578 static $name = NULL;
2579 static $desc = NULL;
2583 $id = intRequestVar('templateid');
2586 if ( $name == NULL )
2588 $name = Template::getNameFromId($id);
2591 if ( $desc == NULL )
2593 $desc = Template::getDesc($id);
2596 $template =& $manager->getTemplate($name);
2604 echo Entity::hsc($name);
2607 echo Entity::hsc($desc);
2609 case 'extratemplate':
2611 $pluginfields = array();
2612 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2614 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2618 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2621 foreach ( $pluginfields as $ptkey => $ptvalue )
2626 $tmplt =& $manager->getTemplate($desc);
2629 /* extra plugin field */
2630 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2633 . "<th colspan=\"2\"><%explugtplname%></th>\n"
2638 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2641 'explugtplname' => Entity::hsc($ptkey)
2643 echo Template::fill($base, $data);
2645 foreach ( $ptvalue as $ptname => $ptdesc )
2647 if ( !array_key_exists($ptname, $template) )
2653 $content = $template[$ptname];
2655 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2661 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2662 $typename = defined($typename) ? constant($typename) : $typename;
2664 if ( !array_key_exists($typename, $template) )
2670 $content = $template[$typename];
2672 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2680 * AdminActions::parse_eventformextra()
2681 * Parse skinvar eventformextra
2683 * @param string $type name of type for event form extra
2686 public function parse_eventformextra($type = 'activation')
2695 $key = requestVar('ackey');
2698 Admin::error(_ERROR_ACTIVATE);
2700 $info = MEMBER::getActivationInfo($key);
2703 Admin::error(_ERROR_ACTIVATE);
2705 $mem =& $manager->getMember($info->vmember);
2708 Admin::error(_ERROR_ACTIVATE);
2711 'type' => 'activation',
2715 case 'membermailform-notloggedin':
2716 $data = array('type' => 'membermailform-notloggedin',);
2719 $manager->notify('FormExtra', $data);
2724 * AdminActions::parse_extrahead()
2725 * Parse skinvar extrahead
2727 public function parse_extrahead()
2732 'extrahead' => &Admin::$extrahead,
2733 'action' => Admin::$action
2736 $manager->notify('AdminPrePageHead', $data);
2738 $this->parser->parse(Admin::$extrahead);
2743 * AdminActions::parse_member()
2744 * Parse skinvar member
2745 * (includes a member info thingie)
2747 * @param string $what which memberdata is needed
2750 public function parse_member($what)
2752 global $memberinfo, $member, $CONF;
2754 // 1. only allow the member-details-page specific variables on member pages
2755 if ( $this->skintype == 'member' )
2760 echo Entity::hsc($memberinfo->getDisplayName());
2763 echo Entity::hsc($memberinfo->getRealName());
2766 echo Entity::hsc($memberinfo->getNotes());
2769 echo Entity::hsc($memberinfo->getURL());
2772 echo Entity::hsc($memberinfo->getEmail());
2775 echo Entity::hsc($memberinfo->getID());
2780 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2781 if ( $member->isLoggedIn() )
2786 echo $member->getDisplayName();
2788 case 'yourrealname':
2789 echo $member->getRealName();
2792 echo $member->getNotes();
2795 echo $member->getURL();
2798 echo $member->getEmail();
2801 echo $member->getID();
2803 case 'yourprofileurl':
2804 if ( $CONF['URLMode'] == 'pathinfo' )
2806 echo Link::create_member_link($member->getID());
2810 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2819 * AdminActions::parse_version()
2820 * Parse skinvar version
2821 * (include nucleus versionnumber)
2826 public function parse_version()
2829 echo 'Nucleus CMS ' . $nucleus['version'];
2834 * AdminActions::parse_sitevar()
2835 * Parse skinvar sitevar
2836 * (include a sitevar)
2838 * @param string $which
2841 public function parse_sitevar($which)
2847 echo $CONF['IndexURL'];
2850 echo $CONF['SiteName'];
2853 echo $CONF['AdminEmail'];
2856 echo $CONF['AdminURL'];
2863 * AdminActions::parse_actionurl()
2869 public function parse_actionurl()
2872 echo Entity::hsc($CONF['ActionURL']);
2877 * AdminActions::parse_getblogsetting()
2878 * Parse skinvar getblogsetting
2880 public function parse_getblogsetting($which)
2882 global $blog, $manager;
2888 elseif ( $bid = intRequestVar('blogid') )
2890 $b =& $manager->getBlog($bid);
2900 return Entity::hsc($b->getID());
2903 return Entity::hsc($b->getURL());
2906 return Entity::hsc($b->getName());
2909 return Entity::hsc($b->getDescription());
2912 return Entity::hsc($b->getShortName());
2914 case 'notifyaddress':
2915 return Entity::hsc($b->getNotifyAddress());
2918 return Entity::hsc($b->getMaxComments());
2921 return Entity::hsc($b->getUpdateFile());
2924 return Entity::hsc($b->getTimeOffset());
2931 * AdminActions::parse_geteditpluginfo()
2932 * Parse skinvar geteditpluginfo
2934 * @param string $type name of setting for edit plugin info
2937 public function parse_geteditpluginfo($type)
2940 $pid = intRequestVar('plugid');
2947 return Entity::hsc($manager->getPluginNameFromPid($pid));
2954 * AdminActions::parse_getmember()
2955 * Parse skinvar getmember
2956 * (includes a member info thingie)
2958 * @param string $what name of setting for member
2961 public function parse_getmember($what)
2963 global $memberinfo, $member;
2964 // 1. only allow the member-details-page specific variables on member pages
2965 if ( $this->skintype == 'member' )
2970 return Entity::hsc($memberinfo->getDisplayName());
2973 return Entity::hsc($memberinfo->getRealName());
2976 return Entity::hsc($memberinfo->getNotes());
2979 return Entity::hsc($memberinfo->getURL());
2982 return Entity::hsc($memberinfo->getEmail());
2985 return Entity::hsc($memberinfo->getID());
2989 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2990 if ( $member->isLoggedIn() )
2995 return $member->getDisplayName();
2997 case 'yourrealname':
2998 return $member->getRealName();
3001 return $member->getNotes();
3004 return $member->getURL();
3007 return $member->getEmail();
3010 return $member->getID();
3018 * AdminActions::parse_headmessage()
3019 * Parse skinvar headmessage
3024 public function parse_headmessage()
3026 if ( !empty(Admin::$headMess) )
3028 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3034 * AdminActions::parse_helplink()
3035 * Parse skinvar helplink
3037 * @param string $topic name of topic for help
3040 public function parse_helplink($topic = '')
3042 if ( !empty($topic) )
3050 * AdminActions::parse_helpplugname()
3051 * Parse skinvar helpplugname
3056 public function parse_helpplugname()
3058 $plugid = intGetVar('plugid');
3059 Entity::hsc($manager->getPluginNameFromPid($plugid));
3064 * AdminActions::parse_ilistaddnew()
3065 * Parse skinvar ilistaddnew
3070 public function parse_ilistaddnew()
3072 $blogid = intRequestVar('blogid');
3073 if ( intPostVar('start') == 0 )
3075 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3081 * AdminActions::parse_importskininfo()
3082 * Parse skinvar importskininfo
3084 * @param string $type name of information for imported skin
3087 public function parse_importskininfo($type)
3092 echo Entity::hsc(Admin::$contents['skininfo']);
3095 $dataArr = Admin::$contents['skinnames'];
3096 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3099 $dataArr = Admin::$contents['tpltnames'];
3100 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3103 $dataArr = Admin::$contents['skinclashes'];
3104 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3107 $dataArr = Admin::$contents['tpltclashes'];
3108 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3111 echo Entity::hsc(Admin::$contents['skinfile']);
3114 echo Entity::hsc(Admin::$contents['mode']);
3121 * AdminActions::parse_init()
3122 * some init stuff for all forms
3127 public function parse_init()
3132 if ( requestVar('action') == 'itemedit' )
3134 $authorid = Admin::$contents['authorid'];
3137 Admin::$blog->insertJavaScriptInfo($authorid);
3142 * AdminActions::parse_inputyesno()
3143 * Parse skinvar inputyesno
3145 * @param string $name
3146 * @param string $checkedval
3147 * @param string $tabindex
3148 * @param string $value1
3149 * @param string $value2
3150 * @param string $yesval
3151 * @param string $noval
3152 * @param string $isAdmin
3153 * @param string $template_name
3156 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3158 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3163 * AdminActions::parse_insertpluginfo()
3164 * Parse templatevar insertpluginfo
3166 public function parse_insertpluginfo($type)
3171 return Admin::$aOptions['pid'];
3174 return Entity::hsc(Admin::$aOptions['pfile']);
3181 * AdminActions::parse_insplugoptcontent()
3182 * Parse skinvar insplugoptcontent
3187 public function parse_insplugoptcontent()
3189 $meta = NucleusPlugin::getOptionMeta(Admin::$aOptions['typeinfo']);
3190 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3193 listplug_plugOptionRow(Admin::$aOptions);
3200 * AdminActions::parse_iprangeinput()
3201 * Parse skinvar iprangeinput
3206 public function parse_iprangeinput()
3208 if ( requestVar('ip') )
3210 $iprangeVal = Entity::hsc(requestVar('ip'));
3211 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3212 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3213 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3214 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3215 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3219 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3220 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3226 * AdminActions::parse_itemnavlist()
3227 * Parse skinvar itemnavlist
3229 * @param string $template_name name of template to use
3232 public function parse_itemnavlist($template_name = '')
3234 global $CONF, $manager, $member;
3236 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3237 . " FROM %s, %s, %s, %s"
3238 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3240 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3242 if ( $this->skintype == 'itemlist' )
3245 if ( array_key_exists('blogid', $_REQUEST) )
3247 $blogid = intRequestVar('blogid');
3249 else if ( array_key_exists('itemid', $_REQUEST) )
3251 $itemid = intRequestVar('itemid');
3252 $item = &$manager->getItem($itemid, 1, 1);
3253 $blogid = (integer) $item['blogid'];
3255 $blog =& $manager->getBlog($blogid);
3257 $query .= " AND iblog={$blogid}";
3258 $template['now'] = $blog->getCorrectTime(time());
3260 // non-blog-admins can only edit/delete their own items
3261 if ( !$member->blogAdminRights($blogid) )
3263 $query .= ' AND iauthor = ' . $member->getID();
3266 elseif ( $this->skintype == 'browseownitems' )
3268 $query .= ' AND iauthor = ' . $member->getID();
3270 $template['now'] = time();
3273 // search through items
3274 $search = postVar('search');
3276 if ( !empty($search) )
3278 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3279 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3280 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3283 if ( postVar('start') )
3285 $start = intPostVar('start');
3292 // amount of items to show
3293 if ( postVar('amount') )
3295 $amount = intPostVar('amount');
3299 $amount = (integer) $CONF['DefaultListSize'];
3306 $query .= ' ORDER BY itime DESC'
3307 . " LIMIT {$start},{$amount}";
3309 $resource = DB::getResult($query);
3310 if ( $resource->rowCount() > 0 )
3312 $template['action'] = $this->skintype;
3313 $template['start'] = $start;
3314 $template['amount'] = $amount;
3315 $template['minamount'] = 0;
3316 $template['maxamount'] = 1000;
3317 $template['blogid'] = $blogid;
3318 $template['search'] = $search;
3319 $template['itemid'] = 0;
3321 $template['content'] = 'itemlist';
3323 $navlist = listplug_navlist('item', $query, 'table', $template, $template_name);
3324 $this->parser->parse($navlist);
3328 /* TODO: nothing to be shown */
3330 $resource->closeCursor();
3336 * AdminActions::parse_itemtime()
3337 * date change on edit item
3339 * @param string $key key of PHP's getDate()
3342 public function parse_itemtime($key)
3346 $contents = Admin::$contents;
3347 $itemtime = getdate($contents['timestamp']);
3348 echo $itemtime[$key];
3353 * AdminActions::parse_jstoolbaroptions()
3354 * Parse skinvar jstoolbaroptions
3359 public function parse_jstoolbaroptions()
3363 _SETTINGS_JSTOOLBAR_NONE,
3364 _SETTINGS_JSTOOLBAR_SIMPLE,
3365 _SETTINGS_JSTOOLBAR_FULL
3369 foreach ( $options as $option )
3371 $text = "<option value=\"%d\"%s>%s</option>\n";
3372 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3373 echo sprintf($text, $i, $extra, $option);
3379 * AdminActions::parse_localeselectoptions()
3380 * Parse skinvar localeselectoptions
3385 public function parse_localeselectoptions()
3387 global $CONF, $member;
3389 $locales = i18n::get_available_locale_list();
3391 /* default option */
3392 if ( $this->skintype == 'editmembersettings' )
3394 if ( !$member->getLocale() )
3396 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3400 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3405 if ( $CONF['Locale'] == 'en_Latn_US' )
3407 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
3411 echo "<option value=\"\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
3415 /* optional options */
3416 foreach ( $locales as $locale )
3418 if ( $this->skintype == 'editmembersettings' )
3420 if ( $locale != $member->getLocale() )
3422 echo "<option value=\"{$locale}\">";
3426 echo "<option value=\"{$locale}\" selected=\"selected\">";
3431 if ( $locale == 'en_Latn_US' )
3433 /* already output */
3436 else if ( $locale != $CONF['Locale'] )
3438 echo "<option value=\"{$locale}\">";
3442 echo "<option value=\"{$locale}\" selected=\"selected\">";
3445 $label = '_LOCALE_' . strtoupper($locale);
3446 if ( !defined($label) )
3452 echo constant($label);
3460 * AdminActions::parse_listplugplugoptionrow()
3461 * Parse templatevar listplugplugoptionrow
3463 * @param string $template_name name of template
3466 public function parse_listplugplugoptionrow($template_name = '')
3468 echo listplug_plugOptionRow(Admin::$aOptions, $template_name);
3473 * AdminActions::parse_mediadirwarning()
3474 * Parse skinvar mediadirwarning
3479 public function parse_mediadirwarning()
3482 if ( !is_dir($DIR_MEDIA) )
3484 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3486 if ( !is_readable($DIR_MEDIA) )
3488 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3490 if ( !is_writeable($DIR_MEDIA) )
3492 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3498 * AdminActions::parse_movedistselect()
3499 * Parse skinvar movedistselect
3501 public function parse_movedistselect()
3503 $actionType = requestVar('action');
3504 switch ( $actionType )
3507 $this->selectBlog('destcatid', 'category');
3509 case 'batchcategory':
3510 $this->selectBlog('destblogid');
3513 if ( $this->skintype == 'itemmove' )
3515 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3516 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3517 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3518 $this->selectBlog('catid', 'category', $catid, 10, 1);
3526 * AdminActions::parse_moveitemid()
3527 * Parse skinvar moveitemid
3532 public function parse_moveitemid()
3534 echo intRequestVar('itemid');
3539 * AdminActions::parse_newestcompare()
3540 * Parse skinvar newestcompare
3545 public function parse_newestcompare()
3549 $newestVersion = getLatestVersion();
3550 $newestCompare = str_replace('/', '.', $newestVersion);
3551 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3553 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3555 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3556 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3560 echo _ADMIN_SYSTEMOVERVIEW_VERSION_LATEST;
3566 * AdminActions::parse_newmemberselect()
3567 * Parse skinvar newmemberselect
3569 * @param string $template_name name of template to use
3572 public function parse_newmemberselect($template_name = '')
3574 $blogid = intRequestVar('blogid');
3576 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3577 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3578 $res = DB::getResult($query);
3581 foreach ( $res as $row )
3583 $tmem[] = intval($row['tmember']);
3586 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3587 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3590 'name' => 'memberid',
3591 'tabindex' => 10000,
3594 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3599 * AdminActions::parse_newpluginlist()
3600 * Parse skinvar newpluginlist
3605 public function parse_newpluginlist()
3607 $candidates = $this->newPlugCandidates;
3608 foreach ( $candidates as $name )
3610 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3616 * AdminActions::parse_outputspecialdirs()
3617 * Parse skinvar outputspecialdirs
3619 * @param string $type type of setting for directory
3622 public function parse_outputspecialdirs($type)
3624 global $DIR_MEDIA, $DIR_NUCLEUS;
3629 echo Entity::hsc($DIR_NUCLEUS);
3632 echo Entity::hsc($DIR_MEDIA);
3639 * AdminActions::parse_passrequestvars()
3640 * Parse skinvar passrequestvars
3645 public function parse_passrequestvars()
3647 $passvar = Admin::$passvar;
3648 $oldaction = postVar('oldaction');
3650 if ( ($oldaction != 'logout')
3651 && ($oldaction != 'login')
3653 && !postVar('customaction') )
3661 * AdminActions::parse_pluginextras()
3662 * Parse skinvar pluginextras
3664 * @param string $type type of plugin context
3667 public function parse_pluginextras($type = 'global')
3674 $id = intRequestVar('memberid');
3675 $mem =& $manager->getMember($id);
3676 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3679 $id = intRequestVar('blogid');
3680 $blg =& $manager->getBlog($id);
3681 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3683 case 'createaccount':
3685 'type' => 'createaccount.php',
3687 'postlabel' => '<br />',
3689 'postfield' => '<br /><br />'
3691 $manager->notify('RegistrationFormExtraFields', $data);
3694 $manager->notify('GeneralSettingsFormExtras', array());
3701 * AdminActions::parse_pluginhelp()
3702 * Parse skinvar pluginhelp
3707 public function parse_pluginhelp()
3709 global $manager, $DIR_PLUGINS;
3711 $plugid = intGetVar('plugid');
3712 $plugName = $manager->getPluginNameFromPid($plugid);
3713 $plug =& $manager->getPlugin($plugName);
3715 if ( $plug->supportsFeature('HelpPage') > 0 )
3717 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3718 if ( @file_exists($helpfile . 'php') )
3720 @include($helpfile . 'php');
3723 elseif ( @file_exists($helpfile . 'html') )
3725 @include($helpfile . 'html');
3729 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3730 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3735 * AdminActions::parse_pluginlistlist()
3736 * Parse skinvar pluginlistlist
3738 * @param string $template_name name of template to use
3741 public function parse_pluginlistlist($template_name = '')
3743 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3744 $query = sprintf($query, sql_table('plugin'));
3746 $template['content'] = 'pluginlist';
3747 $template['tabindex'] = 10;
3749 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3755 * AdminActions::parse_pluginoptions()
3756 * Parse skinvar pluginoptions
3758 * @param string $type type of plugin option
3761 public function parse_pluginoptions($context='global', $template_name='')
3763 global $itemid, $manager;
3768 $contextid = intRequestVar('memberid');
3771 $contextid = intRequestVar('blogid');
3774 $contextid = intRequestVar('catid');
3777 $contextid = $itemid;
3781 /* Actually registererd plugin options */
3782 $aIdToValue = array();
3783 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3784 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3785 $res = DB::getResult($query);
3786 foreach ( $res as $row )
3788 $aIdToValue[$row['oid']] = $row['ovalue'];
3791 /* Currently available plugin options */
3792 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3793 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3794 $res = DB::getResult($query);
3797 foreach ($res as $row )
3799 if ( !array_key_exists($row['oid'], $aIdToValue) )
3801 $value = $row['odef'];
3805 $value = $aIdToValue[$row['oid']];
3809 'pid' => $row['pid'],
3810 'pfile' => $row['pfile'],
3811 'oid' => $row['oid'],
3813 'name' => $row['oname'],
3814 'description' => $row['odesc'],
3815 'type' => $row['otype'],
3816 'typeinfo' => $row['oextra'],
3817 'contextid' => $contextid,
3823 'context' => $context,
3824 'contextid' => $contextid,
3825 'options' => &$options
3827 $manager->notify('PrePluginOptionsEdit', $data);
3829 $template = array();
3830 if ( $template_name )
3832 $templates =& $manager->getTemplate($template_name);
3833 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3835 $template['title'] = "<tr>"
3836 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3841 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3844 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3846 $template['body'] = "<tr>"
3847 . "<%listplugplugoptionrow%>"
3852 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3858 foreach ( $options as $option )
3861 if ( $prevPid != $option['pid'] )
3863 $prevPid = $option['pid'];
3864 $this->parser->parse($template['title']);
3867 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3869 if ( @$meta['access'] != 'hidden' )
3871 $parsed = $this->parser->parse($template['body']);
3879 * AdminActions::parse_qmenuaddselect()
3880 * Parse skinvar qmanuaddselect
3882 * @param string $template_name name of template to use
3885 public function parse_qmenuaddselect($template_name = '')
3887 global $member, $blogid;
3888 $showAll = requestVar('showall');
3889 if ( $member->isAdmin() && ($showAll == 'yes') )
3891 // Super-Admins have access to all blogs! (no add item support though)
3892 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3893 $query = sprintf($query, sql_table('blog'));
3897 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3898 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3901 $template['name'] = 'blogid';
3902 $template['tabindex'] = 15000;
3903 $template['extra'] = _QMENU_ADD_SELECT;
3904 $template['selected'] = 0;
3905 $template['shorten'] = 10;
3906 $template['shortenel'] = '';
3907 $template['javascript'] = 'onchange="return form.submit()"';
3909 $selectlist = showlist($query, 'select', $template, $template_name);
3910 $this->parser->parse($selectlist);
3916 * AdminActions::parse_quickmenu()
3917 * Parse skinvar quickmenu
3919 * @param string $template_name name of template to use
3922 public function parse_quickmenu($template_name = '')
3925 $templates = array();
3927 if ( !empty($template_name) )
3929 $templates = & $manager->getTemplate($template_name);
3931 $pluginExtras = array();
3932 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3934 $template = array();
3935 if ( count($pluginExtras) > 0 )
3937 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3939 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3944 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3947 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3949 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3953 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3956 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3958 $template['foot'] = "</ul>\n";
3962 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3965 $this->parser->parse($template['head']);
3966 foreach ( $pluginExtras as $aInfo )
3969 'plugadminurl' => Entity::hsc($aInfo['url']),
3970 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3971 'plugadmintitle' => Entity::hsc($aInfo['title']),
3973 $this->parser->parse(Template::fill($template['body'], $data));
3975 $this->parser->parse($template['foot']);
3981 * AdminActions::parse_requestblogid()
3982 * Parse skinvar requestblogid
3987 public function parse_requestblogid()
3989 echo intRequestVar('blogid');
3994 * AdminActions::parse_requestiprange()
3995 * Parse skinvar requestiprange
4000 public function parse_requestiprange()
4002 if ( requestVar('iprange') )
4004 echo Entity::hsc(requestVar('iprange'));
4006 elseif ( requestVar('ip') )
4008 echo Entity::hsc(requestVar('ip'));
4014 * AdminActions::parse_selectlocalskinfiles()
4015 * Parse skinvar selectlocalskinfiles
4020 public function parse_selectlocalskinfiles()
4024 if ( !class_exists('SkinImport', FALSE) )
4026 include_libs('skinie.php');
4029 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4031 $skindir = $DIR_SKINS;
4035 $skindir = "{$DIR_SKINS}admin/";
4038 $candidates = SkinImport::searchForCandidates($skindir);
4039 foreach ( $candidates as $skinname => $skinfile )
4041 $skinname = Entity::hsc($skinname);
4042 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4044 $skinfile = Entity::hsc($skinfile);
4048 $skinfile = Entity::hsc("admin/$skinfile");
4050 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4057 * AdminActions::parse_skineditallowedlist()
4058 * Parse skinvar skineditallowedlist
4060 * @param string $type type of skin
4061 * @param string $template_name name of template
4064 public function parse_skineditallowedlist($type, $template_name = '')
4069 $query = "SELECT bshortname, bname FROM %s;";
4071 'content' => 'shortblognames'
4073 $query = sprintf($query, sql_table('blog'));
4076 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4078 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4082 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4085 'content' => 'shortnames'
4087 $query = sprintf($query, sql_table('template_desc'));
4091 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4096 * AdminActions::parse_skinielist()
4097 * Parse skinvar skinielist
4099 * @param string $type type of skin
4100 * @param string $template_name name of template to use
4103 public function parse_skinielist($type, $template_name = '')
4107 $templates = array();
4108 if ( $template_name )
4110 $templates =& $manager->getTemplate($template_name);
4112 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4114 $template = "<tr>\n"
4116 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4117 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4119 . "<td><%expdesc%></td>\n"
4124 $template = $templates['SKINIE_EXPORT_LIST'];
4130 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4132 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4136 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4138 foreach ( $res as $row )
4141 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4142 'expid' => 'skinexp' . $row['sdnumber'],
4143 'expname' => Entity::hsc($row['sdname']),
4144 'expdesc' => Entity::hsc($row['sddesc'])
4146 echo Template::fill($template, $data);
4150 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4152 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4156 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4158 foreach ( $res as $row )
4161 'typeid' => 'template[' . $row['tdnumber'] . ']',
4162 'expid' => 'templateexp' . $row['tdnumber'],
4163 'expname' => Entity::hsc($row['tdname']),
4164 'expdesc' => Entity::hsc($row['tddesc'])
4166 echo Template::fill($template, $data);
4174 * AdminActions::parse_skinoverview()
4175 * Parse skinvar skinoverview
4177 * @param string $template_name name of template to use
4180 public function parse_skinoverview($template_name = '')
4184 $template = array();
4185 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4187 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4188 $template['handler'] = 'Actions';
4189 $template['editaction'] = 'skinedit';
4190 $template['cloneaction'] = 'skinclone';
4191 $template['deleteaction'] = 'skindelete';
4192 $template['edittypeaction'] = 'skinedittype';
4193 $template['default'] = $CONF['BaseSkin'];
4197 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4198 $template['handler'] = 'AdminActions';
4199 $template['editaction'] = 'adminskinedit';
4200 $template['cloneaction'] = 'adminskinclone';
4201 $template['deleteaction'] = 'adminskindelete';
4202 $template['edittypeaction'] = 'adminskinedittype';
4203 $template['default'] = $CONF['AdminSkin'];
4205 $query = sprintf($query, sql_table('skin_desc'));
4207 $template['tabindex'] = 10;
4208 $template['content'] = 'skinlist';
4210 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4216 * AdminActions::parse_skintypehelp()
4217 * Check editing skintypehelp
4222 public function parse_skintypehelp()
4224 $surrent_skin_type = strtolower(trim(requestVar('type')));
4225 $page_action = strtolower(trim(requestVar('action')));
4226 if ( in_array($page_action, Admin::$adminskin_actions) )
4228 $normal_types = array_keys(self::$normal_skin_types);
4232 $normal_types = array_keys(Actions::getNormalSkinTypes());
4235 if ( in_array($surrent_skin_type, $normal_types) )
4237 help('skinpart' . $surrent_skin_type);
4241 help('skinpartspecial');
4247 * AdminActions::parse_specialskinlist()
4248 * Parse skinvar specialskinlist
4250 * @param string $template_name name of template to use
4253 public function parse_specialskinlist($template_name = '')
4255 global $CONF, $manager;
4257 $template = array();
4259 $skinid = intRequestVar('skinid');
4261 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4263 $skin =& $manager->getSkin($skinid);
4264 $template['editaction'] = 'skinedittype';
4265 $template['removeaction'] = 'skinremovetype';
4269 $skin =& $manager->getSkin($skinid, 'AdminActions');
4270 $template['editaction'] = 'adminskinedittype';
4271 $template['removeaction'] = 'adminskinremovetype';
4273 $normal_types = $skin->getNormalTypes();
4274 $available_types = $skin->getAvailableTypes();
4276 $special_skintypes = array();
4277 foreach( $available_types as $skintype => $skinname )
4279 if ( !array_key_exists($skintype, $normal_types) )
4281 $special_skintypes[] = array(
4282 'skintype' => $skintype,
4283 'skintypename' => $skinname
4288 if ( sizeof($special_skintypes) > 0 )
4290 $template['tabindex'] = 75;
4291 $template['skinid'] = $skin->getID();
4292 $template['skinname'] = $skin->getName();
4293 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4297 /* TODO: nothing to be shown */
4304 * AdminActions::parse_sprinttext()
4307 * @param string $which
4308 * @param string $val
4311 public function parse_sprinttext($which, $val)
4313 if ( !defined($which) )
4319 $base = constant($which);
4322 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4324 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4326 $met = 'parse_' . $matchies[0];
4330 $arg = trim($args[0], '()');
4331 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4334 if ( method_exists($this, $met) )
4336 $value = call_user_func(array(&$this, $met), $arg);
4340 if ( !isset($value) || empty($value) )
4344 echo sprintf($base, $value);
4349 * AdminActions::parse_systemsettings()
4350 * Parse skinvar systemsettings
4352 * @param string $type type of settings for system
4353 * @param string $template_name name of template to use
4356 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4358 global $manager, $member, $CONF, $nucleus;
4360 $member->isAdmin() or Admin::disallow();
4362 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4363 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4370 case 'sqlserverinfo':
4371 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4373 case 'sqlclientinfo':
4374 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4376 case 'magicquotesgpc':
4377 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4379 case 'magicquotesruntime':
4380 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4382 case 'registerglobals':
4383 echo ini_get('register_globals') ? 'On' : 'Off';
4386 $templates = array();
4387 if ( $template_name )
4389 $templates =& $manager->getTemplate($template_name);
4391 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4393 $template = "<tr>\n"
4394 . "<td><%key%></td>\n"
4395 . "<td><%value%></td>\n"
4400 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4403 $gdinfo = gd_info();
4405 foreach ( $gdinfo as $key => $value )
4407 if ( is_bool($value) )
4409 $value = $value ? $enable : $disable;
4413 $value = Entity::hsc($value);
4419 echo Template::fill($template, $data);
4423 if ( function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) )
4430 phpinfo(INFO_MODULES);
4431 $im = ob_get_contents();
4433 if ( i18n::strpos($im, 'mod_rewrite') !== FALSE )
4443 case 'nucleusversion':
4444 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4446 case 'nucleuspatchlevel':
4447 echo getNucleusPatchLevel();
4453 echo $CONF['ItemURL'];
4455 case 'alertonheaderssent':
4456 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4458 case 'nucleuscodename':
4459 if ( $nucleus['codename'] != '' )
4461 echo ' "' . $nucleus['codename'] . '"';
4464 case 'versioncheckurl':
4465 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4472 * AdminActions::parse_templateoverview()
4473 * Parse skinvar templateoverview
4475 * @param string $template_name name of template to use
4478 public function parse_templateoverview($template_name = '')
4480 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4482 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4483 $template['deleteaction'] = 'templatedelete';
4484 $template['editaction'] = 'templateedit';
4485 $template['cloneaction'] = 'templateclone';
4489 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4490 $template['deleteaction'] = 'admintemplatedelete';
4491 $template['editaction'] = 'admintemplateedit';
4492 $template['cloneaction'] = 'admintemplateclone';
4494 $query = sprintf($query, sql_table('template_desc'));
4496 $template['tabindex'] = 10;
4497 $template['content'] = 'templatelist';
4499 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4505 * AdminActions::parse_ticket()
4511 public function parse_ticket()
4514 $manager->addTicketHidden();
4519 * AdminActions::parse_versioncheckurl()
4520 * Parse skinvar versioncheckurl
4525 public function parse_versioncheckurl()
4527 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4532 * AdminActions::parse_yrbloglist()
4533 * Parse skinvar yrbloglist
4535 * @param string $template_name name of template to use
4538 public function parse_yrbloglist($template_name = '')
4541 $showAll = requestVar('showall');
4543 if ( $member->isAdmin() && ($showAll == 'yes') )
4545 // Super-Admins have access to all blogs! (no add item support though)
4546 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4548 . " ORDER BY bnumber;";
4549 $query = sprintf($query, sql_table('blog'));
4553 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4555 . " WHERE tblog=bnumber and tmember=%d"
4556 . " ORDER BY bnumber;";
4557 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4560 $resource = DB::getResult($query);
4561 if ( ($showAll != 'yes') && $member->isAdmin() )
4563 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4564 $total = DB::getValue($query);
4566 if ( $total > $resource->rowCount() )
4568 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4572 if ( $resource->rowCount() > 0 )
4574 $template['content'] = 'bloglist';
4575 $template['superadmin'] = $member->isAdmin();
4577 $list_resource_table = showlist($resource, 'table', $template, $template_name);
4578 $this->parser->parse($list_resource_table);
4579 $resource->closeCursor();
4581 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4583 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4584 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4585 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4587 $resource = DB::getResult($query);
4588 if ( $resource->rowCount() > 0 )
4590 $template['content'] = 'draftlist';
4591 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4595 echo _OVERVIEW_NODRAFTS;
4600 echo _OVERVIEW_NOBLOGS;
4602 $resource->closeCursor();
4608 * AdminActions::checkCondition()
4609 * Checks conditions for if statements
4611 * @param string $field type of <%if%>
4612 * @param string $name property of field
4613 * @param string $value value of property
4614 * @return boolean condition
4616 protected function checkCondition($field, $name='', $value = '')
4618 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4628 $blog =& $manager->getBlog($blogid);
4632 $blogid = getBlogIDFromCatID($catid);
4633 $blog =& $manager->getBlog($blogid);
4635 elseif ( intRequestVar('catid') )
4637 $catid = intRequestVar('catid');
4638 $blogid = getBlogIDFromCatID($catid);
4639 $blog =& $manager->getBlog($blogid);
4646 $condition = ($blog && $this->ifCategory($name, $value));
4649 $condition = $member->isLoggedIn();
4652 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4655 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4658 $condition = $member->isLoggedIn() && $member->isAdmin();
4660 case 'allowloginedit':
4661 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4664 $condition = ($itemidnext != '');
4667 $condition = ($itemidprev != '');
4669 case 'archiveprevexists':
4670 $condition = ($archiveprevexists == true);
4672 case 'archivenextexists':
4673 $condition = ($archivenextexists == true);
4676 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4679 $condition = $this->ifHasPlugin($name, $value);
4682 $condition = (Admin::$action == $name);
4684 case 'adminoldaction':
4685 $condition = (Admin::$action == $name);
4687 case 'addresschange':
4688 $condition = ($this->ifAddresscange());
4690 case 'bechangepass':
4691 $condition = ($this->beChangePassword());
4693 case 'skincandidates':
4694 $condition = ($this->ifSkincandidates());
4697 $condition = Admin::$contents['nameclashes'];
4699 case 'existsnewplugin':
4700 $condition = ($this->existsNewPlugin());
4707 $condition = (boolean) ($member->getAutosave() == $value);
4714 $condition = (Admin::$blog->getSetting($name) == $value);
4716 case 'itemproperty':
4721 if ( array_key_exists($name, Admin::$contents) )
4723 $condition = (boolean) (Admin::$contents[$name] == $value);
4727 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4734 * AdminActions::_ifHasPlugin()
4735 * hasplugin,PlugName
4736 * -> checks if plugin exists
4737 * hasplugin,PlugName,OptionName
4738 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4739 * hasplugin,PlugName,OptionName=value
4740 * -> checks if the option OptionName from plugin PlugName is set to value
4742 * @param string $name name of plugin
4743 * @param string $value
4746 private function ifHasPlugin($name, $value)
4750 // (pluginInstalled method won't write a message in the actionlog on failure)
4751 if ( $manager->pluginInstalled("NP_{$name}") )
4753 $plugin =& $manager->getPlugin("NP_{$name}");
4754 if ( $plugin != NULL )
4762 list($name2, $value2) = preg_split('#=#', $value, 2);
4763 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4767 else if ( $plugin->getOption($name2) == $value2 )
4778 * AdminActions::beChangePassword()
4783 private function beChangePassword()
4785 return intRequestVar('bNeedsPasswordChange');
4789 * AdminActions::ifSkincandidates()
4790 * Checks if a plugin exists and call its doIf function
4796 private function ifSkincandidates()
4799 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4800 return (count($candidates) > 0);
4804 * AdminActions::ifPlugin()
4805 * Checks if a plugin exists and call its doIf function
4807 * @param string $name name of plugin
4808 * @param string $key
4809 * @param string $value
4812 private function ifPlugin($name, $key = '', $value = '')
4816 $plugin =& $manager->getPlugin("NP_{$name}");
4822 $params = func_get_args();
4823 array_shift($params);
4825 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4829 * AdminActions::ifCategory()
4830 * Different checks for a category
4832 * @param string $key key for information of category
4833 * @param string $value value for information of category
4836 private function ifCategory($key = '', $value='')
4838 global $blog, $catid;
4840 // when no parameter is defined, just check if a category is selected
4841 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4843 return $blog->isValidCategory($catid);
4846 // check category name
4847 if ( $key == 'catname' )
4849 $value = $blog->getCategoryIdFromName($value);
4850 if ($value == $catid)
4852 return $blog->isValidCategory($catid);
4856 // check category id
4857 if (($key == 'catid') && ($value == $catid))
4859 return $blog->isValidCategory($catid);
4866 * AdminActions::ifOnTeam()
4867 * Checks if a member is on the team of a blog and return his rights
4869 * @param string $blogName name of weblog
4872 private function ifOnTeam($blogName = '')
4874 global $blog, $member, $manager;
4876 // when no blog found
4877 if ( ($blogName == '') && !is_object($blog) )
4882 // explicit blog selection
4883 if ($blogName != '')
4885 $blogid = getBlogIDFromName($blogName);
4888 if (($blogName == '') || !$manager->existsBlogID($blogid))
4891 $blogid = $blog->getID();
4893 return $member->teamRights($blogid);
4897 * AdminActions::ifAdmin()
4898 * Checks if a member is admin of a blog
4900 * @param string $blogName name of weblog
4903 private function ifAdmin($blogName = '')
4905 global $blog, $member, $manager;
4907 // when no blog found
4908 if (($blogName == '') && (!is_object($blog)))
4913 // explicit blog selection
4914 if ($blogName != '')
4916 $blogid = getBlogIDFromName($blogName);
4919 if (($blogName == '') || !$manager->existsBlogID($blogid))
4922 $blogid = $blog->getID();
4925 return $member->isBlogAdmin($blogid);
4929 * AdminActions::ifAddresscange()
4930 * Check e-Mail address is changed
4935 private function ifAddresscange()
4939 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4944 $info = MEMBER::getActivationInfo($key);
4949 $mem =& $manager->getMember($info->vmember);
4954 if ( $info->vtype == 'addresschange' )
4963 * AdminActions::customHelp()
4964 * shows a link to custom help file
4967 * @param string $tplName
4968 * @param string $url
4969 * @param string $iconURL
4970 * @param string $alt
4971 * @param string $title
4975 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4977 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4982 * AdminActions::customHelp()
4983 * shows a link to custom help file
4986 * @param string $tplName
4987 * @param string $url
4988 * @param string $iconURL
4989 * @param string $alt
4990 * @param string $title
4994 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
4996 global $CONF, $manager;
4998 $templates = array();
5002 $templates =& $manager->getTemplate($tplName);
5005 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5007 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5011 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5016 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5019 if ( empty($onclick) )
5021 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5023 elseif ( preg_match('#^onclick#', $onclick) )
5025 $onclick = $onclick;
5029 $onclick = 'onclick="' . $onclick . '"';
5034 'helptarget' => $id,
5035 'onclick' => $onclick,
5036 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5038 return Template::fill($template, $data);
5043 * AdminActions::customHelpHtml()
5045 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5047 global $CONF, $manager;
5049 $templates = array();
5053 $templates =& $manager->getTemplate($tplName);
5055 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5057 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5061 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5064 if ( empty($iconURL) )
5066 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5069 if ( function_exists('getimagesize') )
5071 $size = getimagesize($iconURL);
5072 $width = 'width="' . $size[0] . '" ';
5073 $height = 'height="' . $size[1] . '" ';
5077 'iconurl' => $iconURL,
5079 'height' => $height,
5080 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5081 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5084 $icon = Template::fill($template, $data);
5085 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5087 return $help . $icon;
5091 * AdminActions::existsNewPlugin()
5092 * Check exists new plugin
5095 * @return boolean exists or not
5097 private function existsNewPlugin()
5099 global $DIR_PLUGINS;
5101 $query = "SELECT * FROM %s;";
5102 $query = sprintf($query, sql_table('plugin'));
5103 $res = DB::getResult($query);
5105 $installed = array();
5106 foreach( $res as $row )
5108 $installed[] = $row['pfile'];
5111 $files = scandir($DIR_PLUGINS);
5113 $candidates = array();
5114 foreach ( $files as $file )
5116 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5118 if ( !in_array($matches[1], $installed) )
5120 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5124 $this->newPlugCandidates = $candidates;
5125 return (count($candidates) > 0);
5129 * AdminActions::pagehead()
5130 * Output admin page head
5135 public function parse_pagehead()
5137 global $member, $nucleus, $CONF, $manager;
5139 /* HTTP 1.1 application for no caching */
5140 header("Cache-Control: no-cache, must-revalidate");
5141 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5143 $content = $this->parser->skin->getContentFromDB('pagehead');
5146 $root_element = 'html';
5147 $charset = i18n::get_current_charset();
5148 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5149 $xml_version_info = '1.0';
5150 $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
5151 $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
5152 $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
5154 $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5155 . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5156 . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5158 . "<title><%sitevar(name)%> - Admin</title>\n"
5159 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5160 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5161 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5165 . "<div id=\"adminwrapper\">"
5166 . "<div class=\"header\">"
5167 . "<h1><%sitevar(name)%></h1>"
5169 . "<div id=\"container\">"
5170 . "<div id=\"content\">"
5171 . "<div class=\"loginname\">"
5172 . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5173 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5174 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5175 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5180 . "<div id=\"adminwrapper\">\n"
5181 . "<div class=\"header\">\n"
5182 . "<h1><%sitevar(name)%></h1>\n"
5184 . "<div id=\"container\">\n"
5185 . "<div id=\"content\">\n"
5186 . "<div class=\"loginname\">\n"
5187 . "<%if(loggedin)%>"
5188 . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5189 . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5191 . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5193 . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5195 . "<%if(superadmin)%>"
5196 . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5197 . "<%newestcompare%><%else%><%version%><%codename%>"
5203 $this->parser->parse($content);
5208 * AdminActionss::pagefoot()
5209 * Output admin page foot include quickmenu
5214 public function parse_pagefoot()
5216 global $action, $member, $manager, $blogid;
5218 $manager->notify('AdminPrePageFoot', array('action' => Admin::$action));
5220 $content = $this->parser->skin->getContentFromDB('pagefoot');
5223 $content = "<%if(loggedin)%>"
5224 . "<%ifnot(adminaction,showlogin)%>"
5225 . "<h2><%text(_LOGOUT)%></h2>"
5227 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5228 . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5232 . "<div class=\"foot\">"
5233 . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> © 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5234 . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5237 . "<!-- content -->"
5238 . "<div id=\"quickmenu\">"
5239 . "<%if(loggedin)%>"
5240 . "<%ifnot(adminaction,showlogin)%>"
5242 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5244 . "<h2><%text(_QMENU_ADD)%></h2>"
5245 . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5247 . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5248 . "<%qmenuaddselect(admin/default)%>"
5251 . "<h2><%member(yourrealname)%></h2>"
5253 . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5254 . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5255 . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5257 . "<%if(superadmin)%>"
5258 . "<h2><%text(_QMENU_MANAGE)%></h2>"
5260 . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5261 . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5262 . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5263 . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5264 . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5265 . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5266 . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5268 . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5270 . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5271 . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5272 . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5274 . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5276 . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5277 . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5278 . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5281 . "<%quickmenu(admin/default)%>"
5283 . "<%elseif(adminaction,activate)%>"
5284 . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5285 . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5286 . "<%elseif(adminaction,activatesetpwd)%>"
5287 . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5289 . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5292 . "<!-- content / quickmenu container -->"
5293 . "<div class=\"clear\"></div>"
5296 . "<!-- adminwrapper -->"
5300 . "<p style=\"text-align:right;\"><%benchmark%></p>"
5305 $this->parser->parse($content);
5309 * AdminActions::selectBlog()
5310 * Inserts a HTML select element with choices for all blogs to which the user has access
5311 * mode = 'blog' => shows blognames and values are blogids
5312 * mode = 'category' => show category names and values are catids
5314 * @param string $name
5315 * @param string $mode
5316 * @param integer $selected
5317 * @param integer $tabindex
5318 * @param integer $showNewCat
5319 * @param integer $iForcedBlogInclude ID for weblog always included
5320 * @param $iForcedBlogInclude
5321 * ID of a blog that always needs to be included, without checking if the
5322 * member is on the blog team (-1 = none)
5325 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5327 global $member, $CONF;
5329 // 0. get IDs of blogs to which member can post items (+ forced blog)
5330 $aBlogIds = array();
5331 if ( $iForcedBlogInclude != -1 )
5333 $aBlogIds[] = intval($iForcedBlogInclude);
5336 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5338 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5339 $query = sprintf($query, sql_table('blog'));
5343 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5344 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5347 $rblogids = DB::getResult($query);
5348 foreach ( $rblogids as $row )
5350 if ( $row['bnumber'] != $iForcedBlogInclude )
5352 $aBlogIds[] = intval($row['bnumber']);
5356 if ( count($aBlogIds) == 0 )
5361 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5363 // 1. select blogs (we'll create optiongroups)
5364 // (only select those blogs that have the user on the team)
5365 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5366 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5367 $blogs = DB::getResult($queryBlogs);
5369 if ( $mode == 'category' )
5371 if ( $blogs->rowCount() > 1 )
5375 foreach ( $blogs as $rBlog )
5377 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5379 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5382 // show selection to create new category when allowed/wanted
5385 // check if allowed to do so
5386 if ( $member->blogAdminRights($rBlog['bnumber']) )
5388 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5392 // 2. for each category in that blog
5393 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5394 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5395 $categories = DB::getResult($catQuery);
5396 foreach ( $categories as $rCat )
5398 if ( $rCat['catid'] == $selected )
5400 $selectText = ' selected="selected" ';
5406 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5409 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5417 foreach ( $blogs as $rBlog )
5419 echo '<option value="' . $rBlog['bnumber'] . '"';
5420 if ( $rBlog['bnumber'] == $selected )
5422 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5426 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";