2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
12 /* NOTE: list of whole available action names for tags
21 'adminskineditallowedlist',
24 'adminskinselectoptions',
25 'adminspecialskinlist',
26 'admintemplateoverview',
27 'allowedadminskinactions',
50 'configsettingsyesno',
53 'defaultadminskintypes',
63 'editadmintemplateinfo',
69 'editplugoptionslist',
85 'insertpluginoptions',
90 'listplugplugoptionrow',
91 'localeselectoptions',
108 'selectlocaladminskinfiles',
109 'selectlocalskinfiles',
110 'skineditallowedlist',
127 * AdminActions::$default_actions
128 * list of whole action names with which this class can deal
130 static private $default_actions = array(
153 * AdminActions::$skin_type_friendly_names
154 * friendly name for wrapped page types
156 static private $default_skin_types = array(
157 'actionlog' => _ADM_SKPRT_ACTIONLOG,
158 'activate' => _ADM_SKPRT_ACTIVATE,
159 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
160 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
161 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
162 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
163 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
164 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
165 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
166 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
167 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
168 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
169 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
170 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
171 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
172 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
173 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
174 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
175 'banlist' => _ADM_SKPRT_BANLIST,
176 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
177 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
178 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
179 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
180 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
181 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
182 'batchitem' => _ADM_SKPRT_BATCHITEM,
183 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
184 'batchmove' => _ADM_SKPRT_BATCHMOVE,
185 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
186 'batchteam' => _ADM_SKPRT_BATCHTEAM,
187 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
188 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
189 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
190 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
191 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
192 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
193 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
194 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
195 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
196 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
197 'createitem' => _ADM_SKPRT_CREATEITEM,
198 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
199 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
200 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
201 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
202 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
203 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
204 'itemedit' => _ADM_SKPRT_ITEMEDIT,
205 'itemlist' => _ADM_SKPRT_ITEMLIST,
206 'itemmove' => _ADM_SKPRT_ITEMMOVE,
207 'login' => FALSE, //missing
208 'manage' => _ADM_SKPRT_MANAGE,
209 'manageteam' => _ADM_SKPRT_MANAGETEAM,
210 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
211 'memberedit' => FALSE, //missing
212 'overview' => _ADM_SKPRT_OVERVIEW,
213 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
214 'pagehead' => _ADM_SKPRT_PAGEHEAD,
215 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
216 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
217 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
218 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
219 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
220 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
221 'skindelete' => _ADM_SKPRT_SKINDELETE,
222 'skinedit' => _ADM_SKPRT_SKINEDIT,
223 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
224 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
225 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
226 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
227 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
228 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
229 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
230 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
231 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
232 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
233 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
234 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
238 * AdminActions::getAvailableSkinTypes()
242 * @return array list of friendly names for page actions
244 static public function getAvailableSkinTypes()
246 return self::$default_skin_types;
250 * AdminActions::getDefaultTypes()
254 * @return array list of friendly names for page actions
256 static public function getDefaultTypes()
258 return self::$default_skin_types;
262 * AdminActions::__construct()
263 * Constructor for a new Actions object
265 * @param string $type
268 public function __construct($type)
270 // call constructor of superclass first
271 parent::__construct();
272 $this->skintype = $type;
273 if ( !class_exists('Navlist') || !class_exists('Batch') )
276 include $DIR_LIBS . 'ENCAPSULATE.php';
282 * AdminActions::getAvailableActions()
285 * @return array allowed actions for the page type
287 public function getAvailableActions()
289 $extra_actions = array();
291 switch ( $this->skintype )
294 $extra_actions = array(
299 $extra_actions = array(
304 case 'activatesetpwd':
305 $extra_actions = array(
309 $extra_actions = array(
315 case 'adminerrorpage':
316 $extra_actions = array(
319 case 'adminskindelete':
320 $extra_actions = array(
324 case 'adminskinedit':
325 $extra_actions = array(
327 'defaultadminskintypes',
328 'adminspecialskinlist',
331 case 'adminskinedittype':
332 $extra_actions = array(
335 'allowedadminskinactions',
336 'adminskineditallowedlist',
339 case 'adminskiniedoimport':
340 $extra_actions = array(
344 case 'adminskinieimport':
345 $extra_actions = array(
349 case 'adminskinieoverview':
350 $extra_actions = array(
351 'selectlocaladminskinfiles',
355 case 'adminskinoverview':
356 $extra_actions = array(
360 case 'adminskinremovetype':
361 $extra_actions = array(
365 case 'admintemplatedelete':
366 $extra_actions = array(
367 'editadmintemplateinfo',
369 case 'admintemplateedit':
370 $extra_actions = array(
371 'editadmintemplateinfo',
374 case 'admntemplateoverview':
375 $extra_actions = array(
376 'admintemplateoverview',
379 case 'backupoverview':
380 $extra_actions = array(
383 case 'backuprestore':
384 $extra_actions = array(
388 $extra_actions = array(
394 case 'banlistdelete':
395 $extra_actions = array(
400 case 'banlistdeleteconfirm':
401 $extra_actions = array(
402 'banlistdeletedlist',
407 $extra_actions = array(
413 case 'batchcategory':
414 $extra_actions = array(
420 $extra_actions = array(
426 $extra_actions = array(
432 $extra_actions = array(
438 $extra_actions = array(
444 $extra_actions = array(
453 $extra_actions = array(
462 $extra_actions = array(
468 case 'blogcommentlist':
469 $extra_actions = array(
475 case 'blogselectbox':
476 $extra_actions = array(
481 $extra_actions = array(
497 $extra_actions = array(
501 case 'browseowncomments':
502 $extra_actions = array(
506 case 'browseownitems':
507 $extra_actions = array(
511 case 'categorydelete':
512 $extra_actions = array(
518 $extra_actions = array(
525 case 'commentdelete':
526 $extra_actions = array(
531 $extra_actions = array(
536 $extra_actions = array(
548 $extra_actions = array(
554 $extra_actions = array(
559 case 'editmembersettings':
560 $extra_actions = array(
561 'adminskinselectoptions',
563 'localeselectoptions',
567 case 'insertpluginoptions':
568 $extra_actions = array(
569 'insertpluginoptions',
572 case 'itemcommentlist':
573 $extra_actions = array(
579 $extra_actions = array(
586 $extra_actions = array(
598 $extra_actions = array(
605 $extra_actions = array(
611 $extra_actions = array(
615 $extra_actions = array(
624 $extra_actions = array(
629 $extra_actions = array(
634 $extra_actions = array(
639 $extra_actions = array(
645 $extra_actions = array(
650 case 'pluginoptions':
651 $extra_actions = array(
653 'editplugoptionslist',
657 $extra_actions = array(
660 'configsettingsedit',
661 'configsettingsyesno',
664 'localeselectoptions',
670 $extra_actions = array(
675 $extra_actions = array(
680 $extra_actions = array(
686 $extra_actions = array(
689 'allowedskinactions',
690 'skineditallowedlist',
691 'skineditallowedlist',
694 case 'skiniedoimport':
695 $extra_actions = array(
700 $extra_actions = array(
704 case 'skinieoverview':
705 $extra_actions = array(
706 'selectlocalskinfiles',
711 $extra_actions = array(
715 case 'skinremovetype':
716 $extra_actions = array(
720 case 'systemoverview':
721 $extra_actions = array(
726 $extra_actions = array(
732 case 'templatedelete':
733 $extra_actions = array(
738 $extra_actions = array(
742 case 'templateoverview':
743 $extra_actions = array(
747 case 'usermanagement':
748 $extra_actions = array(
754 $extra_actions = array(
764 'selectlocaladminskinfiles',
772 $defined_actions = array_merge(self::$default_actions, $extra_actions);
774 return array_merge($defined_actions, parent::getAvailableActions());
778 * AdminActions::parse_actionloglist()
779 * Parse skinvar actionloglist
781 * @param string $templateName name of template to use
784 public function parse_actionloglist($templateName = '')
786 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
787 $query = sprintf($query, sql_table('actionlog'));
789 $template['content'] = 'actionlist';
790 $amount = showlist($query, 'table', $template, $templateName);
796 * AdminActions::parse_activationmessage()
797 * Parse skinvar activationmessage
799 * @param string $type type of message
800 * @param string $templateName name of template to use
803 public function parse_activationmessage($type, $templateName = '')
805 global $CONF, $manager;
809 if ( !empty($templateName))
811 $template = Template::read($templateName);
814 $key = postVar('ackey');
817 Admin::error(_ERROR_ACTIVATE);
820 $info = MEMBER::getActivationInfo($key);
823 Admin::error(_ERROR_ACTIVATE);
826 $mem = MEMBER::createFromId($info->vmember);
829 Admin::error(_ERROR_ACTIVATE);
831 switch ( $info->vtype )
834 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
836 $title = $template['ACTIVATE_FORGOT_TITLE'];
840 $title = _ACTIVATE_FORGOT_TITLE;
842 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
844 $text = $template['ACTIVATE_FORGOT_TEXT'];
848 $text = _ACTIVATE_FORGOT_TEXT;
852 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
854 $title = $template['ACTIVATE_REGISTER_TITLE'];
858 $title = _ACTIVATE_REGISTER_TITLE;
860 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
862 $text = $template['ACTIVATE_REGISTER_TEXT'];
866 $text = _ACTIVATE_REGISTER_TEXT;
869 case 'addresschange':
870 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
872 $title = $template['ACTIVATE_CHANGE_TITLE'];
876 $title = _ACTIVATE_CHANGE_TITLE;
878 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
880 $text = $template['ACTIVATE_CHANGE_TEXT'];
884 $text = _ACTIVATE_CHANGE_TEXT;
889 'memberName' => Entity::hsc($mem->getDisplayName()),
890 'realName' => Entity::hsc($mem->getRealName()),
895 echo Template::fill($title, $aVars);
898 echo Template::fill($text, $aVars);
901 echo Entity::hsc($key);
908 * AdminActions::parse_addtickettourl()
909 * Parse skinvar addtickettourl
911 * @param string $url URI for ticket
914 public function parse_addtickettourl($url)
917 $url = $manager->addTicketToUrl($url);
918 echo Entity::hsc($url);
923 * AdminActions::parse_adminbanlist()
924 * Parse skinvar adminbanlist
926 * @param string $templateName name of template to use
929 public function parse_adminbanlist($templateName = '')
931 $blogid = intRequestVar('blogid');
933 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
934 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
936 $template['content'] = 'banlist';
938 $amount = Showlist($query, 'table', $template, $templateName);
948 * AdminActions::parse_adminbatchaction()
949 * Parse skinvar adminbatchaction
954 public function parse_adminbatchaction()
956 echo Entity::hsc(requestVar('batchaction'));
961 * AdminActions::parse_adminbatchlist()
962 * Parse skinvar adminbatchlist
964 * @param string $templateName name of template to use
967 public function parse_adminbatchlist($templateName = '')
970 $templates = array();
972 if ( !empty($templateName) )
974 $templates = Template::read($templateName);
977 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
979 $template = '<li><%text(_BATCH_EXECUTING)%> '
980 . '<b><%adminbatchaction%></b> '
981 . '<%batchlisttype%> '
982 . '<b><%batchid%></b>... '
983 . '<b><%batchlistmsg%></b>'
988 $template = $templates['ADMIN_BATCHLIST'];
991 $selected = requestIntArray('batch');
992 $action = requestVar('batchaction');
994 switch ( $this->skintype )
997 $batchlisttype = _BATCH_ONITEM;
998 $deleteaction = 'deleteOneItem';
999 $moveaction = 'moveOneItem';
1000 $destid = intRequestVar('destcatid');
1002 case 'batchcomment':
1003 $batchlisttype = _BATCH_ONCOMMENT;
1004 $deleteaction = 'deleteOneComment';
1007 $batchlisttype = _BATCH_ONMEMBER;
1008 $deleteaction = 'deleteOneMember';
1009 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1010 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1011 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1012 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1015 $blogid = intRequestVar('blogid');
1016 $batchlisttype = _BATCH_ONTEAM;
1017 $deleteaction = 'deleteOneTeamMember';
1018 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1019 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1020 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1021 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1023 case 'batchcategory':
1024 $batchlisttype = _BATCH_ONCATEGORY;
1025 $deleteaction = 'deleteOneCategory';
1026 $moveaction = 'moveOneCategory';
1027 $destid = intRequestVar('destblogid');
1031 // walk over all selectedids and perform action
1032 foreach ( $selected as $selectedid )
1035 $selectedid = intval($selectedid);
1039 if ( $this->skintype != 'batchteam' )
1041 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1045 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1049 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1053 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1057 // there should always remain at least one super-admin
1058 $r = DB::getResult($unsetchksql);
1059 if ( $r->rowCount() < 2 )
1061 $error = $unseterrmsg;
1065 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1069 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1073 'batchid' => $selectedid,
1074 'batchlisttype' => Entity::hsc($batchlisttype),
1075 'adminbatchaction' => Entity::hsc($action),
1076 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1079 $handler = new AdminActions('template');
1080 $parser = new Parser($handler);
1082 $output = Template::fill($template, $data);
1084 $parser->parse($output);
1085 $output = ob_get_contents();
1087 echo "{$output}<br />";
1093 * AdminActions::parse_adminbloglink()
1094 * Parse skinvar adminbloglink
1096 * @param string $templateName name of template to use
1099 public function parse_adminbloglink($templateName = '')
1102 $blogid = intRequestVar('blogid');
1103 $blog =& $manager->getBlog($blogid);
1104 $templates = array();
1106 if ( !empty($templateName) )
1108 $templates = Template::read($templateName);
1111 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1113 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1117 $template = $templates['ADMIN_BLOGLINK'];
1121 'url' => Entity::hsc($blog->getURL()),
1122 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1123 'blogname' => Entity::hsc($blog->getName())
1126 echo Template::fill($template, $data);
1131 * AdminActions::parse_adminerrormesg()
1132 * Parse skinvar adminerrormesg
1137 public function parse_adminerrormesg()
1142 if ( requestVar('errormessage') )
1144 $message = requestVar('errormessage');
1146 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1148 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1150 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1152 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1154 echo Entity::hsc($message);
1159 * AdminActions::parse_adminskineditallowedlist()
1160 * Parse skinvar adminskineditallowedlist
1162 * @param string $type template/blog
1163 * @param string $templateName name of template to use
1166 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1170 /* TODO: blog seems not to be used */
1172 $query = "SELECT bshortname, bname FROM %s";
1173 $query = sprintf($query, sql_table('blog'));
1175 'content' => 'shortblognames'
1177 Showlist($query, 'table', $show, $templateName);
1180 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1181 $query = sprintf($query, sql_table('template_desc'));
1183 'content' => 'shortnames'
1185 Showlist($query, 'table', $show, $templateName);
1192 * AdminActions::parse_adminskinielist()
1193 * Parse skinvar adminskinielist
1195 * @param string $type skin/template
1196 * @param string $templateName name of template to use
1199 public function parse_adminskinielist($type, $templateName = '')
1201 $templates = array();
1202 if ( $templateName )
1204 $templates = Template::read($templateName);
1207 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1210 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1211 . "<label for=\"<%expid%>\"><%expname%></label>"
1213 . "<td><%expdesc%></td>\n"
1219 $template = $templates['SKINIE_EXPORT_LIST'];
1225 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1226 $query = sprintf($query, sql_table('skin_desc'));
1227 $res = DB::getResult($query);
1229 foreach ( $res as $row )
1232 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1233 'expid' => 'skinexp' . $row['sdnumber'],
1234 'expname' => Entity::hsc($row['sdname']),
1235 'expdesc' => Entity::hsc($row['sddesc']),
1237 echo Template::fill($template, $data);
1241 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1242 $query = sprintf($query, sql_table('template_desc'));
1243 $res = DB::getResult($query);
1244 foreach ( $res as $row )
1247 'typeid' => 'template[' . $row['tdnumber'] . ']',
1248 'expid' => 'templateexp' . $row['tdnumber'],
1249 'expname' => Entity::hsc($row['tdname']),
1250 'expdesc' => Entity::hsc($row['tddesc']),
1252 echo Template::fill($template, $data);
1260 * AdminActions::parse_adminskinoverview()
1261 * Parse skinvar adminskinoverview
1263 * @param string $templateName name of template to use
1266 public function parse_adminskinoverview($templateName = '')
1268 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1269 $query = sprintf($query, sql_table('skin_desc'));
1271 $template['content'] = 'adminskinlist';
1272 $template['tabindex'] = 10;
1273 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1274 Showlist($query, 'table', $template, $templateName);
1279 * AdminActions::parse_adminskinselectoptions()
1280 * Parse skinvar adminskinselectoptions
1285 public function parse_adminskinselectoptions($templateName = '')
1288 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1289 $query = sprintf($query, sql_table('skin_desc'));
1291 $template['name'] = 'adminskin';
1292 $template['selected'] = $CONF['AdminSkin'];
1293 $template['tabindex'] = 110;
1294 Showlist($query, 'select', $template, $templateName);
1299 * AdminActions::parse_adminspecialskinlist()
1300 * Parse skinvar adminspecialskinlist
1302 * @param string $templateName name of template to use
1304 public function parse_adminspecialskinlist($templateName = '')
1306 $templates = array();
1307 if ( $templateName )
1309 $templates = Template::read($templateName);
1312 $nType = $this->parser->skin->getAvailableTypes();
1313 $skinid = intRequestVar('skinid');
1315 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1316 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1318 $res = DB::getResult($query);
1319 if ( $res && $res->rowCount() > 0 )
1321 /* NOTE: set templates for HEAD/BODY/FOOT */
1322 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1324 $template['head'] = "<ul>\n";
1328 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1330 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1332 $template['body'] = '<li>'
1333 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1336 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1343 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1345 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1347 $template['foot'] = "</ul>\n";
1351 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1358 echo $template['head'];
1359 foreach ( $res as $row )
1362 'tabindex' => $tabstart++,
1363 'skinid' => $skinid,
1364 'skintype' => Entity::hsc(strtolower($row['stype']))
1366 echo Template::fill($template['body'], $data);
1369 echo $template['foot'];
1375 * AdminActions::parse_admintemplateoverview()
1376 * Parse skinvar admintemplateoverview
1378 * @param string $templateName name of template to use
1381 public function parse_admintemplateoverview($templateName = '')
1383 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1384 $query = sprintf($query, sql_table('template_desc'));
1386 $template['content'] = 'admintemplatelist';
1387 $template['tabindex'] = 10;
1389 Showlist($query, 'table', $template, $templateName);
1394 * AdminActions::parse_allowedadminskinactions()
1395 * Parse skinvar allowedadminskinactions
1400 public function parse_allowedadminskinactions()
1402 global $DIR_ADMINSKINS;
1403 $skinType = strtolower(trim(requestVar('type')));
1404 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1407 while ( $current = array_shift($actions) )
1409 // TODO: remove this
1410 // skip deprecated vars
1411 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1416 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1418 if ( count($actions) != 0 )
1427 * AdminActions::parse_allowedskinactions()
1428 * Parse skinvar allowedskinactions
1433 public function parse_allowedskinactions()
1435 $skinType = strtolower(trim(requestVar('type')));
1436 $skinid = intRequestVar('skinid');
1438 $skin = new Skin($skinid);
1439 $actions = $skin->getAllowedActionsForType($skinType);
1442 while ( $current = array_shift($actions) )
1444 // TODO: remove this
1445 // skip deprecated vars
1446 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1451 /* TODO: alternative function should be used or not? */
1452 echo helplink("skinvar-{$current}") . "$current</a>\n";
1454 if ( count($actions) != 0 )
1463 * AdminActions::parse_banlistdeletedlist()
1464 * Parse skinvar banlistdeletedlist
1466 * @param string $templateName name of template to use
1469 public function parse_banlistdeletedlist($templateName = '')
1473 $templates = array();
1474 if ( $templateName )
1476 $templates = Template::read($templateName);
1479 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1481 $template = "<li><%blogname%></li>\n";
1485 $template = $templates['BANLIST_DELETED_LIST'];
1488 $deleted = requestArray('delblogs');
1489 foreach ( $deleted as $delblog )
1491 $blog =& $manager->getBlog($delblog);
1493 'blogname' => Entity::hsc($blog->getName())
1495 echo Template::fill($template, $data);
1502 * AdminActions::parse_batchdeletelist()
1503 * Parse skinvar batchdeletelist
1508 public function parse_batchdeletelist()
1510 $selected = requestIntArray('batch');
1513 foreach ( $selected as $select )
1515 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1517 // add hidden vars for team & comment
1518 if ( requestVar('action') == 'batchteam' )
1520 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1522 if ( requestVar('action') == 'batchcomment' )
1524 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1530 * AdminActions::parse_batchdeletetype()
1531 * Parse skinvar batchdeletetype
1536 public function parse_batchdeletetype()
1538 echo Entity::hsc(requestVar('action'));
1543 * AdminActions::parse_batchmovebtn()
1544 * Parse skinvar batchmovebtn
1549 public function parse_batchmovebtn()
1551 $actionType = requestVar('action');
1552 switch ( $actionType )
1557 case 'batchcategory':
1565 * AdminActions::parse_batchmovelist()
1566 * Parse skinvar batchmovelist
1571 public function parse_batchmovelist()
1573 $selected = requestIntArray('batch');
1575 foreach ( $selected as $select )
1577 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1584 * AdminActions::parse_batchmovetitle()
1585 * Parse skinvar batchmovetitle
1590 public function parse_batchmovetitle()
1592 $actionType = requestVar('action');
1593 switch ( $actionType )
1598 case 'batchcategory':
1599 echo _MOVECAT_TITLE;
1606 * AdminActions::parse_batchmovetype()
1607 * Parse skinvar batchmovetype
1612 public function parse_batchmovetype()
1614 echo Entity::hsc(requestVar('action'));
1619 * AdminActions::parse_blogcatlist()
1620 * Parse skinvar blogcatlist
1625 public function parse_blogcatlist($templateName = '')
1628 $blogid = intRequestVar('blogid');
1629 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1630 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1632 $template['content'] = 'categorylist';
1633 $template['tabindex'] = 200;
1635 $batch = new Batch('category');
1636 $batch->showlist($query, 'table', $template, $templateName);
1641 * AdminActions::parse_blogid()
1642 * Parse skinvar blogid
1647 public function parse_blogid()
1649 echo intRequestVar('blogid');
1654 * AdminActions::parse_blognotifysetting()
1655 * Parse skinvar blognotifysetting
1660 public function parse_blognotifysetting($type)
1663 $blogid = intRequestVar('blogid');
1664 $blog = $manager->getBlog($blogid);
1669 if ( !$blog->notifyOnComment() )
1675 if ( !$blog->notifyOnVote() )
1681 if ( !$blog->notifyOnNewItem() )
1687 echo ' checked="checked"';
1692 * AdminActions::parse_blogselectbox()
1693 * Parse skinvar blogselectbox
1698 public function parse_blogselectbox()
1702 $selectData = requestVar('selectData');
1703 $mode = $selectData['mode'];
1704 $name = Entity::hsc($selectData['name']);
1705 $tabindex = Entity::hsc($selectData['tabindex']);
1706 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1707 $showNewCat = intval($selectData['showNewCat']);
1708 $selected = intval($selectData['selected']);
1710 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1712 // 1. select blogs (we'll create optiongroups)
1713 // (only select those blogs that have the user on the team)
1714 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1715 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1716 $blogs = DB::getResult($queryBlogs);
1718 if ( $mode == 'category' )
1720 if ( $blogs->rowCount() > 1 )
1724 foreach ( $blogs as $rBlog )
1726 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1728 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
1731 // show selection to create new category when allowed/wanted
1734 // check if allowed to do so
1735 if ( $member->blogAdminRights($rBlog['bnumber']) )
1737 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
1741 // 2. for each category in that blog
1742 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1743 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
1744 $categories = DB::getResult($catQuery);
1745 foreach ( $categories as $rCat )
1747 if ( $rCat['catid'] == $selected )
1749 $selectText = ' selected="selected" ';
1755 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
1758 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1767 foreach ( $blogs as $rBlog )
1769 echo '<option value="' . $rBlog['bnumber'] . '"';
1770 if ( $rBlog['bnumber'] == $selected )
1772 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1776 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1785 * AdminActions::parse_blogsetting()
1786 * Parse skinvar blogsetting
1788 * @param string $which name of weblog setting
1791 public function parse_blogsetting($which)
1793 echo $this->parse_getblogsetting($which);
1798 * AdminActions::parse_blogsettingyesno()
1799 * Parse skinvar blogsettingyesno
1801 * @param string $type type of weblog setting
1802 * @param string $templateName name of template to use
1805 public function parse_blogsettingyesno($type, $templateName = '')
1809 $blogid = intRequestVar('blogid');
1810 $blog = $manager->getBlog($blogid);
1814 case 'convertbreaks':
1815 $checkedval = $blog->convertBreaks();
1818 case 'allowpastposting':
1819 $checkedval = $blog->allowPastPosting();
1823 $checkedval = $blog->commentsEnabled();
1827 $checkedval = $blog->isPublic();
1831 $checkedval = $blog->emailRequired();
1835 $checkedval = $blog->getSearchable();
1839 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1844 * AdminActions::parse_blogteamlist()
1845 * Parse skinvar blogteamlist
1847 * @param string $templateName name of template to use
1850 public function parse_blogteamlist($templateName = '')
1853 $blogid = intRequestVar('blogid');
1854 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1856 . "WHERE tmember=mnumber AND tblog= %d";
1857 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1859 $template['content'] = 'teamlist';
1860 $template['tabindex'] = 10;
1862 $batch = new Batch('team');
1863 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1868 * AdminActions::parse_blogteammembers()
1869 * Parse skinvar blogteammembers
1874 public function parse_blogteammembers()
1876 $blogid = intRequestVar('blogid');
1877 $query = "SELECT mname, mrealname "
1879 . "WHERE mnumber=tmember AND tblog=%d;";
1880 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1881 $res = DB::getResult($query);
1882 $memberNames = array();
1883 foreach ( $res as $row )
1885 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1887 echo implode(',', $memberNames);
1891 * AdminActions::parse_blogtime()
1892 * Parse skinvar blogtime
1894 * @param string $type type of time
1895 * @param string $format format for time expression
1896 * @param integer $offset offset of time
1899 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1903 if ( $type != 'blogtime' )
1905 /* return server time */
1906 $timestamp = time() + $offset;
1910 $bid = intRequestVar('blogid');
1911 $b = $manager->getBlog($bid);
1912 $timestamp = $b->getCorrectTime() + $offset;
1915 echo i18n::formatted_datetime($format, $timestamp);
1920 * AdminActions::parse_bookmarkletadmin()
1921 * Parse skinvar bookmarkletadmin
1926 public function parse_bookmarkletadmin()
1930 $blogid = intRequestVar('blogid');
1932 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1937 * AdminActions::parse_categories()
1938 * Parse skinvar categories
1940 * create category dropdown box
1942 * @param string $type name of setting for category
1945 public function parse_categories($startidx = 0)
1950 $itemid = intRequestVar('itemid');
1951 $item = &$manager->getItem($itemid, 1, 1);
1956 $blogid = intRequestVar('blogid');
1960 $blogid = $item['blogid'];
1962 $blog = &$manager->getBlog($blogid);
1964 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1966 $item['body'] = removeBreaks($item['body']);
1967 $item['more'] = removeBreaks($item['more']);
1970 $contents = array();
1971 if ( requestVar('action') == 'itemedit' )
1976 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1979 $catid = $blog->getDefaultCategory();
1984 $catid = $contents['catid'];
1987 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1993 * AdminActions::parse_category()
1994 * Parse skinvar category
1996 * @param string $type name of setting for category
1999 public function parse_category($type = 'name')
2001 echo $this->parse_getcategory($type);
2006 * AdminActions::parse_categorysetting()
2007 * Parse skinvar categorysetting
2009 * @param string $type type in category setting
2012 public function parse_categorysetting($type)
2014 $catid = intRequestVar('catid');
2015 if ( $type == 'id' )
2020 $blogid = intRequestVar('blogid');
2021 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2022 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2023 $row = DB::getRow($query);
2025 if ( $type != 'name' )
2027 echo Entity::hsc($row['cdesc']);
2031 echo Entity::hsc($row['cname']);
2038 * AdminActions::parse_codename()
2039 * Parse templatevar codename
2045 public function parse_checkedonval($value, $name)
2050 $itemid = intRequestVar('itemid');
2051 $item =& $manager->getItem($itemid, 1, 1);
2053 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2055 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
2057 $item['body'] = removeBreaks($item['body']);
2058 $item['more'] = removeBreaks($item['more']);
2061 $contents = array();
2062 if ( requestVar('action') == 'itemedit' )
2066 if ( !isset($contents[$name]) )
2068 $contents[$name] = '';
2070 if ($contents[$name] == $value)
2072 echo 'checked="checked"';
2078 * AdminActions::parse_codename()
2079 * Parse templatevar codename
2084 * TODO: is this need???
2086 public function parse_codename()
2089 echo $nucleus['codename'];
2094 * AdminActions::parse_commentnavlist()
2095 * Parse skinvar commentnavlist
2100 public function parse_commentnavlist()
2102 global $CONF, $manager, $member;
2105 if ( postVar('start') )
2107 $start = intPostVar('start');
2114 // amount of items to show
2115 if ( postVar('amount') )
2117 $amount = intPostVar('amount');
2121 $amount = (integer) $CONF['DefaultListSize'];
2127 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2129 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2131 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2133 if ( $this->skintype == 'itemcommentlist' )
2135 $itemid = intRequestVar('itemid');
2136 $query .= " citem={$itemid}";
2137 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2139 $nonComments = _NOCOMMENTS;
2141 elseif ( $this->skintype == 'browseowncomments' )
2144 $query .= ' cmember=' . $member->getID();
2145 $template['canAddBan'] = 0;
2147 $nonComments = _NOCOMMENTS_YOUR;
2149 elseif ( $this->skintype == 'blogcommentlist' )
2152 $query .= ' cblog=' . intRequestVar('blogid');
2153 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2154 $bid = intRequestVar('blogid');
2155 $nonComments = _NOCOMMENTS_BLOG;
2158 $search = postVar('search');
2159 if ( !empty($search) )
2161 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2164 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2166 $template['content'] = 'commentlist';
2168 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2169 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2174 * AdminActions::parse_configsettingsedit()
2175 * Parse skinvar configsettingsedit
2177 * @param string $type type of global configuration
2180 public function parse_configsettingsedit($type)
2185 case 'DefaultListSize':
2186 if ( !array_key_exists('DefaultListSize', $CONF) )
2188 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2189 $query = sprintf($query, sql_table('config'));
2190 DB::execute($query);
2191 $CONF['DefaultListSize'] = 10;
2193 elseif ( intval($CONF['DefaultListSize']) < 1 )
2195 $CONF['DefaultListSize'] = 10;
2197 echo intval($CONF['DefaultListSize']);
2199 case 'SessionCookie':
2200 $value = $CONF['SessionCookie'];
2201 $txt1 = _SETTINGS_COOKIESESSION;
2202 $txt2 = _SETTINGS_COOKIEMONTH;
2203 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2206 $value = $CONF['URLMode'];
2207 $txt1 = _SETTINGS_URLMODE_NORMAL;
2208 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2209 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2212 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2214 echo Entity::hsc($CONF[$type]);
2222 * AdminActions::parse_configsettingsyesno()
2223 * Parse skinvar configsettingsyesno
2225 * @param string $type type of global setting
2226 * @param integer $tabindex tabindex attribute of input element
2229 public function parse_configsettingsyesno($type, $tabindex)
2232 if ( array_key_exists($type, $CONF) )
2234 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2240 * AdminActions::parse_contents()
2241 * Parse skinvar contents
2243 * @param string $which part for item
2246 public function parse_contents($which)
2251 $contents = array();
2253 if ( requestVar('action') == 'itemedit' )
2255 $itemid = intRequestVar('itemid');
2256 $item =& $manager->getItem($itemid, 1, 1);
2258 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2260 if ( $item && $blog->convertBreaks() )
2262 $item['body'] = removeBreaks($item['body']);
2263 $item['more'] = removeBreaks($item['more']);
2267 elseif ( requestVar('action') == 'createitem' )
2269 $blogid = intRequestVar('blogid');
2270 $blog =& $manager->getBlog($blogid);
2274 'contents' => &$contents,
2280 if ( !array_key_exists($which, $contents) )
2282 $contents[$which] = '';
2284 echo Entity::hsc($contents[$which],ENT_QUOTES);
2288 * AdminActions::parse_currenttime()
2289 * Parse skinvar currenttime
2291 * @param string $what
2294 public function parse_currenttime($what)
2297 if ( requestVar('action') == 'itemedit' )
2299 $itemid = intRequestVar('itemid');
2300 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2302 elseif ( requestVar('action') == 'createitem' )
2304 $blog =& $manager->getBlog(intRequestVar('blogid'));
2306 $nu = getdate($blog->getCorrectTime());
2311 * AdminActions::parse_customhelplink()
2312 * Parse skinvar customhelplink
2314 * @param string $topic name of topic
2315 * @param string $tplName name of template
2316 * @param string $url string as URI
2317 * @param string $iconURL string as URI for icon
2318 * @param string $alt alternative text for image element
2319 * @param string $title title for anchor element
2322 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2324 $this->customHelp($topic, $url, $iconURL);
2329 * AdminActions::parse_date()
2330 * Parse skinvar date
2332 public function parse_date($format = 'c')
2334 global $CONF, $manager;
2335 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2340 * AdminActions::parse_defaultadminskintypes()
2341 * Parse skinvar defaultadminskintypes
2343 * @param string $tabindex index number for tabindex attribute of input element
2344 * @param string $templateName name of template
2347 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2349 $templates = array();
2351 if ( $templateName )
2353 $templates = Template::read($templateName);
2356 $types = $this->parser->skin->getAvailableTypes();
2359 /* NOTE: set templates for HEAD/BODY/FOOT */
2360 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2362 $template['head'] = "<ul>\n";
2366 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2368 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2370 $template['body'] = "<li>"
2371 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2376 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2378 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2380 $template['foot'] = "</ul>\n";
2384 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2387 $handler = new AdminActions('template');
2388 $parser = new PARSER($handler);
2390 /* NOTE: do output */
2391 echo $template['head'];
2392 foreach ( $types as $type => $fName )
2394 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2396 'tabindex' => $tabindex,
2397 'skintype' => $type,
2399 'help' => $helplink,
2400 'skinid' => intrequestVar('skinid'),
2402 $parser->parse(Template::fill($template['body'], $data));
2405 echo $template['foot'];
2411 * AdminActions::parse_defblogselect()
2412 * Parse skinvar defblogselect
2414 * @param string $templateName name of template
2417 public function parse_defblogselect($templateName = '')
2421 $query = "SELECT bname as text, bnumber as value FROM %s;";
2422 $query = sprintf($query, sql_table('blog'));
2424 $template['name'] = 'DefaultBlog';
2425 $template['selected'] = $CONF['DefaultBlog'];
2426 $template['tabindex'] = 10;
2428 Showlist($query, 'select', $template, $templateName);
2434 * AdminActions::parse_defcatselect()
2435 * Parse skinvar defcatselect
2437 * @param string $templateName name of template
2440 public function parse_defcatselect($templateName = '')
2444 $blogid = intRequestVar('blogid');
2445 $blog = $manager->getBlog($blogid);
2447 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2448 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2450 $template['name'] = 'defcat';
2451 $template['selected'] = $blog->getDefaultCategory();
2452 $template['tabindex'] = 110;
2454 Showlist($query, 'select', $template, $templateName);
2460 * AdminActions::parse_defskinselect()
2461 * Parse skinvar defskinselect
2463 * @param string $type type of skin
2464 * @param string $templateName name of template
2467 public function parse_defskinselect($type = 'blog', $templateName = '')
2469 global $CONF, $manager;
2471 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2472 $query = sprintf($query, sql_table('skin_desc'));
2474 $blogid = intRequestVar('blogid');
2478 $template['selected'] = $CONF['BaseSkin'];
2482 $blog = $manager->getBlog($blogid);
2483 $template['selected'] = $blog->getDefaultSkin();
2486 if ( $type != 'blog' )
2488 $nname = 'BaseSkin';
2495 $template['name'] = $nname;
2496 $template['tabindex'] = 50;
2498 Showlist($query, 'select', $template, $templateName);
2504 * AdminActions::parse_deletecomment()
2505 * Parse skinvar deletecomment
2507 * @param string $type type of infomation for comment
2510 public function parse_deletecomment($type = 'id')
2512 $commentid = intRequestVar('commentid');
2513 $comment = COMMENT::getComment($commentid);
2518 echo intRequestVar('commentid');
2521 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2523 echo $comment['member'];
2527 echo $comment['user'];
2531 $body = strip_tags($comment['body']);
2532 echo Entity::hsc(shorten($body, 300, '...'));
2538 * AdminActions::parse_deleteitembody()
2539 * Parse skinvar deleteitembody
2544 public function parse_deleteitembody()
2548 $itemid = intRequestVar('itemid');
2549 $item =& $manager->getItem($itemid, 1, 1);
2551 $body = strip_tags($item['body']);
2553 echo Entity::hsc(shorten($body, 300, '...'));
2559 * AdminActions::parse_deleteitemid()
2560 * Parse skinvar deleteitemid
2565 public function parse_deleteitemid()
2567 echo (integer) intRequestVar('itemid');
2572 * AdminActions::parse_deleteitemtitle()
2573 * Parse skinvar deleteitemtitle
2578 public function parse_deleteitemtitle()
2582 $itemid = intRequestVar('itemid');
2583 $item =& $manager->getItem($itemid, 1, 1);
2585 echo Entity::hsc(strip_tags($item['title']));
2591 * AdminActions::parse_editadminskin()
2592 * Parse skinvar editadminskin
2594 * @param string $type type of skin setting
2597 public function parse_editadminskin($type = 'id')
2599 $skinid = intRequestVar('skinid');
2600 $skin = new Skin($skinid);
2604 echo intRequestVar('skinid');
2607 echo Entity::hsc($skin->getName());
2610 echo Entity::hsc($skin->getDescription());
2613 echo Entity::hsc($skin->getContentType());
2616 echo Entity::hsc($skin->getIncludePrefix());
2619 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2627 * AdminActions::parse_editadminskintype()
2628 * Parse skinvar editadminskintype
2630 * @param string $type name of skin type
2633 public function parse_editadminskintype($type = 'id')
2635 global $CONF, $manager, $member;
2637 $fNames = $this->parser->skin->getAvailableTypes();
2638 $sType = strtolower(trim(requestVar('type')));
2643 echo intRequestVar('skinid');
2646 echo Entity::hsc($this->parser->skin->getName());
2649 echo Entity::hsc($this->parser->skin->getDescription());
2652 echo Entity::hsc($this->parser->skin->getContentType());
2655 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2658 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2659 echo Entity::hsc($skinType);
2662 echo Entity::hsc($sType);
2665 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2668 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2669 echo Entity::hsc($incMode);
2678 * AdminActions::parse_editcomment()
2679 * Parse skinvar editcomment
2681 * @param string $type type of comment setting
2684 public function parse_editcomment($type = 'id')
2688 $commentid = intRequestVar('commentid');
2689 $comment = COMMENT::getComment($commentid);
2691 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2696 echo intRequestVar('commentid');
2699 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2701 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2705 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2709 echo date("Y-m-d @ H:i", $comment['timestamp']);
2712 $comment['body'] = str_replace('<br />', '', $comment['body']);
2713 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2714 echo $comment['body'];
2717 echo $comment['userid'];
2720 echo $comment['userid'];
2723 echo $comment[$type];
2730 * AdminActions::parse_editdesturl()
2731 * Parse skinvar editdesturl
2733 public function parse_editdesturl()
2735 if ( requestVar('desturl') )
2737 echo Entity::hsc(requestVar('desturl'));
2743 * AdminActions::parse_editmemberlist()
2744 * Parse skinvar editmemberlist
2746 * @param string $templateName name of template
2749 public function parse_editmemberlist($templateName = '')
2752 // show list of members with actions
2753 $query = 'SELECT * FROM '.sql_table('member');
2754 $template['content'] = 'memberlist';
2755 $template['tabindex'] = 10;
2757 $batch = new Batch('member');
2758 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2763 * AdminActions::parse_editmember()
2764 * Parse skinvar editmember
2766 * @param string $type type of information for member
2767 * @return string $tempateName name of template to use
2770 public function parse_editmember($type = 'id', $templateName = '')
2772 global $CONF, $manager, $member;
2774 $memberid = intRequestVar('memberid');
2775 $mem = MEMBER::createFromID($memberid);
2780 echo intRequestVar('memberid');
2783 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2785 echo Entity::hsc($mem->getDisplayName());
2789 $dispName = Entity::hsc($mem->getDisplayName());
2790 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2792 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2801 echo Entity::hsc($mem->getRealName());
2804 echo Entity::hsc($mem->getEmail());
2807 echo Entity::hsc($mem->getURL());
2810 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2813 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2816 echo Entity::hsc($mem->getNotes());
2819 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2828 * AdminActions::parse_editpluginfo()
2829 * Parse skinvar editpluginfo
2831 * @param string $type type of plugin info
2834 public function parse_editpluginfo($type)
2838 $pid = intRequestVar('plugid');
2845 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2852 * AdminActions::parse_editplugoptionslist()
2853 * Parse skinvar editplugoptionslist
2855 * @param string $templateName name of template
2858 public function parse_editplugoptionslist($templateName = '')
2862 $pid = intRequestVar('plugid');
2863 $aOptions = array();
2866 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2867 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2868 $resource = DB::getResult($query);
2870 foreach ( $resource as $row )
2872 array_push($aOIDs, $row['oid']);
2873 $aOptions[$row['oid']] = array(
2874 'oid' => $row['oid'],
2875 'value' => $row['odef'],
2876 'name' => $row['oname'],
2877 'description' => $row['odesc'],
2878 'type' => $row['otype'],
2879 'typeinfo' => $row['oextra'],
2884 // fill out actual values
2885 if ( count($aOIDs) > 0 )
2887 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2888 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2890 $result = DB::getResult($query);
2892 foreach ( $result as $row )
2894 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2900 'context' => 'global',
2902 'options' => &$aOptions
2904 $manager->notify('PrePluginOptionsEdit', $data);
2906 $template['content'] = 'plugoptionlist';
2908 $amount = Showlist($aOptions, 'table', $template, $templateName);
2912 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2918 * AdminActions::parse_editskin()
2919 * Parse skinvar editskin
2921 * @param string $type type of skin
2924 public function parse_editskin($type = 'id')
2926 $skinid = intRequestVar('skinid');
2927 $skin = new SKIN($skinid);
2931 echo intRequestVar('skinid');
2934 echo Entity::hsc($skin->getName());
2937 echo Entity::hsc($skin->getDescription());
2940 echo Entity::hsc($skin->getContentType());
2943 echo Entity::hsc($skin->getIncludePrefix());
2946 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2954 * AdminActions::parse_editskintype()
2955 * Parse skinvar editskintype
2957 * @param string $type name of type for skin type
2960 public function parse_editskintype($type = 'id')
2962 global $CONF, $manager, $member;
2963 $skinid = intRequestVar('skinid');
2964 $skin = new SKIN($skinid);
2965 $fNames = $skin->getAvailableTypes();
2966 $sType = strtolower(trim(requestVar('type')));
2971 echo intRequestVar('skinid');
2974 echo Entity::hsc($skin->getName());
2977 echo Entity::hsc($skin->getDescription());
2980 echo Entity::hsc($skin->getContentType());
2983 echo Entity::hsc($skin->getContentFromDB($sType));
2986 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2987 echo Entity::hsc($skinType);
2990 echo Entity::hsc($sType);
2993 echo Entity::hsc($skin->getIncludePrefix());
2996 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2997 echo Entity::hsc($incMode);
3006 * AdminActions::parse_adminurl()
3007 * Parse skinvar adminurl
3008 * (shortcut for admin url)
3013 public function parse_adminurl()
3015 $this->parse_sitevar('adminurl');
3020 * AdminActions::parse_edittemplateinfo()
3021 * Parse skinvar edittemplateinfo
3023 * @param string $type name of type for skin
3024 * @param string $description description for skin
3025 * @param string $name name of skin
3026 * @param string $help
3027 * @param string $tabindex index value for tabindex attribute of input element
3028 * @param string $big
3029 * @param string $tplt name of template
3032 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3036 $t_id = intRequestVar('templateid');
3037 $t_name = Template::getNameFromId($t_id);
3038 $t_desc = Template::getDesc($t_id);
3039 $template = &Template::read($t_name);
3047 echo Entity::hsc($t_name);
3050 echo Entity::hsc($t_desc);
3052 case 'extratemplate':
3054 $pluginfields = array();
3055 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
3060 $tmplt = Template::read($desc);
3062 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3066 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3070 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3073 foreach ( $pluginfields as $pfkey => $pfvalue )
3075 $data = array('explugtplname' => Entity::hsc($pfkey));
3077 echo Template::fill($base, $data);
3079 foreach ( $pfvalue as $pffield => $pfdesc )
3081 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3086 $desc = defined($desc) ? constant($desc) : $desc;
3087 $name = defined($name) ? constant($name) : $name;
3088 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3096 * AdminActions::parse_editadmintemplateinfo()
3097 * Parse skinvar editadmintemplateinfo
3099 * @param string $type type of skin template
3100 * @param string $description description of template
3101 * @param string $name name of stemplate
3102 * @param string $tabindex index number for tabindex attribute of input element
3103 * @param string $big
3104 * @param string $tplt
3106 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3110 $t_id = intRequestVar('templateid');
3111 $t_name = Template::getNameFromId($t_id);
3112 $t_desc = Template::getDesc($t_id);
3113 $template = &Template::read($t_name);
3121 echo Entity::hsc($t_name);
3124 echo Entity::hsc($t_desc);
3126 case 'extratemplate':
3128 $pluginfields = array();
3129 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3134 $tmplt = Template::read($desc);
3136 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3140 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3144 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3147 foreach ( $pluginfields as $pfkey => $pfvalue )
3149 $data = array('explugtplname' => Entity::hsc($pfkey));
3151 echo Template::fill($base, $data);
3153 foreach ( $pfvalue as $pffield => $pfdesc )
3155 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3160 $desc = defined($desc) ? constant($desc) : $desc;
3161 $name = defined($name) ? constant($name) : $name;
3162 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3169 * AdminActions::parse_eventformextra()
3170 * Parse skinvar eventformextra
3172 * @param string $type name of type for event form extra
3175 public function parse_eventformextra($type = 'activation')
3184 $key = requestVar('ackey');
3187 Admin::error(_ERROR_ACTIVATE);
3189 $info = MEMBER::getActivationInfo($key);
3192 Admin::error(_ERROR_ACTIVATE);
3194 $mem = MEMBER::createFromId($info->vmember);
3197 Admin::error(_ERROR_ACTIVATE);
3200 'type' => 'activation',
3204 case 'membermailform-notloggedin':
3205 $data = array('type' => 'membermailform-notloggedin',);
3208 $manager->notify('FormExtra', $data);
3213 * AdminActions::parse_extrahead()
3214 * Parse skinvar extrahead
3216 public function parse_extrahead()
3220 $extrahead = Admin::getAdminextrahead();
3223 'extrahead' => &$extrahead,
3224 'action' => Admin::getAdminAction()
3227 $manager->notify('AdminPrePageHead', $data);
3233 * AdminActions::parse_member()
3234 * Parse skinvar member
3235 * (includes a member info thingie)
3237 * @param string $what which memberdata is needed
3240 public function parse_member($what)
3242 global $memberinfo, $member, $CONF;
3244 // 1. only allow the member-details-page specific variables on member pages
3245 if ( $this->skintype == 'member' )
3250 echo Entity::hsc($memberinfo->getDisplayName());
3253 echo Entity::hsc($memberinfo->getRealName());
3256 echo Entity::hsc($memberinfo->getNotes());
3259 echo Entity::hsc($memberinfo->getURL());
3262 echo Entity::hsc($memberinfo->getEmail());
3265 echo Entity::hsc($memberinfo->getID());
3270 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3271 if ( $member->isLoggedIn() )
3276 echo $member->getDisplayName();
3278 case 'yourrealname':
3279 echo $member->getRealName();
3282 echo $member->getNotes();
3285 echo $member->getURL();
3288 echo $member->getEmail();
3291 echo $member->getID();
3293 case 'yourprofileurl':
3294 if ( $CONF['URLMode'] == 'pathinfo' )
3296 echo Link::create_member_link($member->getID());
3300 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3309 * AdminActions::parse_version()
3310 * Parse skinvar version
3311 * (include nucleus versionnumber)
3316 public function parse_version()
3319 echo 'Nucleus CMS ' . $nucleus['version'];
3324 * AdminActions::parse_sitevar()
3325 * Parse skinvar sitevar
3326 * (include a sitevar)
3328 * @param string $which
3331 public function parse_sitevar($which)
3337 echo $CONF['IndexURL'];
3340 echo $CONF['SiteName'];
3343 echo $CONF['AdminEmail'];
3346 echo $CONF['AdminURL'];
3352 * AdminActions::parse_charset()
3353 * Parse skinvar charset
3358 public function parse_charset()
3360 echo i18n::get_current_charset();
3365 * AdminActions::parse_getblogsetting()
3366 * Parse skinvar getblogsetting
3368 public function parse_getblogsetting($which)
3370 global $blog, $manager;
3376 elseif ( $bid = intRequestVar('blogid') )
3378 $b = $manager->getBlog($bid);
3388 return Entity::hsc($b->getID());
3391 return Entity::hsc($b->getURL());
3394 return Entity::hsc($b->getName());
3397 return Entity::hsc($b->getDescription());
3400 return Entity::hsc($b->getShortName());
3402 case 'notifyaddress':
3403 return Entity::hsc($b->getNotifyAddress());
3406 return Entity::hsc($b->getMaxComments());
3409 return Entity::hsc($b->getUpdateFile());
3412 return Entity::hsc($b->getTimeOffset());
3419 * AdminActions::parse_geteditpluginfo()
3420 * Parse skinvar geteditpluginfo
3422 * @param string $type name of setting for edit plugin info
3425 public function parse_geteditpluginfo($type)
3428 $pid = intRequestVar('plugid');
3435 return Entity::hsc($manager->getPluginNameFromPid($pid));
3442 * AdminActions::parse_getmember()
3443 * Parse skinvar getmember
3444 * (includes a member info thingie)
3446 * @param string $what name of setting for member
3449 public function parse_getmember($what)
3451 global $memberinfo, $member;
3452 // 1. only allow the member-details-page specific variables on member pages
3453 if ( $this->skintype == 'member' )
3458 return Entity::hsc($memberinfo->getDisplayName());
3461 return Entity::hsc($memberinfo->getRealName());
3464 return Entity::hsc($memberinfo->getNotes());
3467 return Entity::hsc($memberinfo->getURL());
3470 return Entity::hsc($memberinfo->getEmail());
3473 return Entity::hsc($memberinfo->getID());
3477 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3478 if ( $member->isLoggedIn() )
3483 return $member->getDisplayName();
3485 case 'yourrealname':
3486 return $member->getRealName();
3489 return $member->getNotes();
3492 return $member->getURL();
3495 return $member->getEmail();
3498 return $member->getID();
3506 * AdminActions::parse_headmessage()
3507 * Parse skinvar headmessage
3512 public function parse_headmessage()
3514 if ( !empty(Admin::$headMess) )
3516 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3522 * AdminActions::parse_helplink()
3523 * Parse skinvar helplink
3525 * @param string $topic name of topic for help
3528 public function parse_helplink($topic = '')
3530 if ( !empty($topic) )
3538 * AdminActions::parse_helpplugname()
3539 * Parse skinvar helpplugname
3544 public function parse_helpplugname()
3546 $plugid = intGetVar('plugid');
3547 Entity::hsc($manager->getPluginNameFromPid($plugid));
3552 * AdminActions::parse_ilistaddnew()
3553 * Parse skinvar ilistaddnew
3558 public function parse_ilistaddnew()
3560 $blogid = intRequestVar('blogid');
3561 if ( intPostVar('start') == 0 )
3563 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3569 * AdminActions::parse_importskininfo()
3570 * Parse skinvar importskininfo
3572 * @param string $type name of information for imported skin
3575 public function parse_importskininfo($type)
3580 echo Entity::hsc(requestVar('skininfo'));
3583 $dataArr = requestArray('skinnames');
3584 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3587 $dataArr = requestArray('tpltnames');
3588 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3591 $dataArr = requestArray('skinclashes');
3592 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3595 $dataArr = requestArray('tpltclashes');
3596 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3599 echo Entity::hsc(requestVar('skinfile'));
3602 echo Entity::hsc(requestVar('mode'));
3609 * AdminActions::parse_inputyesno()
3610 * Parse skinvar inputyesno
3612 * some init stuff for all forms
3617 public function parse_init()
3622 if ( requestVar('action') == 'itemedit' )
3624 $itemid = intRequestVar('itemid');
3625 $item =& $manager->getItem($itemid, 1, 1);
3627 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3628 if ( $item && $blog->convertBreaks() )
3630 $item['body'] = removeBreaks($item['body']);
3631 $item['more'] = removeBreaks($item['more']);
3634 $authorid = $contents['authorid'];
3636 elseif ( requestVar('action') == 'createitem' )
3638 $blogid = intRequestVar('blogid');
3639 $blog =& $manager->getBlog($blogid);
3642 $blog->insertJavaScriptInfo($authorid);
3647 * AdminActions::parse_inputyesno()
3648 * Parse skinvar inputyesno
3650 * @param string $name
3651 * @param string $checkedval
3652 * @param string $tabindex
3653 * @param string $value1
3654 * @param string $value2
3655 * @param string $yesval
3656 * @param string $noval
3657 * @param string $isAdmin
3658 * @param string $templateName
3661 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3663 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3668 * AdminActions::parse_insertpluginfo()
3669 * Parse templatevar insertpluginfo
3671 public function parse_insertpluginfo($type)
3673 $option = Admin::getAdminaOption();
3677 return $option['pid'];
3680 return Entity::hsc($option['pfile']);
3687 * AdminActions::parse_insertpluginoptions()
3688 * Parse skinvar insertpluginoptions
3690 * @param string $templateName name of template
3693 public function parse_insertpluginoptions($templateName = '')
3695 $options = Admin::getAdminaOption();
3696 $template = array();
3697 $templats = array();
3699 if ( $templateName )
3701 $templates = Template::read($templateName);
3704 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3706 $template['title'] = "<tr>"
3707 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3712 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3715 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3717 $template['body'] = "<tr>"
3718 . "<%listplugplugoptionrow%>"
3723 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3728 include_libs('ACTIONS.php');
3729 $handler = new Actions($this->skintype);
3730 $parser = new PARSER($handler);
3732 foreach ( $options as $option )
3736 if ( $prevPid != $option['pid'] )
3738 $prevPid = $option['pid'];
3739 $parser->parse($template['title']);
3742 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3744 if ( @$meta['access'] != 'hidden' )
3746 $parsed = $parser->parse($template['body']);
3753 * AdminActions::parse_insplugoptcontent()
3754 * Parse skinvar insplugoptcontent
3759 public function parse_insplugoptcontent()
3761 $option = Admin::getAdminaOption();
3763 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3764 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3767 listplug_plugOptionRow($option);
3774 * AdminActions::parse_iprangeinput()
3775 * Parse skinvar iprangeinput
3780 public function parse_iprangeinput()
3782 if ( requestVar('ip') )
3784 $iprangeVal = Entity::hsc(requestVar('ip'));
3785 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3786 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3787 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3788 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3789 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3793 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3794 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3800 * AdminActions::parse_itemnavlist()
3801 * Parse skinvar itemnavlist
3806 public function parse_itemnavlist($templateName)
3808 global $CONF, $manager, $member;
3810 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3811 . " FROM %s, %s, %s, %s"
3812 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3814 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3816 if ( $this->skintype == 'itemlist' )
3819 if ( array_key_exists('blogid', $_REQUEST) )
3821 $blogid = intRequestVar('blogid');
3823 else if ( array_key_exists('itemid', $_REQUEST) )
3825 $itemid = intRequestVar('itemid');
3826 $item = &$manager->getItem($itemid, 1, 1);
3827 $blogid = (integer) $item['blogid'];
3829 $blog =& $manager->getBlog($blogid);
3831 $query .= " AND iblog={$blogid}";
3832 $template['now'] = $blog->getCorrectTime(time());
3834 // non-blog-admins can only edit/delete their own items
3835 if ( !$member->blogAdminRights($blogid) )
3837 $query .= ' AND iauthor = ' . $member->getID();
3840 elseif ( $this->skintype == 'browseownitems' )
3842 $query .= ' AND iauthor = ' . $member->getID();
3844 $template['now'] = time();
3847 // search through items
3848 $search = postVar('search');
3850 if ( !empty($search) )
3852 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3853 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3854 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3857 if ( postVar('start') )
3859 $start = intPostVar('start');
3866 // amount of items to show
3867 if ( postVar('amount') )
3869 $amount = intPostVar('amount');
3873 $amount = (integer) $CONF['DefaultListSize'];
3880 $query .= ' ORDER BY itime DESC'
3881 . " LIMIT {$start},{$amount}";
3883 $template['content'] = 'itemlist';
3885 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3886 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3891 * AdminActions::parse_itemtime()
3892 * date change on edit item
3894 * @param string $key key of PHP's getDate()
3897 public function parse_itemtime($key)
3902 $itemid = intRequestVar('itemid');
3903 $item =& $manager->getItem($itemid, 1, 1);
3905 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3907 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3909 $item['body'] = removeBreaks($item['body']);
3910 $item['more'] = removeBreaks($item['more']);
3913 $contents = array();
3914 if ( requestVar('action') == 'itemedit' )
3918 elseif ( requestVar('action') == 'createitem' )
3921 'contents' => &$contents,
3922 'blog' => &$this->blog
3924 $manager->notify('PreAddItemForm', $data);
3926 $itemtime = getdate($contents['timestamp']);
3927 echo $itemtime[$key];
3932 * AdminActions::parse_jstoolbaroptions()
3933 * Parse skinvar jstoolbaroptions
3938 public function parse_jstoolbaroptions()
3942 _SETTINGS_JSTOOLBAR_NONE,
3943 _SETTINGS_JSTOOLBAR_SIMPLE,
3944 _SETTINGS_JSTOOLBAR_FULL
3948 foreach ( $options as $option )
3950 $text = "<option value=\"%d\"%s>%s</option>\n";
3951 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3952 echo sprintf($text, $i, $extra, $option);
3958 * AdminActions::parse_localeselectoptions()
3959 * Parse skinvar localeselectoptions
3964 public function parse_localeselectoptions()
3966 $locales = i18n::get_available_locale_list();
3968 $memid = intRequestVar('memberid');
3971 $mem = MEMBER::createFromID($memid);
3972 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3974 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3978 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3983 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3985 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3989 echo "<option value=\"\">en_Latn_US</option>\n";
3992 foreach ( $locales as $locale )
3994 if ( $locale == 'en_Latn_US' )
4000 if ( $locale == $mem->getLocale() )
4002 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4006 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4011 if ( $locale == i18n::get_current_locale() )
4013 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4017 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4025 * AdminActions::parse_listplugplugoptionrow()
4026 * Parse templatevar listplugplugoptionrow
4028 * @param string $templateName name of template
4031 public function parse_listplugplugoptionrow($templateName = '')
4033 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
4038 * AdminActions::parse_mediadirwarning()
4039 * Parse skinvar mediadirwarning
4044 public function parse_mediadirwarning()
4047 if ( !is_dir($DIR_MEDIA) )
4049 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4051 if ( !is_readable($DIR_MEDIA) )
4053 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4055 if ( !is_writeable($DIR_MEDIA) )
4057 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4063 * AdminActions::parse_movedistselect()
4064 * Parse skinvar movedistselect
4066 public function parse_movedistselect()
4068 $actionType = requestVar('action');
4069 switch ( $actionType )
4072 Admin::selectBlogCategory('destcatid');
4074 case 'batchcategory':
4075 Admin::selectBlog('destblogid');
4078 if ( $this->skintype == 'itemmove' )
4080 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4081 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
4082 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
4083 Admin::selectBlogCategory('catid', $catid, 10, 1);
4091 * AdminActions::parse_moveitemid()
4092 * Parse skinvar moveitemid
4097 public function parse_moveitemid()
4099 echo intRequestVar('itemid');
4104 * AdminActions::parse_newestcompare()
4105 * Parse skinvar newestcompare
4110 public function parse_newestcompare()
4114 $newestVersion = getLatestVersion();
4115 $newestCompare = str_replace('/', '.', $newestVersion);
4116 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4118 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4120 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4121 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4127 * AdminActions::parse_newmemberselect()
4128 * Parse skinvar newmemberselect
4130 * @param string $templateName name of template to use
4133 public function parse_newmemberselect($templateName = '')
4135 $blogid = intRequestVar('blogid');
4137 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4138 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4139 $res = DB::getResult($query);
4142 foreach ( $res as $row )
4144 $tmem[] = intval($row['tmember']);
4147 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4148 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4151 'name' => 'memberid',
4152 'tabindex' => 10000,
4155 Showlist($query, 'select', $template, $templateName);
4160 * AdminActions::parse_newpluginlist()
4161 * Parse skinvar newpluginlist
4166 public function parse_newpluginlist()
4168 $candidates = $this->newPlugCandidates;
4169 foreach ( $candidates as $name )
4171 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4177 * AdminActions::parse_outputspecialdirs()
4178 * Parse skinvar outputspecialdirs
4180 * @param string $type type of setting for directory
4183 public function parse_outputspecialdirs($type)
4185 global $DIR_MEDIA, $DIR_NUCLEUS;
4190 echo Entity::hsc($DIR_NUCLEUS);
4193 echo Entity::hsc($DIR_MEDIA);
4200 * AdminActions::parse_passrequestvars()
4201 * Parse skinvar passrequestvars
4206 public function parse_passrequestvars()
4208 $passvar = Admin::getAdminpassvar();
4209 $oldaction = postVar('oldaction');
4211 if ( ($oldaction != 'logout')
4212 && ($oldaction != 'login')
4214 && !postVar('customaction') )
4222 * AdminActions::parse_pluginextras()
4223 * Parse skinvar pluginextras
4225 * @param string $type type of plugin context
4228 public function parse_pluginextras($type = 'global')
4234 $id = intRequestVar('memberid');
4235 $mem = MEMBER::createFromID($id);
4236 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4239 $id = intRequestVar('blogid');
4240 $blg = $manager->getBlog($id);
4241 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4245 'GeneralSettingsFormExtras',
4255 * AdminActions::parse_pluginhelp()
4256 * Parse skinvar pluginhelp
4261 public function parse_pluginhelp()
4263 global $manager, $DIR_PLUGINS;
4265 $plugid = intGetVar('plugid');
4266 $plugName = $manager->getPluginNameFromPid($plugid);
4267 $plug =& $manager->getPlugin($plugName);
4269 if ( $plug->supportsFeature('HelpPage') > 0 )
4271 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4272 if ( @file_exists($helpfile . 'php') )
4274 @include($helpfile . 'php');
4277 elseif ( @file_exists($helpfile . 'html') )
4279 @include($helpfile . 'html');
4283 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4284 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4289 * AdminActions::parse_pluginlistlist()
4290 * Parse skinvar pluginlistlist
4292 * @param string $templateName name of template to use
4295 public function parse_pluginlistlist($templateName = '')
4297 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4298 $query = sprintf($query, sql_table('plugin'));
4300 $template['content'] = 'pluginlist';
4301 $template['tabindex'] = 10;
4303 Showlist($query, 'table', $template, $templateName);
4309 * AdminActions::parse_pluginoptions()
4310 * Parse skinvar pluginoptions
4312 * @param string $type type of plugin option
4315 public function parse_pluginoptions($context='global')
4317 global $itemid, $manager;
4322 $contextid = intRequestVar('memberid');
4325 $contextid = intRequestVar('blogid');
4328 $contextid = intRequestVar('catid');
4331 $contextid = $itemid;
4335 /* Actually registererd plugin options */
4336 $aIdToValue = array();
4337 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4338 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4339 $res = DB::getResult($query);
4340 foreach ( $res as $row )
4342 $aIdToValue[$row['oid']] = $row['ovalue'];
4345 /* Currently available plugin options */
4346 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4347 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4348 $res = DB::getResult($query);
4351 foreach ($res as $row )
4353 if ( !array_key_exists($row['oid'], $aIdToValue) )
4355 $value = $row['odef'];
4359 $value = $aIdToValue[$row['oid']];
4363 'pid' => $row['pid'],
4364 'pfile' => $row['pfile'],
4365 'oid' => $row['oid'],
4367 'name' => $row['oname'],
4368 'description' => $row['odesc'],
4369 'type' => $row['otype'],
4370 'typeinfo' => $row['oextra'],
4371 'contextid' => $contextid,
4377 'context' => $context,
4378 'contextid' => $contextid,
4379 'options' => &$options
4381 $manager->notify('PrePluginOptionsEdit', $data);
4383 $content = $this->parser->skin->getContentFromDB('insertpluginoptions');
4384 $this->parser->parse($content);
4390 * AdminActions::parse_qmenuaddselect()
4391 * Parse skinvar qmanuaddselect
4393 * @param string $templateName name of template to use
4396 public function parse_qmenuaddselect($templateName = '')
4399 $showAll = requestVar('showall');
4400 if ( $member->isAdmin() && ($showAll == 'yes') )
4402 // Super-Admins have access to all blogs! (no add item support though)
4403 $query = 'SELECT bnumber as value, bname as text'
4404 . ' FROM ' . sql_table('blog')
4405 . ' ORDER BY bname';
4409 $query = 'SELECT bnumber as value, bname as text'
4410 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4411 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4412 . ' ORDER BY bname';
4415 $template['name'] = 'blogid';
4416 $template['tabindex'] = 15000;
4417 $template['extra'] = _QMENU_ADD_SELECT;
4418 $template['selected'] = -1;
4419 $template['shorten'] = 10;
4420 $template['shortenel'] = '';
4421 $template['javascript'] = 'onchange="return form.submit()"';
4423 Showlist($query, 'select', $template, $templateName);
4429 * AdminActions::parse_quickmenu()
4430 * Parse skinvar quickmenu
4432 * @param string $templateName name of template to use
4435 public function parse_quickmenu($templateName = '')
4438 $templates = array();
4439 $template = array();
4440 if ( !empty($templateName) )
4442 $templates = Template::read($templateName);
4444 $pluginExtras = array();
4448 'options' => &$pluginExtras
4451 if ( count($pluginExtras) > 0 )
4453 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4455 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4459 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4461 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4463 $template['head'] = "<ul>\n";
4467 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4469 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4471 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4475 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4477 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4479 $template['foot'] = "</ul>\n";
4483 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4486 $handler = new Actions($this->skintype);
4487 $parser = new PARSER($handler);
4489 $parser->parse($template['title']);
4490 echo $template['head'];
4491 foreach ( $pluginExtras as $aInfo )
4494 'plugadminurl' => Entity::hsc($aInfo['url']),
4495 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4496 'plugadmintitle' => Entity::hsc($aInfo['title']),
4498 echo Template::fill($template['body'], $data);
4500 echo $template['foot'];
4506 * AdminActions::parse_requestblogid()
4507 * Parse skinvar requestblogid
4512 public function parse_requestblogid()
4514 echo intRequestVar('blogid');
4519 * AdminActions::parse_requestiprange()
4520 * Parse skinvar requestiprange
4525 public function parse_requestiprange()
4527 if ( requestVar('iprange') )
4529 echo Entity::hsc(requestVar('iprange'));
4531 elseif ( requestVar('ip') )
4533 echo Entity::hsc(requestVar('ip'));
4539 * AdminActions::parse_selectlocaladminskinfiles()
4540 * Parse skinvar selectlocaladminskinfiles
4545 public function parse_selectlocaladminskinfiles()
4547 global $DIR_SKINS, $manager;
4549 $adminskindir = $DIR_SKINS . 'admin/';
4550 $candidates = SkinImport::searchForCandidates($adminskindir);
4552 foreach ( $candidates as $skinname => $skinfile )
4554 $html = Entity::hsc($skinfile);
4555 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4562 * AdminActions::parse_selectlocalskinfiles()
4563 * Parse skinvar selectlocalskinfiles
4568 public function parse_selectlocalskinfiles()
4572 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4574 foreach ( $candidates as $skinname => $skinfile )
4576 $html = Entity::hsc($skinfile);
4577 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4584 * AdminActions::parse_skineditallowedlist()
4585 * Parse skinvar skineditallowedlist
4587 * @param string $type type of skin
4588 * @param string $templateName name of template
4591 public function parse_skineditallowedlist($type, $templateName = '')
4596 $query = "SELECT bshortname, bname FROM %s;";
4598 'content' => 'shortblognames'
4600 $query = sprintf($query, sql_table('blog'));
4601 Showlist($query, 'table', $show, $templateName);
4604 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4606 'content' => 'shortnames'
4608 $query = sprintf($query, sql_table('template_desc'));
4609 Showlist($query, 'table', $show, $templateName);
4616 * AdminActions::parse_skinielist()
4617 * Parse skinvar skinielist
4619 * @param string $type type of skin
4620 * @param string $templateName name of template to use
4623 public function parse_skinielist($type, $templateName = '')
4625 $templates = array();
4626 if ( $templateName )
4628 $templates = Template::read($templateName);
4630 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4632 $template = $templates['SKINIE_EXPORT_LIST'];
4637 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4638 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4640 . "<td><%expdesc%></td>\n"
4647 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'));
4648 foreach ( $res as $row )
4651 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4652 'expid' => 'skinexp' . $row['sdnumber'],
4653 'expname' => Entity::hsc($row['sdname']),
4654 'expdesc' => Entity::hsc($row['sddesc'])
4656 echo Template::fill($template, $data);
4660 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4661 foreach ( $res as $row )
4664 'typeid' => 'template[' . $row['tdnumber'] . ']',
4665 'expid' => 'templateexp' . $row['tdnumber'],
4666 'expname' => Entity::hsc($row['tdname']),
4667 'expdesc' => Entity::hsc($row['tddesc'])
4669 echo Template::fill($template, $data);
4677 * AdminActions::parse_skinoverview()
4678 * Parse skinvar skinoverview
4680 * @param string $templateName name of template to use
4683 public function parse_skinoverview($templateName = '')
4686 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4687 $query = sprintf($query, sql_table('skin_desc'));
4689 $template['content'] = 'skinlist';
4690 $template['tabindex'] = 10;
4692 Showlist($query, 'table', $template, $templateName);
4697 * AdminActions::parse_skintypehelp()
4698 * Check editing skintypehelp
4703 public function parse_skintypehelp()
4705 $nowSkinType = strtolower(trim(requestVar('type')));
4707 /* TODO: use Skin class */
4708 $regularType = array(
4719 if ( in_array($nowSkinType, $regularType) )
4721 help('skinpart' . $nowSkinType);
4725 help('skinpartspecial');
4731 * AdminActions::parse_specialskinlist()
4732 * Parse skinvar specialskinlist
4734 * @param string $templateName name of template to use
4737 public function parse_specialskinlist($templateName = '')
4739 $templates = array();
4740 if ( $templateName )
4742 $templates = Template::read($templateName);
4745 /* TODO: use Skin class */
4756 $skinid = intRequestVar('skinid');
4757 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4758 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4760 $res = DB::getResult($query);
4761 if ( $res && $res->rowCount() > 0 )
4764 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4766 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4770 $template['head'] = "<ul>\n";
4772 echo Template::fill($template['head'], $data);
4773 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4775 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4776 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4777 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4781 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4785 foreach ( $res as $row )
4788 'tabindex' => $tabstart++,
4789 'skinid' => $skinid,
4790 'skintype' => Entity::hsc(strtolower($row['stype']))
4792 echo Template::fill($template['body'], $data);
4795 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4797 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4801 $template['foot'] = "</ul>\n";
4803 echo Template::fill($template['foot'], $data);
4809 * AdminActions::parse_sprinttext()
4812 * @param string $which
4813 * @param string $val
4816 public function parse_sprinttext($which, $val)
4818 if ( !defined($which) )
4824 $base = constant($which);
4827 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4829 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4831 $met = 'parse_' . $matchies[0];
4835 $arg = trim($args[0], '()');
4836 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4839 if ( method_exists($this, $met) )
4841 $value = call_user_func(array(&$this, $met), $arg);
4845 if ( !isset($value) || empty($value) )
4849 echo sprintf($base, $value);
4854 * AdminActions::parse_systemsettings()
4855 * Parse skinvar systemsettings
4857 * @param string $type type of settings for system
4858 * @param string $templateName name of template to use
4861 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4863 global $member, $CONF, $nucleus;
4865 $member->isAdmin() or Admin::disallow();
4867 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4868 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4875 case 'sqlserverinfo':
4876 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4878 case 'sqlclientinfo':
4879 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4881 case 'magicquotesgpc':
4882 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4884 case 'magicquotesruntime':
4885 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4887 case 'registerglobals':
4888 echo ini_get('register_globals') ? 'On' : 'Off';
4891 $templates = array();
4892 if ( $templateName )
4894 $templates = Template::read($templateName);
4896 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4898 $template = "<tr>\n"
4899 . "<td><%key%></td>\n"
4900 . "<td><%value%></td>\n"
4905 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4908 $gdinfo = gd_info();
4910 foreach ( $gdinfo as $key => $value )
4912 if ( is_bool($value) )
4914 $value = $value ? $enable : $disable;
4918 $value = Entity::hsc($value);
4924 echo Template::fill($template, $data);
4929 phpinfo(INFO_MODULES);
4930 $im = ob_get_contents();
4932 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4934 case 'nucleusversion':
4935 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4937 case 'nucleuspatchlevel':
4938 echo getNucleusPatchLevel();
4944 echo $CONF['ItemURL'];
4946 case 'alertonheaderssent':
4947 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4949 case 'nucleuscodename':
4950 if ( $nucleus['codename'] != '' )
4952 echo ' "' . $nucleus['codename'] . '"';
4955 case 'versioncheckurl':
4956 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4963 * AdminActions::parse_templateoverview()
4964 * Parse skinvar templateoverview
4966 * @param string $templateName name of template to use
4969 public function parse_templateoverview($templateName = '')
4971 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4972 $query = sprintf($query, sql_table('template_desc'));
4974 $template['content'] = 'templatelist';
4975 $template['tabindex'] = 10;
4977 Showlist($query, 'table', $template, $templateName);
4983 * AdminActions::parse_ticket()
4989 public function parse_ticket()
4992 $manager->addTicketHidden();
4997 * AdminActions::parse_versioncheckurl()
4998 * Parse skinvar versioncheckurl
5003 public function parse_versioncheckurl()
5005 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5010 * AdminActions::parse_yrbloglist()
5011 * Parse skinvar yrbloglist
5013 * @param string $templateName name of template to use
5016 public function parse_yrbloglist($templateName = '')
5019 $showAll = requestVar('showall');
5021 if ( $member->isAdmin() && ($showAll == 'yes') )
5023 // Super-Admins have access to all blogs! (no add item support though)
5024 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
5026 . " ORDER BY bnumber;";
5027 $query = sprintf($query, sql_table('blog'));
5031 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
5033 . " WHERE tblog=bnumber and tmember=%d"
5034 . " ORDER BY bnumber;";
5035 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5038 $template['content'] = 'bloglist';
5039 $template['superadmin'] = $member->isAdmin();
5041 $amount = Showlist($query, 'table', $template, $templateName);
5043 if ( ($showAll != 'yes') && ($member->isAdmin()) )
5045 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
5047 $total = DB::getValue($query);
5048 if ( $total > $amount )
5050 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
5056 echo _OVERVIEW_NOBLOGS;
5058 elseif( $amount != 0 )
5060 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
5062 $query = "SELECT ititle, inumber, bshortname"
5064 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
5065 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
5067 $template['content'] = 'draftlist';
5069 $amountdrafts = Showlist($query, 'table', $template, $templateName);
5070 if ( $amountdrafts == 0 )
5072 echo _OVERVIEW_NODRAFTS;
5079 * AdminActions::checkCondition()
5080 * Checks conditions for if statements
5082 * @param string $field type of <%if%>
5083 * @param string $name property of field
5084 * @param string $value value of property
5085 * @return boolean condition
5087 protected function checkCondition($field, $name='', $value = '')
5089 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5100 $blog =& $manager->getBlog($blogid);
5104 $blogid = getBlogIDFromCatID($catid);
5106 $blog =& $manager->getBlog($blogid);
5108 elseif ( intRequestVar('catid') )
5110 $catid = intRequestVar('catid');
5111 $blogid = getBlogIDFromCatID($catid);
5113 $blog =& $manager->getBlog($blogid);
5120 $condition = ($blog && $this->ifCategory($name, $value));
5123 $condition = ($blog && ($blog->getSetting($name) == $value));
5126 $condition = $member->isLoggedIn();
5129 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5132 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5135 $condition = $member->isLoggedIn() && $member->isAdmin();
5137 case 'allowloginedit':
5138 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5141 $condition = ($itemidnext != '');
5144 $condition = ($itemidprev != '');
5146 case 'archiveprevexists':
5147 $condition = ($archiveprevexists == true);
5149 case 'archivenextexists':
5150 $condition = ($archivenextexists == true);
5153 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5156 $condition = $this->ifHasPlugin($name, $value);
5159 $condition = (Admin::getAdminAction() == $name);
5161 case 'adminoldaction':
5162 $condition = (Admin::getAdminAction() == $name);
5164 case 'addresschange':
5165 $condition = ($this->ifAddresscange());
5167 case 'bechangepass':
5168 $condition = ($this->beChangePassword());
5170 case 'skincandidates':
5171 $condition = ($this->ifSkincandidates());
5174 $condition = requestVar('nameclashes');
5176 case 'existsnewplugin':
5177 $condition = ($this->existsNewPlugin());
5180 $condition = (boolean) ($member->getAutosave() == $value);
5183 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5190 * Actions::_ifHasPlugin()
5191 * hasplugin,PlugName
5192 * -> checks if plugin exists
5193 * hasplugin,PlugName,OptionName
5194 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5195 * hasplugin,PlugName,OptionName=value
5196 * -> checks if the option OptionName from plugin PlugName is set to value
5198 * @param string $name name of plugin
5199 * @param string $value
5202 private function ifHasPlugin($name, $value)
5206 // (pluginInstalled method won't write a message in the actionlog on failure)
5207 if ( $manager->pluginInstalled("NP_{$name}") )
5209 $plugin =& $manager->getPlugin("NP_{$name}");
5210 if ( $plugin != NULL )
5218 list($name2, $value2) = preg_split('#=#', $value, 2);
5219 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5223 else if ( $plugin->getOption($name2) == $value2 )
5234 * Actions::beChangePassword()
5239 private function beChangePassword()
5241 return intRequestVar('bNeedsPasswordChange');
5245 * Actions::ifSkincandidates()
5246 * Checks if a plugin exists and call its doIf function
5252 private function ifSkincandidates()
5255 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5256 return (count($candidates) > 0);
5260 * Actions::ifPlugin()
5261 * Checks if a plugin exists and call its doIf function
5263 * @param string $name name of plugin
5264 * @param string $key
5265 * @param string $value
5268 private function ifPlugin($name, $key = '', $value = '')
5272 $plugin =& $manager->getPlugin("NP_{$name}");
5278 $params = func_get_args();
5279 array_shift($params);
5281 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5285 * AdminActions::ifCategory()
5286 * Different checks for a category
5288 * @param string $key key for information of category
5289 * @param string $value value for information of category
5292 private function ifCategory($key = '', $value='')
5294 global $blog, $catid;
5296 // when no parameter is defined, just check if a category is selected
5297 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5299 return $blog->isValidCategory($catid);
5302 // check category name
5303 if ( $key == 'catname' )
5305 $value = $blog->getCategoryIdFromName($value);
5306 if ($value == $catid)
5308 return $blog->isValidCategory($catid);
5312 // check category id
5313 if (($key == 'catid') && ($value == $catid))
5315 return $blog->isValidCategory($catid);
5322 * AdminActions::ifOnTeam()
5323 * Checks if a member is on the team of a blog and return his rights
5325 * @param string $blogName name of weblog
5328 private function ifOnTeam($blogName = '')
5330 global $blog, $member, $manager;
5332 // when no blog found
5333 if ( ($blogName == '') && !is_object($blog) )
5338 // explicit blog selection
5339 if ($blogName != '')
5341 $blogid = getBlogIDFromName($blogName);
5344 if (($blogName == '') || !$manager->existsBlogID($blogid))
5347 $blogid = $blog->getID();
5349 return $member->teamRights($blogid);
5353 * AdminActions::ifAdmin()
5354 * Checks if a member is admin of a blog
5356 * @param string $blogName name of weblog
5359 private function ifAdmin($blogName = '')
5361 global $blog, $member, $manager;
5363 // when no blog found
5364 if (($blogName == '') && (!is_object($blog)))
5369 // explicit blog selection
5370 if ($blogName != '')
5372 $blogid = getBlogIDFromName($blogName);
5375 if (($blogName == '') || !$manager->existsBlogID($blogid))
5378 $blogid = $blog->getID();
5381 return $member->isBlogAdmin($blogid);
5385 * AdminActions::ifAddresscange()
5386 * Check e-Mail address is changed
5391 private function ifAddresscange()
5393 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5398 $info = MEMBER::getActivationInfo($key);
5403 $mem = MEMBER::createFromId($info->vmember);
5408 if ( $info->vtype == 'addresschange' )
5416 * AdminActions::templateEditRow()
5419 * @param array $template
5420 * @param string $desc
5421 * @param string $name
5422 * @param string $help
5423 * @param integer $tabindex
5424 * @param boolean $big
5425 * @param array $tmplt
5428 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5432 if ( !array_key_exists($name, $template) )
5434 $template[$name] = '';
5442 $tmplt = skinableTEMPLATE::read($tplt);
5446 'description' => $desc,
5447 'help' => empty($help) ? '' : helpHtml('template' . $help),
5450 'tabindex' => $tabindex,
5451 'rows' => $big ? 10 : 5,
5454 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5456 $base['head'] = "</tr>"
5458 . "<td><%description%><%help%></td>\n"
5459 . "<td id=\"td<%count%>\">\n"
5460 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5464 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5467 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5469 $base['tail'] = "</textarea>\n"
5474 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5477 echo TEMPLATE::fill($base['head'], $data);
5478 echo ENTITY::hsc($template[$name]);
5479 echo TEMPLATE::fill($base['tail'], $data);
5487 * AdminActions::customHelp()
5488 * shows a link to custom help file
5491 * @param string $tplName
5492 * @param string $url
5493 * @param string $iconURL
5494 * @param string $alt
5495 * @param string $title
5499 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5501 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5505 * AdminActions::customHelp()
5506 * shows a link to custom help file
5509 * @param string $tplName
5510 * @param string $url
5511 * @param string $iconURL
5512 * @param string $alt
5513 * @param string $title
5517 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5521 $templates = array();
5525 $templates = Template::read($tplName);
5528 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5530 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5534 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5539 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5542 if ( empty($onclick) )
5544 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5546 elseif ( preg_match('#^onclick#', $onclick) )
5548 $onclick = $onclick;
5552 $onclick = 'onclick="' . $onclick . '"';
5557 'helptarget' => $id,
5558 'onclick' => $onclick,
5559 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5561 return Template::fill($template, $data);
5565 * AdminActions::customHelpHtml()
5568 * @param string $tplName
5569 * @param string $url
5570 * @param string $iconURL
5571 * @param string $alt
5572 * @param string $title
5573 * @param string $onclick
5574 * @return string anchor element with help uri
5576 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5580 $templates = array();
5584 $templates = Template::read($tplName);
5586 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5588 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5592 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5595 if ( empty($iconURL) )
5597 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5600 if ( function_exists('getimagesize') )
5602 $size = getimagesize($iconURL);
5603 $width = 'width="' . $size[0] . '" ';
5604 $height = 'height="' . $size[1] . '" ';
5608 'iconurl' => $iconURL,
5610 'height' => $height,
5611 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5612 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5615 $icon = Template::fill($template, $data);
5616 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5618 return $help . $icon;
5622 * AdminActions::input_yesno
5625 * @param $checkedval
5632 * @param $templateName
5635 public function input_yesno($name,
5646 $templates = array();
5647 if ( $templateName )
5649 $templates = Template::read($templateName);
5652 if ( $name == 'admin' )
5654 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5656 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5657 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5658 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5659 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5663 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5668 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5670 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5674 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5676 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5679 if ( !isset($template) )
5681 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5682 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5683 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5684 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5689 $id = Entity::hsc($name);
5690 $id = str_replace('[', '-', $id);
5691 $id = str_replace(']', '-', $id);
5692 $id1 = $id . Entity::hsc($value1);
5693 $id2 = $id . Entity::hsc($value2);
5695 'name' => Entity::hsc($name),
5696 'yesval' => Entity::hsc($value1),
5697 'noval' => Entity::hsc($value2),
5700 'yesvaltext' => $yesval,
5701 'novaltext' => $noval,
5702 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5703 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5704 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5709 return Template::fill($template, $dat);
5713 echo Template::fill($template, $dat);
5719 * AdminActions::existsNewPlugin()
5720 * Check exists new plugin
5723 * @return boolean exists or not
5725 private function existsNewPlugin()
5727 global $DIR_PLUGINS;
5729 $query = "SELECT * FROM %s;";
5730 $query = sprintf($query, sql_table('plugin'));
5731 $res = DB::getResult($query);
5733 $installed = array();
5734 foreach( $res as $row )
5736 $installed[] = $row['pfile'];
5739 $files = scandir($DIR_PLUGINS);
5741 $candidates = array();
5742 foreach ( $files as $file )
5744 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5746 if ( !in_array($matches[1], $installed) )
5748 $candidates[] = $matches[1];
5752 $this->newPlugCandidates = $candidates;
5753 return (count($candidates) > 0);
5757 * AdminActions::pagehead()
5758 * Output admin page head
5763 public function parse_pagehead()
5765 global $member, $nucleus, $CONF, $manager;
5767 $extrahead = Admin::getAdminextrahead();
5769 'extrahead' => &$extrahead,
5770 'action' => Admin::getAdminAction()
5772 $manager->notify('AdminPrePageHead', $data);
5774 $content = $this->parser->skin->getContentFromDB('pagehead');
5777 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5781 if ( !array_key_exists('AdminCSS', $CONF) )
5783 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5784 $CONF['AdminCSS'] = 'original';
5788 /* HTTP 1.1 application for no caching */
5789 header("Cache-Control: no-cache, must-revalidate");
5790 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5792 $root_element = 'html';
5793 $charset = i18n::get_current_charset();
5794 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5795 $xml_version_info = self::$xml_version_info;
5796 $formal_public_identifier = self::$formal_public_identifier;
5797 $system_identifier = self::$system_identifier;
5798 $xhtml_namespace = self::$xhtml_namespace;
5800 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5801 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5802 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5804 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5807 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5809 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5810 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5811 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5812 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5813 echo "{$extrahead}\n";
5816 echo "<div id=\"adminwrapper\">\n";
5817 echo "<div class=\"header\">\n";
5818 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5820 echo "<div id=\"container\">\n";
5821 echo "<div id=\"content\">\n";
5822 echo "<div class=\"loginname\">\n";
5824 if ( !$member->isLoggedIn() )
5826 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5830 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5831 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5834 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5837 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5839 $codenamestring = '';
5843 $codenamestring = ' "' . $nucleus['codename'].'"';
5846 if ( $member->isLoggedIn() && $member->isAdmin() )
5848 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5849 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5851 $newestVersion = getLatestVersion();
5852 $newestCompare = str_replace('/', '.', $newestVersion);
5853 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5855 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5858 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5859 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5865 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5872 $this->parser->parse($content);
5879 * AdminActionss::pagefoot()
5880 * Output admin page foot include quickmenu
5885 public function parse_pagefoot()
5887 global $action, $member, $manager;
5890 'action' => Admin::getAdminAction()
5892 $manager->notify('AdminPrePageFoot', $data);
5894 $content = $this->parser->skin->getContentFromDB('pagefoot');
5897 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5899 echo '<h2>' . _LOGOUT . "</h2>\n";
5901 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5902 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5906 echo "<div class=\"foot\">\n";
5907 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5909 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5912 echo "<div id=\"quickmenu\">\n";
5914 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5917 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5920 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5921 echo "<form method=\"get\" action=\"index.php\">\n";
5923 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5925 $showAll = requestVar('showall');
5927 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5929 // Super-Admins have access to all blogs! (no add item support though)
5930 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5931 $query = sprintf($query, sql_table('blog'));
5935 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5936 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5938 $template['name'] = 'blogid';
5939 $template['tabindex'] = 15000;
5940 $template['extra'] = _QMENU_ADD_SELECT;
5941 $template['selected'] = -1;
5942 $template['shorten'] = 10;
5943 $template['shortenel'] = '';
5944 $template['javascript'] = 'onchange="return form.submit()"';
5945 showlist($query, 'select', $template);
5950 echo "<h2>{$member->getDisplayName()}</h2>\n";
5952 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5953 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5954 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5957 if ( $member->isAdmin() )
5959 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5961 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5962 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5963 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5964 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5965 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5966 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5967 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5970 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5972 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5973 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5974 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5978 $data = array('options' => array());
5980 $manager->notify('QuickMenu', $data);
5982 if ( count($data['options']) > 0 )
5984 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5986 foreach ( $data['options'] as $option )
5988 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5993 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5996 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
6000 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
6003 echo "<!-- quickmenu -->\n";
6006 echo "<!-- content -->\n";
6009 echo "<!-- container -->\n";
6012 echo "<!-- adminwrapper -->\n";
6020 $this->parser->skin->parse('pagefoot');