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
22 'adminskineditallowedlist',
25 'adminskinselectoptions',
26 'adminspecialskinlist',
27 'admintemplateoverview',
28 'allowedadminskinactions',
50 'configsettingsyesno',
52 'createaccountsuccess',
53 'createaccountdisable',
56 'defaultadminskintypes',
66 'editadmintemplateinfo',
72 'editplugoptionslist',
92 'listplugplugoptionrow',
93 'localeselectoptions',
110 'selectlocaladminskinfiles',
111 'selectlocalskinfiles',
112 'skineditallowedlist',
129 * AdminActions::$default_actions
130 * list of whole action names with which this class can deal
132 static private $default_actions = array(
156 * AdminActions::$skin_type_friendly_names
157 * friendly name for wrapped page types
159 static private $default_skin_types = array(
160 'actionlog' => _ADM_SKPRT_ACTIONLOG,
161 'activate' => _ADM_SKPRT_ACTIVATE,
162 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
163 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
164 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
165 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
166 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
167 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
168 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
169 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
170 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
171 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
172 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
173 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
174 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
175 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
176 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
177 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
178 'banlist' => _ADM_SKPRT_BANLIST,
179 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
180 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
181 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
182 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
183 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
184 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
185 'batchitem' => _ADM_SKPRT_BATCHITEM,
186 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
187 'batchmove' => _ADM_SKPRT_BATCHMOVE,
188 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
189 'batchteam' => _ADM_SKPRT_BATCHTEAM,
190 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
191 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
192 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
193 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
194 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
195 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
196 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
197 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
198 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
199 'createitem' => _ADM_SKPRT_CREATEITEM,
200 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
201 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT, /* not yet */
202 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS, /* not yet */
203 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED, /* not yet */
204 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
205 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
206 'forgotpassword' => _ADM_SKPRT_FORGOTPASSWORD, /* not yet */
207 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
208 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
209 'itemedit' => _ADM_SKPRT_ITEMEDIT,
210 'itemlist' => _ADM_SKPRT_ITEMLIST,
211 'itemmove' => _ADM_SKPRT_ITEMMOVE,
212 'login' => FALSE, //missing
213 'manage' => _ADM_SKPRT_MANAGE,
214 'manageteam' => _ADM_SKPRT_MANAGETEAM,
215 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
216 'memberedit' => FALSE, //missing
217 'overview' => _ADM_SKPRT_OVERVIEW,
218 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
219 'pagehead' => _ADM_SKPRT_PAGEHEAD,
220 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
221 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
222 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
223 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
224 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
225 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
226 'skindelete' => _ADM_SKPRT_SKINDELETE,
227 'skinedit' => _ADM_SKPRT_SKINEDIT,
228 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
229 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
230 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
231 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
232 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
233 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
234 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
235 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
236 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
237 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
238 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
239 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
243 * AdminActions::getAvailableSkinTypes()
247 * @return array list of friendly names for page actions
249 static public function getAvailableSkinTypes()
251 return self::$default_skin_types;
255 * AdminActions::getDefaultTypes()
259 * @return array list of friendly names for page actions
261 static public function getDefaultTypes()
263 return self::$default_skin_types;
267 * AdminActions::__construct()
268 * Constructor for a new Actions object
270 * @param string $type
273 public function __construct($type)
275 // call constructor of superclass first
276 parent::__construct();
277 $this->skintype = $type;
278 if ( !class_exists('Navlist') || !class_exists('Batch') )
281 include $DIR_LIBS . 'ENCAPSULATE.php';
287 * AdminActions::getAvailableActions()
290 * @return array allowed actions for the page type
292 public function getAvailableActions()
294 $extra_actions = array();
296 switch ( $this->skintype )
299 $extra_actions = array(
304 $extra_actions = array(
309 case 'activatesetpwd':
310 $extra_actions = array(
314 $extra_actions = array(
320 case 'adminerrorpage':
321 $extra_actions = array(
324 case 'adminskindelete':
325 $extra_actions = array(
329 case 'adminskinedit':
330 $extra_actions = array(
332 'defaultadminskintypes',
333 'adminspecialskinlist',
336 case 'adminskinedittype':
337 $extra_actions = array(
340 'allowedadminskinactions',
341 'adminskineditallowedlist',
344 case 'adminskiniedoimport':
345 $extra_actions = array(
349 case 'adminskinieimport':
350 $extra_actions = array(
354 case 'adminskinieoverview':
355 $extra_actions = array(
356 'selectlocaladminskinfiles',
360 case 'adminskinoverview':
361 $extra_actions = array(
365 case 'adminskinremovetype':
366 $extra_actions = array(
370 case 'admintemplatedelete':
371 $extra_actions = array(
372 'editadmintemplateinfo',
374 case 'admintemplateedit':
375 $extra_actions = array(
376 'editadmintemplateinfo',
379 case 'admntemplateoverview':
380 $extra_actions = array(
381 'admintemplateoverview',
384 case 'backupoverview':
385 $extra_actions = array(
388 case 'backuprestore':
389 $extra_actions = array(
393 $extra_actions = array(
399 case 'banlistdelete':
400 $extra_actions = array(
405 case 'banlistdeleteconfirm':
406 $extra_actions = array(
407 'banlistdeletedlist',
412 $extra_actions = array(
418 case 'batchcategory':
419 $extra_actions = array(
425 $extra_actions = array(
431 $extra_actions = array(
437 $extra_actions = array(
443 $extra_actions = array(
449 $extra_actions = array(
458 $extra_actions = array(
467 $extra_actions = array(
473 case 'blogcommentlist':
474 $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(
535 case 'createaccountinput':
536 $extra_actions = array(
542 case 'createaccountsuccess':
543 $extra_actions = array(
\r
547 case 'createaccountdisable':
548 $extra_actions = array(
553 $extra_actions = array(
565 $extra_actions = array(
571 $extra_actions = array(
576 case 'editmembersettings':
577 $extra_actions = array(
578 'adminskinselectoptions',
580 'localeselectoptions',
584 case 'forgotpassword':
585 $extra_actions = array(
589 case 'itemcommentlist':
590 $extra_actions = array(
596 $extra_actions = array(
603 $extra_actions = array(
615 $extra_actions = array(
622 $extra_actions = array(
628 $extra_actions = array(
632 $extra_actions = array(
641 $extra_actions = array(
646 $extra_actions = array(
651 $extra_actions = array(
656 $extra_actions = array(
662 $extra_actions = array(
667 case 'pluginoptions':
668 $extra_actions = array(
670 'editplugoptionslist',
674 $extra_actions = array(
677 'configsettingsedit',
678 'configsettingsyesno',
681 'localeselectoptions',
687 $extra_actions = array(
692 $extra_actions = array(
697 $extra_actions = array(
703 $extra_actions = array(
706 'allowedskinactions',
707 'skineditallowedlist',
708 'skineditallowedlist',
711 case 'skiniedoimport':
712 $extra_actions = array(
717 $extra_actions = array(
721 case 'skinieoverview':
722 $extra_actions = array(
723 'selectlocalskinfiles',
728 $extra_actions = array(
732 case 'skinremovetype':
733 $extra_actions = array(
737 case 'systemoverview':
738 $extra_actions = array(
743 $extra_actions = array(
749 case 'templatedelete':
750 $extra_actions = array(
755 $extra_actions = array(
759 case 'templateoverview':
760 $extra_actions = array(
764 case 'usermanagement':
765 $extra_actions = array(
771 $extra_actions = array(
780 'selectlocaladminskinfiles',
788 $defined_actions = array_merge(self::$default_actions, $extra_actions);
790 return array_merge($defined_actions, parent::getAvailableActions());
794 * AdminActions::parse_actionloglist()
795 * Parse skinvar actionloglist
797 * @param string $templateName name of template to use
800 public function parse_actionloglist($templateName = '')
802 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
803 $query = sprintf($query, sql_table('actionlog'));
805 $template['content'] = 'actionlist';
806 $amount = showlist($query, 'table', $template, $templateName);
812 * AdminActions::parse_activationmessage()
813 * Parse skinvar activationmessage
815 * @param string $type type of message
816 * @param string $templateName name of template to use
819 public function parse_activationmessage($type, $templateName = '')
821 global $CONF, $manager;
825 if ( !empty($templateName))
827 $template =& $manager->getTemplate($templateName);
830 $key = postVar('ackey');
833 Admin::error(_ERROR_ACTIVATE);
836 $info = MEMBER::getActivationInfo($key);
839 Admin::error(_ERROR_ACTIVATE);
842 $mem =& $manager->getMember($info->vmember);
845 Admin::error(_ERROR_ACTIVATE);
847 switch ( $info->vtype )
850 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
852 $title = $template['ACTIVATE_FORGOT_TITLE'];
856 $title = _ACTIVATE_FORGOT_TITLE;
858 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
860 $text = $template['ACTIVATE_FORGOT_TEXT'];
864 $text = _ACTIVATE_FORGOT_TEXT;
868 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
870 $title = $template['ACTIVATE_REGISTER_TITLE'];
874 $title = _ACTIVATE_REGISTER_TITLE;
876 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
878 $text = $template['ACTIVATE_REGISTER_TEXT'];
882 $text = _ACTIVATE_REGISTER_TEXT;
885 case 'addresschange':
886 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
888 $title = $template['ACTIVATE_CHANGE_TITLE'];
892 $title = _ACTIVATE_CHANGE_TITLE;
894 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
896 $text = $template['ACTIVATE_CHANGE_TEXT'];
900 $text = _ACTIVATE_CHANGE_TEXT;
905 'memberName' => Entity::hsc($mem->getDisplayName()),
906 'realName' => Entity::hsc($mem->getRealName()),
911 echo Template::fill($title, $aVars);
914 echo Template::fill($text, $aVars);
917 echo Entity::hsc($key);
924 * AdminActions::parse_addtickettourl()
925 * Parse skinvar addtickettourl
927 * @param string $url URI for ticket
930 public function parse_addtickettourl($url)
933 $url = $manager->addTicketToUrl($url);
934 echo Entity::hsc($url);
939 * AdminActions::parse_adminbanlist()
940 * Parse skinvar adminbanlist
942 * @param string $templateName name of template to use
945 public function parse_adminbanlist($templateName = '')
947 $blogid = intRequestVar('blogid');
949 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
950 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
952 $template['content'] = 'banlist';
954 $amount = Showlist($query, 'table', $template, $templateName);
964 * AdminActions::parse_adminbatchaction()
965 * Parse skinvar adminbatchaction
970 public function parse_adminbatchaction()
972 echo Entity::hsc(requestVar('batchaction'));
977 * AdminActions::parse_adminbatchlist()
978 * Parse skinvar adminbatchlist
980 * @param string $templateName name of template to use
983 public function parse_adminbatchlist($templateName = '')
986 $templates = array();
988 if ( !empty($templateName) )
990 $templates =& $manager->getTemplate($templateName);
993 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
995 $template = '<li><%text(_BATCH_EXECUTING)%> '
996 . '<b><%adminbatchaction%></b> '
997 . '<%batchlisttype%> '
998 . '<b><%batchid%></b>... '
999 . '<b><%batchlistmsg%></b>'
1004 $template = $templates['ADMIN_BATCHLIST'];
1007 $selected = requestIntArray('batch');
1008 $action = requestVar('batchaction');
1010 switch ( $this->skintype )
1013 $batchlisttype = _BATCH_ONITEM;
1014 $deleteaction = 'deleteOneItem';
1015 $moveaction = 'moveOneItem';
1016 $destid = intRequestVar('destcatid');
1018 case 'batchcomment':
1019 $batchlisttype = _BATCH_ONCOMMENT;
1020 $deleteaction = 'deleteOneComment';
1023 $batchlisttype = _BATCH_ONMEMBER;
1024 $deleteaction = 'deleteOneMember';
1025 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1026 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1027 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1028 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1031 $blogid = intRequestVar('blogid');
1032 $batchlisttype = _BATCH_ONTEAM;
1033 $deleteaction = 'deleteOneTeamMember';
1034 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1035 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1036 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1037 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1039 case 'batchcategory':
1040 $batchlisttype = _BATCH_ONCATEGORY;
1041 $deleteaction = 'deleteOneCategory';
1042 $moveaction = 'moveOneCategory';
1043 $destid = intRequestVar('destblogid');
1047 // walk over all selectedids and perform action
1048 foreach ( $selected as $selectedid )
1051 $selectedid = intval($selectedid);
1055 if ( $this->skintype != 'batchteam' )
1057 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1061 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1065 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1069 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1073 // there should always remain at least one super-admin
1074 $r = DB::getResult($unsetchksql);
1075 if ( $r->rowCount() < 2 )
1077 $error = $unseterrmsg;
1081 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1085 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1089 'batchid' => $selectedid,
1090 'batchlisttype' => Entity::hsc($batchlisttype),
1091 'adminbatchaction' => Entity::hsc($action),
1092 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1095 $handler = new AdminActions('template');
1096 $parser = new Parser($handler);
1098 $output = Template::fill($template, $data);
1100 $parser->parse($output);
1101 $output = ob_get_contents();
1103 echo "{$output}<br />";
1109 * AdminActions::parse_adminbloglink()
1110 * Parse skinvar adminbloglink
1112 * @param string $templateName name of template to use
1115 public function parse_adminbloglink($templateName = '')
1118 $blogid = intRequestVar('blogid');
1119 $blog =& $manager->getBlog($blogid);
1120 $templates = array();
1122 if ( !empty($templateName) )
1124 $templates =& $manager->getTemplate($templateName);
1127 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1129 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1133 $template = $templates['ADMIN_BLOGLINK'];
1137 'url' => Entity::hsc($blog->getURL()),
1138 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1139 'blogname' => Entity::hsc($blog->getName())
1142 echo Template::fill($template, $data);
1147 * AdminActions::parse_adminerrormesg()
1148 * Parse skinvar adminerrormesg
1153 public function parse_adminerrormesg()
1158 if ( requestVar('errormessage') )
1160 $message = requestVar('errormessage');
1162 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1164 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1166 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1168 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1170 echo Entity::hsc($message);
1175 * AdminActions::parse_adminskineditallowedlist()
1176 * Parse skinvar adminskineditallowedlist
1178 * @param string $type template/blog
1179 * @param string $templateName name of template to use
1182 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1186 /* TODO: blog seems not to be used */
1188 $query = "SELECT bshortname, bname FROM %s";
1189 $query = sprintf($query, sql_table('blog'));
1191 'content' => 'shortblognames'
1193 Showlist($query, 'table', $show, $templateName);
1196 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1197 $query = sprintf($query, sql_table('template_desc'));
1199 'content' => 'shortnames'
1201 Showlist($query, 'table', $show, $templateName);
1208 * AdminActions::parse_adminskinielist()
1209 * Parse skinvar adminskinielist
1211 * @param string $type skin/template
1212 * @param string $templateName name of template to use
1215 public function parse_adminskinielist($type, $templateName = '')
1219 $templates = array();
1220 if ( $templateName )
1222 $templates =& $manager->getTemplate($templateName);
1225 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1228 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1229 . "<label for=\"<%expid%>\"><%expname%></label>"
1231 . "<td><%expdesc%></td>\n"
1237 $template = $templates['SKINIE_EXPORT_LIST'];
1243 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1244 $query = sprintf($query, sql_table('skin_desc'));
1245 $res = DB::getResult($query);
1247 foreach ( $res as $row )
1250 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1251 'expid' => 'skinexp' . $row['sdnumber'],
1252 'expname' => Entity::hsc($row['sdname']),
1253 'expdesc' => Entity::hsc($row['sddesc']),
1255 echo Template::fill($template, $data);
1259 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1260 $query = sprintf($query, sql_table('template_desc'));
1261 $res = DB::getResult($query);
1262 foreach ( $res as $row )
1265 'typeid' => 'template[' . $row['tdnumber'] . ']',
1266 'expid' => 'templateexp' . $row['tdnumber'],
1267 'expname' => Entity::hsc($row['tdname']),
1268 'expdesc' => Entity::hsc($row['tddesc']),
1270 echo Template::fill($template, $data);
1278 * AdminActions::parse_adminskinoverview()
1279 * Parse skinvar adminskinoverview
1281 * @param string $templateName name of template to use
1284 public function parse_adminskinoverview($templateName = '')
1286 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1287 $query = sprintf($query, sql_table('skin_desc'));
1289 $template['content'] = 'adminskinlist';
1290 $template['tabindex'] = 10;
1291 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1292 Showlist($query, 'table', $template, $templateName);
1297 * AdminActions::parse_adminskinselectoptions()
1298 * Parse skinvar adminskinselectoptions
1303 public function parse_adminskinselectoptions($templateName = '')
1306 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1307 $query = sprintf($query, sql_table('skin_desc'));
1309 $template['name'] = 'adminskin';
1310 $template['selected'] = $CONF['AdminSkin'];
1311 $template['tabindex'] = 110;
1312 Showlist($query, 'select', $template, $templateName);
1317 * AdminActions::parse_adminspecialskinlist()
1318 * Parse skinvar adminspecialskinlist
1320 * @param string $templateName name of template to use
1322 public function parse_adminspecialskinlist($templateName = '')
1326 $templates = array();
1327 if ( $templateName )
1329 $templates =& $manager->getTemplate($templateName);
1332 $nType = $this->parser->skin->getDefaultTypes();
1333 $types = self::$default_skin_types;
1334 unset($types['memberedit']);
1335 unset($types['login']);
1336 $nType = array_keys($types);
1337 $skinid = intRequestVar('skinid');
1339 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1340 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1342 $res = DB::getResult($query);
1343 if ( $res && $res->rowCount() > 0 )
1345 /* NOTE: set templates for HEAD/BODY/FOOT */
1346 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1348 $template['head'] = "<ul>\n";
1352 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1354 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1356 $template['body'] = '<li>'
1357 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1360 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1367 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1369 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1371 $template['foot'] = "</ul>\n";
1375 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1382 echo $template['head'];
1383 foreach ( $res as $row )
1386 'tabindex' => $tabstart++,
1387 'skinid' => $skinid,
1388 'skintype' => Entity::hsc(strtolower($row['stype']))
1390 echo Template::fill($template['body'], $data);
1393 echo $template['foot'];
1399 * AdminActions::parse_admintemplateoverview()
1400 * Parse skinvar admintemplateoverview
1402 * @param string $templateName name of template to use
1405 public function parse_admintemplateoverview($templateName = '')
1407 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1408 $query = sprintf($query, sql_table('template_desc'));
1410 $template['content'] = 'admintemplatelist';
1411 $template['tabindex'] = 10;
1413 Showlist($query, 'table', $template, $templateName);
1418 * AdminActions::parse_allowedadminskinactions()
1419 * Parse skinvar allowedadminskinactions
1424 public function parse_allowedadminskinactions()
1426 global $DIR_ADMINSKINS;
1427 $skinType = strtolower(trim(requestVar('type')));
1428 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1431 while ( $current = array_shift($actions) )
1433 // TODO: remove this
1434 // skip deprecated vars
1435 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1440 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1442 if ( count($actions) != 0 )
1451 * AdminActions::parse_allowedskinactions()
1452 * Parse skinvar allowedskinactions
1457 public function parse_allowedskinactions()
1459 $skinType = strtolower(trim(requestVar('type')));
1460 $skinid = intRequestVar('skinid');
1462 $skin = new Skin($skinid);
1463 $actions = $skin->getAllowedActionsForType($skinType);
1466 while ( $current = array_shift($actions) )
1468 // TODO: remove this
1469 // skip deprecated vars
1470 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1475 /* TODO: alternative function should be used or not? */
1476 echo helplink("skinvar-{$current}") . "$current</a>\n";
1478 if ( count($actions) != 0 )
1487 * AdminActions::parse_banlistdeletedlist()
1488 * Parse skinvar banlistdeletedlist
1490 * @param string $templateName name of template to use
1493 public function parse_banlistdeletedlist($templateName = '')
1497 $templates = array();
1498 if ( $templateName )
1500 $templates =& $manager->getTemplate($templateName);
1503 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1505 $template = "<li><%blogname%></li>\n";
1509 $template = $templates['BANLIST_DELETED_LIST'];
1512 $deleted = requestArray('delblogs');
1513 foreach ( $deleted as $delblog )
1515 $blog =& $manager->getBlog($delblog);
1517 'blogname' => Entity::hsc($blog->getName())
1519 echo Template::fill($template, $data);
1526 * AdminActions::parse_batchdeletelist()
1527 * Parse skinvar batchdeletelist
1532 public function parse_batchdeletelist()
1534 $selected = requestIntArray('batch');
1537 foreach ( $selected as $select )
1539 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1541 // add hidden vars for team & comment
1542 if ( requestVar('action') == 'batchteam' )
1544 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1546 if ( requestVar('action') == 'batchcomment' )
1548 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1554 * AdminActions::parse_batchdeletetype()
1555 * Parse skinvar batchdeletetype
1560 public function parse_batchdeletetype()
1562 echo Entity::hsc(requestVar('action'));
1567 * AdminActions::parse_batchmovebtn()
1568 * Parse skinvar batchmovebtn
1573 public function parse_batchmovebtn()
1575 $actionType = requestVar('action');
1576 switch ( $actionType )
1581 case 'batchcategory':
1589 * AdminActions::parse_batchmovelist()
1590 * Parse skinvar batchmovelist
1595 public function parse_batchmovelist()
1597 $selected = requestIntArray('batch');
1599 foreach ( $selected as $select )
1601 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1608 * AdminActions::parse_batchmovetitle()
1609 * Parse skinvar batchmovetitle
1614 public function parse_batchmovetitle()
1616 $actionType = requestVar('action');
1617 switch ( $actionType )
1622 case 'batchcategory':
1623 echo _MOVECAT_TITLE;
1630 * AdminActions::parse_batchmovetype()
1631 * Parse skinvar batchmovetype
1636 public function parse_batchmovetype()
1638 echo Entity::hsc(requestVar('action'));
1643 * AdminActions::parse_blogcatlist()
1644 * Parse skinvar blogcatlist
1649 public function parse_blogcatlist($templateName = '')
1652 $blogid = intRequestVar('blogid');
1653 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1654 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1656 $template['content'] = 'categorylist';
1657 $template['tabindex'] = 200;
1659 $batch = new Batch('category');
1660 $batch->showlist($query, 'table', $template, $templateName);
1665 * AdminActions::parse_blogid()
1666 * Parse skinvar blogid
1671 public function parse_blogid()
1673 echo intRequestVar('blogid');
1678 * AdminActions::parse_blognotifysetting()
1679 * Parse skinvar blognotifysetting
1684 public function parse_blognotifysetting($type)
1687 $blogid = intRequestVar('blogid');
1688 $blog =& $manager->getBlog($blogid);
1693 if ( !$blog->notifyOnComment() )
1699 if ( !$blog->notifyOnVote() )
1705 if ( !$blog->notifyOnNewItem() )
1711 echo ' checked="checked"';
1716 * AdminActions::parse_blogsetting()
1717 * Parse skinvar blogsetting
1719 * @param string $which name of weblog setting
1722 public function parse_blogsetting($which)
1724 echo $this->parse_getblogsetting($which);
1729 * AdminActions::parse_blogsettingyesno()
1730 * Parse skinvar blogsettingyesno
1732 * @param string $type type of weblog setting
1733 * @param string $templateName name of template to use
1736 public function parse_blogsettingyesno($type, $templateName = '')
1740 $blogid = intRequestVar('blogid');
1741 $blog =& $manager->getBlog($blogid);
1745 case 'convertbreaks':
1746 $checkedval = $blog->convertBreaks();
1749 case 'allowpastposting':
1750 $checkedval = $blog->allowPastPosting();
1754 $checkedval = $blog->commentsEnabled();
1758 $checkedval = $blog->isPublic();
1762 $checkedval = $blog->emailRequired();
1766 $checkedval = $blog->getSearchable();
1770 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1775 * AdminActions::parse_blogteamlist()
1776 * Parse skinvar blogteamlist
1778 * @param string $templateName name of template to use
1781 public function parse_blogteamlist($templateName = '')
1784 $blogid = intRequestVar('blogid');
1785 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1787 . "WHERE tmember=mnumber AND tblog= %d";
1788 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1790 $template['content'] = 'teamlist';
1791 $template['tabindex'] = 10;
1793 $batch = new Batch('team');
1794 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1799 * AdminActions::parse_blogteammembers()
1800 * Parse skinvar blogteammembers
1805 public function parse_blogteammembers()
1807 $blogid = intRequestVar('blogid');
1808 $query = "SELECT mname, mrealname "
1810 . "WHERE mnumber=tmember AND tblog=%d;";
1811 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1812 $res = DB::getResult($query);
1813 $memberNames = array();
1814 foreach ( $res as $row )
1816 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1818 echo implode(',', $memberNames);
1822 * AdminActions::parse_blogtime()
1823 * Parse skinvar blogtime
1825 * @param string $type type of time
1826 * @param string $format format for time expression
1827 * @param integer $offset offset of time
1830 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1834 if ( $type != 'blogtime' )
1836 /* return server time */
1837 $timestamp = time() + $offset;
1841 $bid = intRequestVar('blogid');
1842 $b =& $manager->getBlog($bid);
1843 $timestamp = $b->getCorrectTime() + $offset;
1846 echo i18n::formatted_datetime($format, $timestamp);
1851 * AdminActions::parse_bookmarkletadmin()
1852 * Parse skinvar bookmarkletadmin
1857 public function parse_bookmarkletadmin()
1861 $blogid = intRequestVar('blogid');
1863 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1868 * AdminActions::parse_categories()
1869 * Parse skinvar categories
1871 * create category dropdown box
1873 * @param string $type name of setting for category
1876 public function parse_categories($startidx = 0)
1881 $itemid = intRequestVar('itemid');
1882 $item = &$manager->getItem($itemid, 1, 1);
1887 $blogid = intRequestVar('blogid');
1891 $blogid = $item['blogid'];
1893 $blog = &$manager->getBlog($blogid);
1895 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1897 $item['body'] = removeBreaks($item['body']);
1898 $item['more'] = removeBreaks($item['more']);
1901 $contents = array();
1902 if ( requestVar('action') == 'itemedit' )
1907 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1910 $catid = $blog->getDefaultCategory();
1915 $catid = $contents['catid'];
1918 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1924 * AdminActions::parse_category()
1925 * Parse skinvar category
1927 * @param string $type name of setting for category
1930 public function parse_category($type = 'name')
1932 echo $this->parse_getcategory($type);
1937 * AdminActions::parse_categorysetting()
1938 * Parse skinvar categorysetting
1940 * @param string $type type in category setting
1943 public function parse_categorysetting($type)
1945 $catid = intRequestVar('catid');
1946 if ( $type == 'id' )
1951 $blogid = intRequestVar('blogid');
1952 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1953 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1954 $row = DB::getRow($query);
1956 if ( $type != 'name' )
1958 echo Entity::hsc($row['cdesc']);
1962 echo Entity::hsc($row['cname']);
1969 * AdminActions::parse_codename()
1970 * Parse templatevar codename
1976 public function parse_checkedonval($value, $name)
1981 $itemid = intRequestVar('itemid');
1982 $item =& $manager->getItem($itemid, 1, 1);
1984 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1986 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1988 $item['body'] = removeBreaks($item['body']);
1989 $item['more'] = removeBreaks($item['more']);
1992 $contents = array();
1993 if ( requestVar('action') == 'itemedit' )
1997 if ( !isset($contents[$name]) )
1999 $contents[$name] = '';
2001 if ($contents[$name] == $value)
2003 echo 'checked="checked"';
2009 * AdminActions::parse_codename()
2010 * Parse templatevar codename
2015 * TODO: is this need???
2017 public function parse_codename()
2020 echo $nucleus['codename'];
2025 * AdminActions::parse_commentnavlist()
2026 * Parse skinvar commentnavlist
2031 public function parse_commentnavlist()
2033 global $CONF, $manager, $member;
2036 if ( postVar('start') )
2038 $start = intPostVar('start');
2045 // amount of items to show
2046 if ( postVar('amount') )
2048 $amount = intPostVar('amount');
2052 $amount = (integer) $CONF['DefaultListSize'];
2058 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2060 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2062 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2064 if ( $this->skintype == 'itemcommentlist' )
2066 $itemid = intRequestVar('itemid');
2067 $query .= " citem={$itemid}";
2068 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2070 $nonComments = _NOCOMMENTS;
2072 elseif ( $this->skintype == 'browseowncomments' )
2075 $query .= ' cmember=' . $member->getID();
2076 $template['canAddBan'] = 0;
2078 $nonComments = _NOCOMMENTS_YOUR;
2080 elseif ( $this->skintype == 'blogcommentlist' )
2083 $query .= ' cblog=' . intRequestVar('blogid');
2084 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2085 $bid = intRequestVar('blogid');
2086 $nonComments = _NOCOMMENTS_BLOG;
2089 $search = postVar('search');
2090 if ( !empty($search) )
2092 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2095 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2097 $template['content'] = 'commentlist';
2099 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2100 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2105 * AdminActions::parse_configsettingsedit()
2106 * Parse skinvar configsettingsedit
2108 * @param string $type type of global configuration
2111 public function parse_configsettingsedit($type)
2116 case 'DefaultListSize':
2117 if ( !array_key_exists('DefaultListSize', $CONF) )
2119 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2120 $query = sprintf($query, sql_table('config'));
2121 DB::execute($query);
2122 $CONF['DefaultListSize'] = 10;
2124 elseif ( intval($CONF['DefaultListSize']) < 1 )
2126 $CONF['DefaultListSize'] = 10;
2128 echo intval($CONF['DefaultListSize']);
2130 case 'SessionCookie':
2131 $value = $CONF['SessionCookie'];
2132 $txt1 = _SETTINGS_COOKIESESSION;
2133 $txt2 = _SETTINGS_COOKIEMONTH;
2134 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2137 $value = $CONF['URLMode'];
2138 $txt1 = _SETTINGS_URLMODE_NORMAL;
2139 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2140 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2143 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2145 echo Entity::hsc($CONF[$type]);
2153 * AdminActions::parse_configsettingsyesno()
2154 * Parse skinvar configsettingsyesno
2156 * @param string $type type of global setting
2157 * @param integer $tabindex tabindex attribute of input element
2160 public function parse_configsettingsyesno($type, $tabindex)
2163 if ( array_key_exists($type, $CONF) )
2165 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2171 * AdminActions::parse_contents()
2172 * Parse skinvar contents
2174 * @param string $which part for item
2177 public function parse_contents($which)
2179 if ( !array_key_exists($which, Admin::$contents) )
2181 Admin::$contents[$which] = '';
2183 echo Entity::hsc(Admin::$contents[$which]);
2187 * AdminActions::parse_currenttime()
2188 * Parse skinvar currenttime
2190 * @param string $what
2193 public function parse_currenttime($what)
2195 $nu = getdate(Admin::$blog->getCorrectTime());
2200 * AdminActions::parse_customhelplink()
2201 * Parse skinvar customhelplink
2203 * @param string $topic name of topic
2204 * @param string $tplName name of template
2205 * @param string $url string as URI
2206 * @param string $iconURL string as URI for icon
2207 * @param string $alt alternative text for image element
2208 * @param string $title title for anchor element
2211 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2213 $this->customHelp($topic, $url, $iconURL);
2218 * AdminActions::parse_date()
2219 * Parse skinvar date
2221 public function parse_date($format = 'c')
2223 global $CONF, $manager;
2224 /* TODO: offset is based on i18n::get_current_locale()? */
2225 echo i18n::formatted_datetime($format, time());
2230 * AdminActions::parse_defaultadminskintypes()
2231 * Parse skinvar defaultadminskintypes
2233 * @param string $tabindex index number for tabindex attribute of input element
2234 * @param string $templateName name of template
2237 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2241 $templates = array();
2243 if ( $templateName )
2245 $templates =& $manager->getTemplate($templateName);
2248 $types = self::$default_skin_types;
2249 unset($types['memberedit']);
2250 unset($types['login']);
2253 /* NOTE: set templates for HEAD/BODY/FOOT */
2254 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2256 $template['head'] = "<ul>\n";
2260 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2262 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2264 $template['body'] = "<li>"
2265 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2270 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2272 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2274 $template['foot'] = "</ul>\n";
2278 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2281 $handler = new AdminActions('template');
2282 $parser = new PARSER($handler);
2284 /* NOTE: do output */
2285 echo $template['head'];
2286 foreach ( $types as $type => $fName )
2288 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2290 'tabindex' => $tabindex,
2291 'skintype' => $type,
2293 'help' => $helplink,
2294 'skinid' => intrequestVar('skinid'),
2296 $parser->parse(Template::fill($template['body'], $data));
2299 echo $template['foot'];
2305 * AdminActions::parse_defblogselect()
2306 * Parse skinvar defblogselect
2308 * @param string $templateName name of template
2311 public function parse_defblogselect($templateName = '')
2315 $query = "SELECT bname as text, bnumber as value FROM %s;";
2316 $query = sprintf($query, sql_table('blog'));
2318 $template['name'] = 'DefaultBlog';
2319 $template['selected'] = $CONF['DefaultBlog'];
2320 $template['tabindex'] = 10;
2322 Showlist($query, 'select', $template, $templateName);
2328 * AdminActions::parse_defcatselect()
2329 * Parse skinvar defcatselect
2331 * @param string $templateName name of template
2334 public function parse_defcatselect($templateName = '')
2338 $blogid = intRequestVar('blogid');
2339 $blog =& $manager->getBlog($blogid);
2341 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2342 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2344 $template['name'] = 'defcat';
2345 $template['selected'] = $blog->getDefaultCategory();
2346 $template['tabindex'] = 110;
2348 Showlist($query, 'select', $template, $templateName);
2354 * AdminActions::parse_defskinselect()
2355 * Parse skinvar defskinselect
2357 * @param string $type type of skin
2358 * @param string $templateName name of template
2361 public function parse_defskinselect($type = 'blog', $templateName = '')
2363 global $CONF, $manager;
2365 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2366 $query = sprintf($query, sql_table('skin_desc'));
2368 $blogid = intRequestVar('blogid');
2372 $template['selected'] = $CONF['BaseSkin'];
2376 $blog =& $manager->getBlog($blogid);
2377 $template['selected'] = $blog->getDefaultSkin();
2380 if ( $type != 'blog' )
2382 $nname = 'BaseSkin';
2389 $template['name'] = $nname;
2390 $template['tabindex'] = 50;
2392 Showlist($query, 'select', $template, $templateName);
2398 * AdminActions::parse_deletecomment()
2399 * Parse skinvar deletecomment
2401 * @param string $type type of infomation for comment
2404 public function parse_deletecomment($type = 'id')
2406 $commentid = intRequestVar('commentid');
2407 $comment = COMMENT::getComment($commentid);
2412 echo intRequestVar('commentid');
2415 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2417 echo $comment['member'];
2421 echo $comment['user'];
2425 $body = strip_tags($comment['body']);
2426 echo Entity::hsc(shorten($body, 300, '...'));
2432 * AdminActions::parse_deleteitembody()
2433 * Parse skinvar deleteitembody
2438 public function parse_deleteitembody()
2442 $itemid = intRequestVar('itemid');
2443 $item =& $manager->getItem($itemid, 1, 1);
2445 $body = strip_tags($item['body']);
2447 echo Entity::hsc(shorten($body, 300, '...'));
2453 * AdminActions::parse_deleteitemid()
2454 * Parse skinvar deleteitemid
2459 public function parse_deleteitemid()
2461 echo (integer) intRequestVar('itemid');
2466 * AdminActions::parse_deleteitemtitle()
2467 * Parse skinvar deleteitemtitle
2472 public function parse_deleteitemtitle()
2476 $itemid = intRequestVar('itemid');
2477 $item =& $manager->getItem($itemid, 1, 1);
2479 echo Entity::hsc(strip_tags($item['title']));
2485 * AdminActions::parse_editadminskin()
2486 * Parse skinvar editadminskin
2488 * @param string $type type of skin setting
2491 public function parse_editadminskin($type = 'id')
2493 $skinid = intRequestVar('skinid');
2494 $skin = new Skin($skinid);
2498 echo intRequestVar('skinid');
2501 echo Entity::hsc($skin->getName());
2504 echo Entity::hsc($skin->getDescription());
2507 echo Entity::hsc($skin->getContentType());
2510 echo Entity::hsc($skin->getIncludePrefix());
2513 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2521 * AdminActions::parse_editadminskintype()
2522 * Parse skinvar editadminskintype
2524 * @param string $type name of skin type
2527 public function parse_editadminskintype($type = 'id')
2529 global $CONF, $manager, $member;
2531 static $skin = NULL;
2532 static $types = array();
2534 if ( $skin == NULL )
2536 $skinid = intRequestVar('skinid');
2537 $skin = new Skin($skinid, 'AdminActions');
2538 $types = $skin->getDefaultTypes();
2541 $stype = strtolower(trim(requestVar('type')));
2542 if ( empty($stype) )
2549 echo $skin->getID();
2552 echo Entity::hsc($skin->getName());
2555 echo Entity::hsc($skin->getDescription());
2558 echo Entity::hsc($skin->getContentType());
2561 echo Entity::hsc($skin->getContentFromDB($stype));
2564 $friendly_name = !array_key_exists($stype, $types) ? ucfirst($stype) : $types[$stype];
2565 echo Entity::hsc($friendly_name);
2568 echo Entity::hsc($stype);
2571 echo Entity::hsc($skin->getIncludePrefix());
2574 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2575 echo Entity::hsc($incMode);
2584 * AdminActions::parse_editcomment()
2585 * Parse skinvar editcomment
2587 * @param string $type type of comment setting
2590 public function parse_editcomment($type = 'id')
2594 $commentid = intRequestVar('commentid');
2595 $comment = COMMENT::getComment($commentid);
2597 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2602 echo intRequestVar('commentid');
2605 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2607 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2611 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2615 echo date("Y-m-d @ H:i", $comment['timestamp']);
2618 $comment['body'] = str_replace('<br />', '', $comment['body']);
2619 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2620 echo $comment['body'];
2623 echo $comment['userid'];
2626 echo $comment['userid'];
2629 echo $comment[$type];
2636 * AdminActions::parse_editdesturl()
2637 * Parse skinvar editdesturl
2639 public function parse_editdesturl()
2641 if ( requestVar('desturl') )
2643 echo Entity::hsc(requestVar('desturl'));
2649 * AdminActions::parse_editmemberlist()
2650 * Parse skinvar editmemberlist
2652 * @param string $templateName name of template
2655 public function parse_editmemberlist($templateName = '')
2658 // show list of members with actions
2659 $query = 'SELECT * FROM '.sql_table('member');
2660 $template['content'] = 'memberlist';
2661 $template['tabindex'] = 10;
2663 $batch = new Batch('member');
2664 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2669 * AdminActions::parse_editmember()
2670 * Parse skinvar editmember
2672 * @param string $type type of information for member
2673 * @return string $tempateName name of template to use
2676 public function parse_editmember($type = 'id', $templateName = '')
2678 global $CONF, $manager, $member;
2680 $memberid = intRequestVar('memberid');
2681 $mem =& $manager->getMember($memberid);
2686 echo intRequestVar('memberid');
2689 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2691 echo Entity::hsc($mem->getDisplayName());
2695 $dispName = Entity::hsc($mem->getDisplayName());
2696 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2698 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2707 echo Entity::hsc($mem->getRealName());
2710 echo Entity::hsc($mem->getEmail());
2713 echo Entity::hsc($mem->getURL());
2716 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2719 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2722 echo Entity::hsc($mem->getNotes());
2725 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2734 * AdminActions::parse_editpluginfo()
2735 * Parse skinvar editpluginfo
2737 * @param string $type type of plugin info
2740 public function parse_editpluginfo($type)
2744 $pid = intRequestVar('plugid');
2751 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2758 * AdminActions::parse_editplugoptionslist()
2759 * Parse skinvar editplugoptionslist
2761 * @param string $templateName name of template
2764 public function parse_editplugoptionslist($templateName = '')
2768 $pid = intRequestVar('plugid');
2769 $aOptions = array();
2772 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2773 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2774 $resource = DB::getResult($query);
2776 foreach ( $resource as $row )
2778 array_push($aOIDs, $row['oid']);
2779 $aOptions[$row['oid']] = array(
2780 'oid' => $row['oid'],
2781 'value' => $row['odef'],
2782 'name' => $row['oname'],
2783 'description' => $row['odesc'],
2784 'type' => $row['otype'],
2785 'typeinfo' => $row['oextra'],
2790 // fill out actual values
2791 if ( count($aOIDs) > 0 )
2793 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2794 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2796 $result = DB::getResult($query);
2798 foreach ( $result as $row )
2800 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2806 'context' => 'global',
2808 'options' => &$aOptions
2810 $manager->notify('PrePluginOptionsEdit', $data);
2812 $template['content'] = 'plugoptionlist';
2814 $amount = Showlist($aOptions, 'table', $template, $templateName);
2818 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2824 * AdminActions::parse_editskin()
2825 * Parse skinvar editskin
2827 * @param string $type type of skin
2830 public function parse_editskin($type = 'id')
2832 $skinid = intRequestVar('skinid');
2833 $skin = new SKIN($skinid);
2837 echo intRequestVar('skinid');
2840 echo Entity::hsc($skin->getName());
2843 echo Entity::hsc($skin->getDescription());
2846 echo Entity::hsc($skin->getContentType());
2849 echo Entity::hsc($skin->getIncludePrefix());
2852 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2860 * AdminActions::parse_editskintype()
2861 * Parse skinvar editskintype
2863 * @param string $type name of type for skin type
2866 public function parse_editskintype($type = 'id')
2868 global $CONF, $manager, $member;
2869 $skinid = intRequestVar('skinid');
2870 $skin = new SKIN($skinid);
2871 $fNames = $skin->getDefaultTypes();
2872 $sType = strtolower(trim(requestVar('type')));
2876 echo intRequestVar('skinid');
2879 echo Entity::hsc($skin->getName());
2882 echo Entity::hsc($skin->getDescription());
2885 echo Entity::hsc($skin->getContentType());
2888 echo Entity::hsc($skin->getContentFromDB($sType));
2891 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2892 echo Entity::hsc($skinType);
2895 echo Entity::hsc($sType);
2898 echo Entity::hsc($skin->getIncludePrefix());
2901 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2902 echo Entity::hsc($incMode);
2911 * AdminActions::parse_adminurl()
2912 * Parse skinvar adminurl
2913 * (shortcut for admin url)
2918 public function parse_adminurl()
2920 $this->parse_sitevar('adminurl');
2925 * AdminActions::parse_edittemplateinfo()
2926 * Parse skinvar edittemplateinfo
2928 * @param string $type name of type for skin
2929 * @param string $description description for skin
2930 * @param string $name name of skin
2931 * @param string $help
2932 * @param string $tabindex index value for tabindex attribute of input element
2933 * @param string $big
2934 * @param string $tplt name of template
2937 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2940 static $cache = array();
2942 if ( !array_key_exists('id', $cache) )
2944 $cache['id'] = intRequestVar('templateid');
2947 if ( !array_key_exists('name', $cache) )
2949 $cache['name'] = Template::getNameFromId($cache['id']);
2952 if ( !array_key_exists('desc', $cache) )
2954 $cache['desc'] = Template::getDesc($cache['id']);
2957 $template =& $manager->getTemplate($cache['name']);
2962 echo (integer) $cache['id'];
2965 echo Entity::hsc($cache['name']);
2968 echo Entity::hsc($cache['desc']);
2970 case 'extratemplate':
2972 $pluginfields = array();
2973 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2978 $tmplt =& $manager->getTemplate($desc);
2980 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2984 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2988 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2991 foreach ( $pluginfields as $pfkey => $pfvalue )
2993 $data = array('explugtplname' => Entity::hsc($pfkey));
2995 echo Template::fill($base, $data);
2997 foreach ( $pfvalue as $pffield => $pfdesc )
2999 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3004 $desc = defined($desc) ? constant($desc) : $desc;
3005 $name = defined($name) ? constant($name) : $name;
3006 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3014 * AdminActions::parse_editadmintemplateinfo()
3015 * Parse skinvar editadmintemplateinfo
3017 * @param string $type type of skin template
3018 * @param string $description description of template
3019 * @param string $name name of stemplate
3020 * @param string $tabindex index number for tabindex attribute of input element
3021 * @param string $big
3022 * @param string $tplt
3024 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3027 static $cache = array();
3029 if ( !array_key_exists('id', $cache) )
3031 $cache['id'] = intRequestVar('templateid');
3034 if ( !array_key_exists('name', $cache) )
3036 $cache['name'] = Template::getNameFromId($cache['id']);
3039 if ( !array_key_exists('desc', $cache) )
3041 $cache['desc'] = Template::getDesc($cache['id']);
3044 $template =& $manager->getTemplate($cache['name']);
3049 echo (integer) $cache['id'];
3052 echo Entity::hsc($cache['name']);
3055 echo Entity::hsc($cache['desc']);
3057 case 'extratemplate':
3059 $pluginfields = array();
3060 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3065 $tmplt =& $manager->getTemplate($desc);
3067 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3071 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3075 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3078 foreach ( $pluginfields as $pfkey => $pfvalue )
3080 $data = array('explugtplname' => Entity::hsc($pfkey));
3082 echo Template::fill($base, $data);
3084 foreach ( $pfvalue as $pffield => $pfdesc )
3086 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3091 $desc = defined($desc) ? constant($desc) : $desc;
3092 $name = defined($name) ? constant($name) : $name;
3093 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3100 * AdminActions::parse_eventformextra()
3101 * Parse skinvar eventformextra
3103 * @param string $type name of type for event form extra
3106 public function parse_eventformextra($type = 'activation')
3115 $key = requestVar('ackey');
3118 Admin::error(_ERROR_ACTIVATE);
3120 $info = MEMBER::getActivationInfo($key);
3123 Admin::error(_ERROR_ACTIVATE);
3125 $mem =& $manager->getMember($info->vmember);
3128 Admin::error(_ERROR_ACTIVATE);
3131 'type' => 'activation',
3135 case 'membermailform-notloggedin':
3136 $data = array('type' => 'membermailform-notloggedin',);
3139 $manager->notify('FormExtra', $data);
3144 * AdminActions::parse_extrahead()
3145 * Parse skinvar extrahead
3147 public function parse_extrahead()
3151 $extrahead = Admin::getAdminextrahead();
3154 'extrahead' => &$extrahead,
3155 'action' => Admin::getAdminAction()
3158 $manager->notify('AdminPrePageHead', $data);
3164 * AdminActions::parse_member()
3165 * Parse skinvar member
3166 * (includes a member info thingie)
3168 * @param string $what which memberdata is needed
3171 public function parse_member($what)
3173 global $memberinfo, $member, $CONF;
3175 // 1. only allow the member-details-page specific variables on member pages
3176 if ( $this->skintype == 'member' )
3181 echo Entity::hsc($memberinfo->getDisplayName());
3184 echo Entity::hsc($memberinfo->getRealName());
3187 echo Entity::hsc($memberinfo->getNotes());
3190 echo Entity::hsc($memberinfo->getURL());
3193 echo Entity::hsc($memberinfo->getEmail());
3196 echo Entity::hsc($memberinfo->getID());
3201 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3202 if ( $member->isLoggedIn() )
3207 echo $member->getDisplayName();
3209 case 'yourrealname':
3210 echo $member->getRealName();
3213 echo $member->getNotes();
3216 echo $member->getURL();
3219 echo $member->getEmail();
3222 echo $member->getID();
3224 case 'yourprofileurl':
3225 if ( $CONF['URLMode'] == 'pathinfo' )
3227 echo Link::create_member_link($member->getID());
3231 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3240 * AdminActions::parse_version()
3241 * Parse skinvar version
3242 * (include nucleus versionnumber)
3247 public function parse_version()
3250 echo 'Nucleus CMS ' . $nucleus['version'];
3255 * AdminActions::parse_sitevar()
3256 * Parse skinvar sitevar
3257 * (include a sitevar)
3259 * @param string $which
3262 public function parse_sitevar($which)
3268 echo $CONF['IndexURL'];
3271 echo $CONF['SiteName'];
3274 echo $CONF['AdminEmail'];
3277 echo $CONF['AdminURL'];
3284 * AdminActions::parse_actionurl()
3290 public function parse_actionurl()
3293 echo Entity::hsc($CONF['ActionURL']);
3298 * AdminActions::parse_getblogsetting()
3299 * Parse skinvar getblogsetting
3301 public function parse_getblogsetting($which)
3303 global $blog, $manager;
3309 elseif ( $bid = intRequestVar('blogid') )
3311 $b =& $manager->getBlog($bid);
3321 return Entity::hsc($b->getID());
3324 return Entity::hsc($b->getURL());
3327 return Entity::hsc($b->getName());
3330 return Entity::hsc($b->getDescription());
3333 return Entity::hsc($b->getShortName());
3335 case 'notifyaddress':
3336 return Entity::hsc($b->getNotifyAddress());
3339 return Entity::hsc($b->getMaxComments());
3342 return Entity::hsc($b->getUpdateFile());
3345 return Entity::hsc($b->getTimeOffset());
3352 * AdminActions::parse_geteditpluginfo()
3353 * Parse skinvar geteditpluginfo
3355 * @param string $type name of setting for edit plugin info
3358 public function parse_geteditpluginfo($type)
3361 $pid = intRequestVar('plugid');
3368 return Entity::hsc($manager->getPluginNameFromPid($pid));
3375 * AdminActions::parse_getmember()
3376 * Parse skinvar getmember
3377 * (includes a member info thingie)
3379 * @param string $what name of setting for member
3382 public function parse_getmember($what)
3384 global $memberinfo, $member;
3385 // 1. only allow the member-details-page specific variables on member pages
3386 if ( $this->skintype == 'member' )
3391 return Entity::hsc($memberinfo->getDisplayName());
3394 return Entity::hsc($memberinfo->getRealName());
3397 return Entity::hsc($memberinfo->getNotes());
3400 return Entity::hsc($memberinfo->getURL());
3403 return Entity::hsc($memberinfo->getEmail());
3406 return Entity::hsc($memberinfo->getID());
3410 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3411 if ( $member->isLoggedIn() )
3416 return $member->getDisplayName();
3418 case 'yourrealname':
3419 return $member->getRealName();
3422 return $member->getNotes();
3425 return $member->getURL();
3428 return $member->getEmail();
3431 return $member->getID();
3439 * AdminActions::parse_headmessage()
3440 * Parse skinvar headmessage
3445 public function parse_headmessage()
3447 if ( !empty(Admin::$headMess) )
3449 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3455 * AdminActions::parse_helplink()
3456 * Parse skinvar helplink
3458 * @param string $topic name of topic for help
3461 public function parse_helplink($topic = '')
3463 if ( !empty($topic) )
3471 * AdminActions::parse_helpplugname()
3472 * Parse skinvar helpplugname
3477 public function parse_helpplugname()
3479 $plugid = intGetVar('plugid');
3480 Entity::hsc($manager->getPluginNameFromPid($plugid));
3485 * AdminActions::parse_ilistaddnew()
3486 * Parse skinvar ilistaddnew
3491 public function parse_ilistaddnew()
3493 $blogid = intRequestVar('blogid');
3494 if ( intPostVar('start') == 0 )
3496 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3502 * AdminActions::parse_importskininfo()
3503 * Parse skinvar importskininfo
3505 * @param string $type name of information for imported skin
3508 public function parse_importskininfo($type)
3513 echo Entity::hsc(requestVar('skininfo'));
3516 $dataArr = requestArray('skinnames');
3517 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3520 $dataArr = requestArray('tpltnames');
3521 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3524 $dataArr = requestArray('skinclashes');
3525 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3528 $dataArr = requestArray('tpltclashes');
3529 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3532 echo Entity::hsc(requestVar('skinfile'));
3535 echo Entity::hsc(requestVar('mode'));
3542 * AdminActions::parse_inputyesno()
3543 * Parse skinvar inputyesno
3545 * some init stuff for all forms
3550 public function parse_init()
3555 if ( requestVar('action') == 'itemedit' )
3557 $authorid = Admin::$contents['authorid'];
3560 Admin::$blog->insertJavaScriptInfo($authorid);
3565 * AdminActions::parse_inputyesno()
3566 * Parse skinvar inputyesno
3568 * @param string $name
3569 * @param string $checkedval
3570 * @param string $tabindex
3571 * @param string $value1
3572 * @param string $value2
3573 * @param string $yesval
3574 * @param string $noval
3575 * @param string $isAdmin
3576 * @param string $templateName
3579 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3581 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3586 * AdminActions::parse_insertpluginfo()
3587 * Parse templatevar insertpluginfo
3589 public function parse_insertpluginfo($type)
3591 $option = Admin::getAdminaOption();
3595 return $option['pid'];
3598 return Entity::hsc($option['pfile']);
3605 * AdminActions::parse_insplugoptcontent()
3606 * Parse skinvar insplugoptcontent
3611 public function parse_insplugoptcontent()
3613 $option = Admin::getAdminaOption();
3615 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3616 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3619 listplug_plugOptionRow($option);
3626 * AdminActions::parse_iprangeinput()
3627 * Parse skinvar iprangeinput
3632 public function parse_iprangeinput()
3634 if ( requestVar('ip') )
3636 $iprangeVal = Entity::hsc(requestVar('ip'));
3637 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3638 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3639 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3640 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3641 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3645 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3646 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3652 * AdminActions::parse_itemnavlist()
3653 * Parse skinvar itemnavlist
3658 public function parse_itemnavlist($templateName)
3660 global $CONF, $manager, $member;
3662 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3663 . " FROM %s, %s, %s, %s"
3664 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3666 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3668 if ( $this->skintype == 'itemlist' )
3671 if ( array_key_exists('blogid', $_REQUEST) )
3673 $blogid = intRequestVar('blogid');
3675 else if ( array_key_exists('itemid', $_REQUEST) )
3677 $itemid = intRequestVar('itemid');
3678 $item = &$manager->getItem($itemid, 1, 1);
3679 $blogid = (integer) $item['blogid'];
3681 $blog =& $manager->getBlog($blogid);
3683 $query .= " AND iblog={$blogid}";
3684 $template['now'] = $blog->getCorrectTime(time());
3686 // non-blog-admins can only edit/delete their own items
3687 if ( !$member->blogAdminRights($blogid) )
3689 $query .= ' AND iauthor = ' . $member->getID();
3692 elseif ( $this->skintype == 'browseownitems' )
3694 $query .= ' AND iauthor = ' . $member->getID();
3696 $template['now'] = time();
3699 // search through items
3700 $search = postVar('search');
3702 if ( !empty($search) )
3704 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3705 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3706 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3709 if ( postVar('start') )
3711 $start = intPostVar('start');
3718 // amount of items to show
3719 if ( postVar('amount') )
3721 $amount = intPostVar('amount');
3725 $amount = (integer) $CONF['DefaultListSize'];
3732 $query .= ' ORDER BY itime DESC'
3733 . " LIMIT {$start},{$amount}";
3735 $template['content'] = 'itemlist';
3737 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3738 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3743 * AdminActions::parse_itemtime()
3744 * date change on edit item
3746 * @param string $key key of PHP's getDate()
3749 public function parse_itemtime($key)
3754 $itemid = intRequestVar('itemid');
3755 $item =& $manager->getItem($itemid, 1, 1);
3757 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3759 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3761 $item['body'] = removeBreaks($item['body']);
3762 $item['more'] = removeBreaks($item['more']);
3765 $contents = array();
3766 if ( requestVar('action') == 'itemedit' )
3770 elseif ( requestVar('action') == 'createitem' )
3773 'contents' => &$contents,
3774 'blog' => &$this->blog
3776 $manager->notify('PreAddItemForm', $data);
3778 $itemtime = getdate($contents['timestamp']);
3779 echo $itemtime[$key];
3784 * AdminActions::parse_jstoolbaroptions()
3785 * Parse skinvar jstoolbaroptions
3790 public function parse_jstoolbaroptions()
3794 _SETTINGS_JSTOOLBAR_NONE,
3795 _SETTINGS_JSTOOLBAR_SIMPLE,
3796 _SETTINGS_JSTOOLBAR_FULL
3800 foreach ( $options as $option )
3802 $text = "<option value=\"%d\"%s>%s</option>\n";
3803 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3804 echo sprintf($text, $i, $extra, $option);
3810 * AdminActions::parse_localeselectoptions()
3811 * Parse skinvar localeselectoptions
3816 public function parse_localeselectoptions()
3820 $locales = i18n::get_available_locale_list();
3822 $memid = intRequestVar('memberid');
3825 $mem =& $manager->getMember($memid);
3826 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3828 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3832 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3837 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3839 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3843 echo "<option value=\"\">en_Latn_US</option>\n";
3846 foreach ( $locales as $locale )
3848 if ( $locale == 'en_Latn_US' )
3854 if ( $locale == $mem->getLocale() )
3856 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3860 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3865 if ( $locale == i18n::get_current_locale() )
3867 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3871 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3879 * AdminActions::parse_listplugplugoptionrow()
3880 * Parse templatevar listplugplugoptionrow
3882 * @param string $templateName name of template
3885 public function parse_listplugplugoptionrow($templateName = '')
3887 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3892 * AdminActions::parse_mediadirwarning()
3893 * Parse skinvar mediadirwarning
3898 public function parse_mediadirwarning()
3901 if ( !is_dir($DIR_MEDIA) )
3903 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3905 if ( !is_readable($DIR_MEDIA) )
3907 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3909 if ( !is_writeable($DIR_MEDIA) )
3911 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3917 * AdminActions::parse_movedistselect()
3918 * Parse skinvar movedistselect
3920 public function parse_movedistselect()
3922 $actionType = requestVar('action');
3923 switch ( $actionType )
3926 $this->selectBlog('destcatid', 'category');
3928 case 'batchcategory':
3929 $this->selectBlog('destblogid');
3932 if ( $this->skintype == 'itemmove' )
3934 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3935 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3936 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3937 $this->selectBlog('catid', 'category', $catid, 10, 1);
3945 * AdminActions::parse_moveitemid()
3946 * Parse skinvar moveitemid
3951 public function parse_moveitemid()
3953 echo intRequestVar('itemid');
3958 * AdminActions::parse_newestcompare()
3959 * Parse skinvar newestcompare
3964 public function parse_newestcompare()
3968 $newestVersion = getLatestVersion();
3969 $newestCompare = str_replace('/', '.', $newestVersion);
3970 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3972 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3974 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3975 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3981 * AdminActions::parse_newmemberselect()
3982 * Parse skinvar newmemberselect
3984 * @param string $templateName name of template to use
3987 public function parse_newmemberselect($templateName = '')
3989 $blogid = intRequestVar('blogid');
3991 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3992 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3993 $res = DB::getResult($query);
3996 foreach ( $res as $row )
3998 $tmem[] = intval($row['tmember']);
4001 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4002 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4005 'name' => 'memberid',
4006 'tabindex' => 10000,
4009 Showlist($query, 'select', $template, $templateName);
4014 * AdminActions::parse_newpluginlist()
4015 * Parse skinvar newpluginlist
4020 public function parse_newpluginlist()
4022 $candidates = $this->newPlugCandidates;
4023 foreach ( $candidates as $name )
4025 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4031 * AdminActions::parse_outputspecialdirs()
4032 * Parse skinvar outputspecialdirs
4034 * @param string $type type of setting for directory
4037 public function parse_outputspecialdirs($type)
4039 global $DIR_MEDIA, $DIR_NUCLEUS;
4044 echo Entity::hsc($DIR_NUCLEUS);
4047 echo Entity::hsc($DIR_MEDIA);
4054 * AdminActions::parse_passrequestvars()
4055 * Parse skinvar passrequestvars
4060 public function parse_passrequestvars()
4062 $passvar = Admin::getAdminpassvar();
4063 $oldaction = postVar('oldaction');
4065 if ( ($oldaction != 'logout')
4066 && ($oldaction != 'login')
4068 && !postVar('customaction') )
4076 * AdminActions::parse_pluginextras()
4077 * Parse skinvar pluginextras
4079 * @param string $type type of plugin context
4082 public function parse_pluginextras($type = 'global')
4089 $id = intRequestVar('memberid');
4090 $mem =& $manager->getMember($id);
4091 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4094 $id = intRequestVar('blogid');
4095 $blg =& $manager->getBlog($id);
4096 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4098 case 'createaccount':
4100 'type' => 'createaccount.php',
4102 'postlabel' => '<br />',
4104 'postfield' => '<br /><br />'
4106 $manager->notify('RegistrationFormExtraFields', $data);
4109 $manager->notify('GeneralSettingsFormExtras', array());
4116 * AdminActions::parse_pluginhelp()
4117 * Parse skinvar pluginhelp
4122 public function parse_pluginhelp()
4124 global $manager, $DIR_PLUGINS;
4126 $plugid = intGetVar('plugid');
4127 $plugName = $manager->getPluginNameFromPid($plugid);
4128 $plug =& $manager->getPlugin($plugName);
4130 if ( $plug->supportsFeature('HelpPage') > 0 )
4132 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4133 if ( @file_exists($helpfile . 'php') )
4135 @include($helpfile . 'php');
4138 elseif ( @file_exists($helpfile . 'html') )
4140 @include($helpfile . 'html');
4144 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4145 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4150 * AdminActions::parse_pluginlistlist()
4151 * Parse skinvar pluginlistlist
4153 * @param string $templateName name of template to use
4156 public function parse_pluginlistlist($templateName = '')
4158 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4159 $query = sprintf($query, sql_table('plugin'));
4161 $template['content'] = 'pluginlist';
4162 $template['tabindex'] = 10;
4164 Showlist($query, 'table', $template, $templateName);
4170 * AdminActions::parse_pluginoptions()
4171 * Parse skinvar pluginoptions
4173 * @param string $type type of plugin option
4176 public function parse_pluginoptions($context='global', $templateName='')
4178 global $itemid, $manager;
4183 $contextid = intRequestVar('memberid');
4186 $contextid = intRequestVar('blogid');
4189 $contextid = intRequestVar('catid');
4192 $contextid = $itemid;
4196 /* Actually registererd plugin options */
4197 $aIdToValue = array();
4198 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4199 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4200 $res = DB::getResult($query);
4201 foreach ( $res as $row )
4203 $aIdToValue[$row['oid']] = $row['ovalue'];
4206 /* Currently available plugin options */
4207 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4208 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4209 $res = DB::getResult($query);
4212 foreach ($res as $row )
4214 if ( !array_key_exists($row['oid'], $aIdToValue) )
4216 $value = $row['odef'];
4220 $value = $aIdToValue[$row['oid']];
4224 'pid' => $row['pid'],
4225 'pfile' => $row['pfile'],
4226 'oid' => $row['oid'],
4228 'name' => $row['oname'],
4229 'description' => $row['odesc'],
4230 'type' => $row['otype'],
4231 'typeinfo' => $row['oextra'],
4232 'contextid' => $contextid,
4238 'context' => $context,
4239 'contextid' => $contextid,
4240 'options' => &$options
4242 $manager->notify('PrePluginOptionsEdit', $data);
4244 $template = array();
4245 if ( $templateName )
4247 $templates =& $manager->getTemplate($templateName);
4248 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4250 $template['title'] = "<tr>"
4251 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4256 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4259 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4261 $template['body'] = "<tr>"
4262 . "<%listplugplugoptionrow%>"
4267 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4273 include_libs('ACTIONS.php');
4274 $handler = new Actions($this->skintype);
4275 $parser = new PARSER($handler);
4277 foreach ( $options as $option )
4280 if ( $prevPid != $option['pid'] )
4282 $prevPid = $option['pid'];
4283 $parser->parse($template['title']);
4286 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4288 if ( @$meta['access'] != 'hidden' )
4290 $parsed = $parser->parse($template['body']);
4298 * AdminActions::parse_qmenuaddselect()
4299 * Parse skinvar qmanuaddselect
4301 * @param string $templateName name of template to use
4304 public function parse_qmenuaddselect($templateName = '')
4307 $showAll = requestVar('showall');
4308 if ( $member->isAdmin() && ($showAll == 'yes') )
4310 // Super-Admins have access to all blogs! (no add item support though)
4311 $query = 'SELECT bnumber as value, bname as text'
4312 . ' FROM ' . sql_table('blog')
4313 . ' ORDER BY bname';
4317 $query = 'SELECT bnumber as value, bname as text'
4318 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4319 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4320 . ' ORDER BY bname';
4323 $template['name'] = 'blogid';
4324 $template['tabindex'] = 15000;
4325 $template['extra'] = _QMENU_ADD_SELECT;
4326 $template['selected'] = -1;
4327 $template['shorten'] = 10;
4328 $template['shortenel'] = '';
4329 $template['javascript'] = 'onchange="return form.submit()"';
4331 Showlist($query, 'select', $template, $templateName);
4337 * AdminActions::parse_quickmenu()
4338 * Parse skinvar quickmenu
4340 * @param string $templateName name of template to use
4343 public function parse_quickmenu($templateName = '')
4346 $templates = array();
4347 $template = array();
4348 if ( !empty($templateName) )
4350 $templates = & $manager->getTemplate($templateName);
4352 $pluginExtras = array();
4356 'options' => &$pluginExtras
4359 if ( count($pluginExtras) > 0 )
4361 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4363 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4367 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4369 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4371 $template['head'] = "<ul>\n";
4375 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4377 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4379 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4383 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4385 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4387 $template['foot'] = "</ul>\n";
4391 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4394 $handler = new Actions($this->skintype);
4395 $parser = new PARSER($handler);
4397 $parser->parse($template['title']);
4398 echo $template['head'];
4399 foreach ( $pluginExtras as $aInfo )
4402 'plugadminurl' => Entity::hsc($aInfo['url']),
4403 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4404 'plugadmintitle' => Entity::hsc($aInfo['title']),
4406 echo Template::fill($template['body'], $data);
4408 echo $template['foot'];
4414 * AdminActions::parse_requestblogid()
4415 * Parse skinvar requestblogid
4420 public function parse_requestblogid()
4422 echo intRequestVar('blogid');
4427 * AdminActions::parse_requestiprange()
4428 * Parse skinvar requestiprange
4433 public function parse_requestiprange()
4435 if ( requestVar('iprange') )
4437 echo Entity::hsc(requestVar('iprange'));
4439 elseif ( requestVar('ip') )
4441 echo Entity::hsc(requestVar('ip'));
4447 * AdminActions::parse_selectlocaladminskinfiles()
4448 * Parse skinvar selectlocaladminskinfiles
4453 public function parse_selectlocaladminskinfiles()
4455 global $DIR_SKINS, $manager, $DIR_LIBS;
4457 if ( !class_exists('SkinImport', FALSE) )
4459 include_once("{$DIR_LIBS}skinie.php");
4461 $adminskindir = $DIR_SKINS . 'admin/';
4462 $candidates = SkinImport::searchForCandidates($adminskindir);
4464 foreach ( $candidates as $skinname => $skinfile )
4466 $html = Entity::hsc($skinfile);
4467 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4474 * AdminActions::parse_selectlocalskinfiles()
4475 * Parse skinvar selectlocalskinfiles
4480 public function parse_selectlocalskinfiles()
4484 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4486 foreach ( $candidates as $skinname => $skinfile )
4488 $html = Entity::hsc($skinfile);
4489 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4496 * AdminActions::parse_skineditallowedlist()
4497 * Parse skinvar skineditallowedlist
4499 * @param string $type type of skin
4500 * @param string $templateName name of template
4503 public function parse_skineditallowedlist($type, $templateName = '')
4508 $query = "SELECT bshortname, bname FROM %s;";
4510 'content' => 'shortblognames'
4512 $query = sprintf($query, sql_table('blog'));
4513 Showlist($query, 'table', $show, $templateName);
4516 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4518 'content' => 'shortnames'
4520 $query = sprintf($query, sql_table('template_desc'));
4521 Showlist($query, 'table', $show, $templateName);
4528 * AdminActions::parse_skinielist()
4529 * Parse skinvar skinielist
4531 * @param string $type type of skin
4532 * @param string $templateName name of template to use
4535 public function parse_skinielist($type, $templateName = '')
4539 $templates = array();
4540 if ( $templateName )
4542 $templates =& $manager->getTemplate($templateName);
4544 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4546 $template = $templates['SKINIE_EXPORT_LIST'];
4551 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4552 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4554 . "<td><%expdesc%></td>\n"
4561 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4562 foreach ( $res as $row )
4565 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4566 'expid' => 'skinexp' . $row['sdnumber'],
4567 'expname' => Entity::hsc($row['sdname']),
4568 'expdesc' => Entity::hsc($row['sddesc'])
4570 echo Template::fill($template, $data);
4574 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4575 foreach ( $res as $row )
4578 'typeid' => 'template[' . $row['tdnumber'] . ']',
4579 'expid' => 'templateexp' . $row['tdnumber'],
4580 'expname' => Entity::hsc($row['tdname']),
4581 'expdesc' => Entity::hsc($row['tddesc'])
4583 echo Template::fill($template, $data);
4591 * AdminActions::parse_skinoverview()
4592 * Parse skinvar skinoverview
4594 * @param string $templateName name of template to use
4597 public function parse_skinoverview($templateName = '')
4600 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4601 $query = sprintf($query, sql_table('skin_desc'));
4603 $template['content'] = 'skinlist';
4604 $template['tabindex'] = 10;
4606 Showlist($query, 'table', $template, $templateName);
4611 * AdminActions::parse_skintypehelp()
4612 * Check editing skintypehelp
4617 public function parse_skintypehelp()
4619 $nowSkinType = strtolower(trim(requestVar('type')));
4620 $pageAction = strtolower(trim(requestVar('action')));
4621 if ( preg_match('/^admin.*/', $pageAction) )
4623 $regularType = self::$default_skin_types;
4624 unset($regularType['memberedit']);
4625 unset($regularType['login']);
4626 $regularType = array_keys($regularType);
4630 /* TODO: use Skin class */
4631 $regularType = array(
4643 if ( in_array($nowSkinType, $regularType) )
4645 help('skinpart' . $nowSkinType);
4649 help('skinpartspecial');
4655 * AdminActions::parse_specialskinlist()
4656 * Parse skinvar specialskinlist
4658 * @param string $templateName name of template to use
4661 public function parse_specialskinlist($templateName = '')
4665 $templates = array();
4666 if ( $templateName )
4668 $templates =& $manager->getTemplate($templateName);
4671 /* TODO: use Skin class */
4682 $skinid = intRequestVar('skinid');
4683 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4684 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4686 $res = DB::getResult($query);
4687 if ( $res && $res->rowCount() > 0 )
4690 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4692 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4696 $template['head'] = "<ul>\n";
4698 echo Template::fill($template['head'], $data);
4699 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4701 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4702 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4703 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4707 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4711 foreach ( $res as $row )
4714 'tabindex' => $tabstart++,
4715 'skinid' => $skinid,
4716 'skintype' => Entity::hsc(strtolower($row['stype']))
4718 echo Template::fill($template['body'], $data);
4721 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4723 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4727 $template['foot'] = "</ul>\n";
4729 echo Template::fill($template['foot'], $data);
4735 * AdminActions::parse_sprinttext()
4738 * @param string $which
4739 * @param string $val
4742 public function parse_sprinttext($which, $val)
4744 if ( !defined($which) )
4750 $base = constant($which);
4753 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4755 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4757 $met = 'parse_' . $matchies[0];
4761 $arg = trim($args[0], '()');
4762 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4765 if ( method_exists($this, $met) )
4767 $value = call_user_func(array(&$this, $met), $arg);
4771 if ( !isset($value) || empty($value) )
4775 echo sprintf($base, $value);
4780 * AdminActions::parse_systemsettings()
4781 * Parse skinvar systemsettings
4783 * @param string $type type of settings for system
4784 * @param string $templateName name of template to use
4787 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4789 global $manager, $member, $CONF, $nucleus;
4791 $member->isAdmin() or Admin::disallow();
4793 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4794 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4801 case 'sqlserverinfo':
4802 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4804 case 'sqlclientinfo':
4805 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4807 case 'magicquotesgpc':
4808 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4810 case 'magicquotesruntime':
4811 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4813 case 'registerglobals':
4814 echo ini_get('register_globals') ? 'On' : 'Off';
4817 $templates = array();
4818 if ( $templateName )
4820 $templates =& $manager->getTemplate($templateName);
4822 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4824 $template = "<tr>\n"
4825 . "<td><%key%></td>\n"
4826 . "<td><%value%></td>\n"
4831 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4834 $gdinfo = gd_info();
4836 foreach ( $gdinfo as $key => $value )
4838 if ( is_bool($value) )
4840 $value = $value ? $enable : $disable;
4844 $value = Entity::hsc($value);
4850 echo Template::fill($template, $data);
4855 phpinfo(INFO_MODULES);
4856 $im = ob_get_contents();
4858 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4860 case 'nucleusversion':
4861 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4863 case 'nucleuspatchlevel':
4864 echo getNucleusPatchLevel();
4870 echo $CONF['ItemURL'];
4872 case 'alertonheaderssent':
4873 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4875 case 'nucleuscodename':
4876 if ( $nucleus['codename'] != '' )
4878 echo ' "' . $nucleus['codename'] . '"';
4881 case 'versioncheckurl':
4882 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4889 * AdminActions::parse_templateoverview()
4890 * Parse skinvar templateoverview
4892 * @param string $templateName name of template to use
4895 public function parse_templateoverview($templateName = '')
4897 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4898 $query = sprintf($query, sql_table('template_desc'));
4900 $template['content'] = 'templatelist';
4901 $template['tabindex'] = 10;
4903 Showlist($query, 'table', $template, $templateName);
4909 * AdminActions::parse_ticket()
4915 public function parse_ticket()
4918 $manager->addTicketHidden();
4923 * AdminActions::parse_versioncheckurl()
4924 * Parse skinvar versioncheckurl
4929 public function parse_versioncheckurl()
4931 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4936 * AdminActions::parse_yrbloglist()
4937 * Parse skinvar yrbloglist
4939 * @param string $templateName name of template to use
4942 public function parse_yrbloglist($templateName = '')
4945 $showAll = requestVar('showall');
4947 if ( $member->isAdmin() && ($showAll == 'yes') )
4949 // Super-Admins have access to all blogs! (no add item support though)
4950 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4952 . " ORDER BY bnumber;";
4953 $query = sprintf($query, sql_table('blog'));
4957 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4959 . " WHERE tblog=bnumber and tmember=%d"
4960 . " ORDER BY bnumber;";
4961 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4964 $template['content'] = 'bloglist';
4965 $template['superadmin'] = $member->isAdmin();
4967 $amount = Showlist($query, 'table', $template, $templateName);
4969 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4971 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4973 $total = DB::getValue($query);
4974 if ( $total > $amount )
4976 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4982 echo _OVERVIEW_NOBLOGS;
4984 elseif( $amount != 0 )
4986 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4988 $query = "SELECT ititle, inumber, bshortname"
4990 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4991 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4993 $template['content'] = 'draftlist';
4995 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4996 if ( $amountdrafts == 0 )
4998 echo _OVERVIEW_NODRAFTS;
5005 * AdminActions::checkCondition()
5006 * Checks conditions for if statements
5008 * @param string $field type of <%if%>
5009 * @param string $name property of field
5010 * @param string $value value of property
5011 * @return boolean condition
5013 protected function checkCondition($field, $name='', $value = '')
5015 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
5025 $blog =& $manager->getBlog($blogid);
5029 $blogid = getBlogIDFromCatID($catid);
5030 $blog =& $manager->getBlog($blogid);
5032 elseif ( intRequestVar('catid') )
5034 $catid = intRequestVar('catid');
5035 $blogid = getBlogIDFromCatID($catid);
5036 $blog =& $manager->getBlog($blogid);
5043 $condition = ($blog && $this->ifCategory($name, $value));
5046 $condition = $member->isLoggedIn();
5049 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5052 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5055 $condition = $member->isLoggedIn() && $member->isAdmin();
5057 case 'allowloginedit':
5058 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5061 $condition = ($itemidnext != '');
5064 $condition = ($itemidprev != '');
5066 case 'archiveprevexists':
5067 $condition = ($archiveprevexists == true);
5069 case 'archivenextexists':
5070 $condition = ($archivenextexists == true);
5073 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5076 $condition = $this->ifHasPlugin($name, $value);
5079 $condition = (Admin::getAdminAction() == $name);
5081 case 'adminoldaction':
5082 $condition = (Admin::getAdminAction() == $name);
5084 case 'addresschange':
5085 $condition = ($this->ifAddresscange());
5087 case 'bechangepass':
5088 $condition = ($this->beChangePassword());
5090 case 'skincandidates':
5091 $condition = ($this->ifSkincandidates());
5094 $condition = requestVar('nameclashes');
5096 case 'existsnewplugin':
5097 $condition = ($this->existsNewPlugin());
5104 $condition = (boolean) ($member->getAutosave() == $value);
5111 $condition = (Admin::$blog->getSetting($name) == $value);
5113 case 'itemproperty':
5118 if ( array_key_exists($name, Admin::$contents) )
5120 $condition = (boolean) (Admin::$contents[$name] == $value);
5124 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5131 * AdminActions::_ifHasPlugin()
5132 * hasplugin,PlugName
5133 * -> checks if plugin exists
5134 * hasplugin,PlugName,OptionName
5135 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5136 * hasplugin,PlugName,OptionName=value
5137 * -> checks if the option OptionName from plugin PlugName is set to value
5139 * @param string $name name of plugin
5140 * @param string $value
5143 private function ifHasPlugin($name, $value)
5147 // (pluginInstalled method won't write a message in the actionlog on failure)
5148 if ( $manager->pluginInstalled("NP_{$name}") )
5150 $plugin =& $manager->getPlugin("NP_{$name}");
5151 if ( $plugin != NULL )
5159 list($name2, $value2) = preg_split('#=#', $value, 2);
5160 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5164 else if ( $plugin->getOption($name2) == $value2 )
5175 * AdminActions::beChangePassword()
5180 private function beChangePassword()
5182 return intRequestVar('bNeedsPasswordChange');
5186 * AdminActions::ifSkincandidates()
5187 * Checks if a plugin exists and call its doIf function
5193 private function ifSkincandidates()
5196 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5197 return (count($candidates) > 0);
5201 * AdminActions::ifPlugin()
5202 * Checks if a plugin exists and call its doIf function
5204 * @param string $name name of plugin
5205 * @param string $key
5206 * @param string $value
5209 private function ifPlugin($name, $key = '', $value = '')
5213 $plugin =& $manager->getPlugin("NP_{$name}");
5219 $params = func_get_args();
5220 array_shift($params);
5222 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5226 * AdminActions::ifCategory()
5227 * Different checks for a category
5229 * @param string $key key for information of category
5230 * @param string $value value for information of category
5233 private function ifCategory($key = '', $value='')
5235 global $blog, $catid;
5237 // when no parameter is defined, just check if a category is selected
5238 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5240 return $blog->isValidCategory($catid);
5243 // check category name
5244 if ( $key == 'catname' )
5246 $value = $blog->getCategoryIdFromName($value);
5247 if ($value == $catid)
5249 return $blog->isValidCategory($catid);
5253 // check category id
5254 if (($key == 'catid') && ($value == $catid))
5256 return $blog->isValidCategory($catid);
5263 * AdminActions::ifOnTeam()
5264 * Checks if a member is on the team of a blog and return his rights
5266 * @param string $blogName name of weblog
5269 private function ifOnTeam($blogName = '')
5271 global $blog, $member, $manager;
5273 // when no blog found
5274 if ( ($blogName == '') && !is_object($blog) )
5279 // explicit blog selection
5280 if ($blogName != '')
5282 $blogid = getBlogIDFromName($blogName);
5285 if (($blogName == '') || !$manager->existsBlogID($blogid))
5288 $blogid = $blog->getID();
5290 return $member->teamRights($blogid);
5294 * AdminActions::ifAdmin()
5295 * Checks if a member is admin of a blog
5297 * @param string $blogName name of weblog
5300 private function ifAdmin($blogName = '')
5302 global $blog, $member, $manager;
5304 // when no blog found
5305 if (($blogName == '') && (!is_object($blog)))
5310 // explicit blog selection
5311 if ($blogName != '')
5313 $blogid = getBlogIDFromName($blogName);
5316 if (($blogName == '') || !$manager->existsBlogID($blogid))
5319 $blogid = $blog->getID();
5322 return $member->isBlogAdmin($blogid);
5326 * AdminActions::ifAddresscange()
5327 * Check e-Mail address is changed
5332 private function ifAddresscange()
5336 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5341 $info = MEMBER::getActivationInfo($key);
5346 $mem =& $manager->getMember($info->vmember);
5351 if ( $info->vtype == 'addresschange' )
5359 * AdminActions::templateEditRow()
5362 * @param array $template
5363 * @param string $desc
5364 * @param string $name
5365 * @param string $help
5366 * @param integer $tabindex
5367 * @param boolean $big
5368 * @param array $tmplt
5371 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5377 if ( !array_key_exists($name, $template) )
5379 $template[$name] = '';
5387 $tmplt =& $manager->getTemplate($tplt);
5391 'description' => $desc,
5392 'help' => empty($help) ? '' : helpHtml('template' . $help),
5395 'tabindex' => $tabindex,
5396 'rows' => $big ? 10 : 5,
5399 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5401 $base['head'] = "</tr>"
5403 . "<td><%description%><%help%></td>\n"
5404 . "<td id=\"td<%count%>\">\n"
5405 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5409 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5412 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5414 $base['tail'] = "</textarea>\n"
5419 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5422 echo TEMPLATE::fill($base['head'], $data);
5423 echo ENTITY::hsc($template[$name]);
5424 echo TEMPLATE::fill($base['tail'], $data);
5432 * AdminActions::customHelp()
5433 * shows a link to custom help file
5436 * @param string $tplName
5437 * @param string $url
5438 * @param string $iconURL
5439 * @param string $alt
5440 * @param string $title
5444 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5446 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5450 * AdminActions::customHelp()
5451 * shows a link to custom help file
5454 * @param string $tplName
5455 * @param string $url
5456 * @param string $iconURL
5457 * @param string $alt
5458 * @param string $title
5462 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5464 global $CONF, $manager;
5466 $templates = array();
5470 $templates =& $manager->getTemplate($tplName);
5473 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5475 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5479 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5484 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5487 if ( empty($onclick) )
5489 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5491 elseif ( preg_match('#^onclick#', $onclick) )
5493 $onclick = $onclick;
5497 $onclick = 'onclick="' . $onclick . '"';
5502 'helptarget' => $id,
5503 'onclick' => $onclick,
5504 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5506 return Template::fill($template, $data);
5510 * AdminActions::customHelpHtml()
5513 * @param string $tplName
5514 * @param string $url
5515 * @param string $iconURL
5516 * @param string $alt
5517 * @param string $title
5518 * @param string $onclick
5519 * @return string anchor element with help uri
5521 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5523 global $CONF, $manager;
5525 $templates = array();
5529 $templates =& $manager->getTemplate($tplName);
5531 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5533 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5537 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5540 if ( empty($iconURL) )
5542 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5545 if ( function_exists('getimagesize') )
5547 $size = getimagesize($iconURL);
5548 $width = 'width="' . $size[0] . '" ';
5549 $height = 'height="' . $size[1] . '" ';
5553 'iconurl' => $iconURL,
5555 'height' => $height,
5556 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5557 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5560 $icon = Template::fill($template, $data);
5561 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5563 return $help . $icon;
5567 * AdminActions::input_yesno
5570 * @param $checkedval
5577 * @param $templateName
5580 public function input_yesno($name,
5593 $templates = array();
5594 if ( $templateName )
5596 $templates =& $manager->getTemplate($templateName);
5599 if ( $name == 'admin' )
5601 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5603 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5604 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5605 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5606 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5610 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5615 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5617 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5621 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5623 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5626 if ( !isset($template) )
5628 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5629 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5630 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5631 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5636 $id = Entity::hsc($name);
5637 $id = str_replace('[', '-', $id);
5638 $id = str_replace(']', '-', $id);
5639 $id1 = $id . Entity::hsc($value1);
5640 $id2 = $id . Entity::hsc($value2);
5642 'name' => Entity::hsc($name),
5643 'yesval' => Entity::hsc($value1),
5644 'noval' => Entity::hsc($value2),
5647 'yesvaltext' => $yesval,
5648 'novaltext' => $noval,
5649 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5650 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5651 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5656 return Template::fill($template, $dat);
5660 echo Template::fill($template, $dat);
5666 * AdminActions::existsNewPlugin()
5667 * Check exists new plugin
5670 * @return boolean exists or not
5672 private function existsNewPlugin()
5674 global $DIR_PLUGINS;
5676 $query = "SELECT * FROM %s;";
5677 $query = sprintf($query, sql_table('plugin'));
5678 $res = DB::getResult($query);
5680 $installed = array();
5681 foreach( $res as $row )
5683 $installed[] = $row['pfile'];
5686 $files = scandir($DIR_PLUGINS);
5688 $candidates = array();
5689 foreach ( $files as $file )
5691 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5693 if ( !in_array($matches[1], $installed) )
5695 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5699 $this->newPlugCandidates = $candidates;
5700 return (count($candidates) > 0);
5704 * AdminActions::pagehead()
5705 * Output admin page head
5710 public function parse_pagehead()
5712 global $member, $nucleus, $CONF, $manager;
5714 $extrahead = Admin::getAdminextrahead();
5716 'extrahead' => &$extrahead,
5717 'action' => Admin::getAdminAction()
5719 $manager->notify('AdminPrePageHead', $data);
5721 $content = $this->parser->skin->getContentFromDB('pagehead');
5724 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5728 if ( !array_key_exists('AdminCSS', $CONF) )
5730 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5731 $CONF['AdminCSS'] = 'original';
5735 /* HTTP 1.1 application for no caching */
5736 header("Cache-Control: no-cache, must-revalidate");
5737 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5739 $root_element = 'html';
5740 $charset = i18n::get_current_charset();
5741 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5742 $xml_version_info = self::$xml_version_info;
5743 $formal_public_identifier = self::$formal_public_identifier;
5744 $system_identifier = self::$system_identifier;
5745 $xhtml_namespace = self::$xhtml_namespace;
5747 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5748 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5749 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5751 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5754 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5756 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5757 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5758 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5759 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5760 echo "{$extrahead}\n";
5763 echo "<div id=\"adminwrapper\">\n";
5764 echo "<div class=\"header\">\n";
5765 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5767 echo "<div id=\"container\">\n";
5768 echo "<div id=\"content\">\n";
5769 echo "<div class=\"loginname\">\n";
5771 if ( !$member->isLoggedIn() )
5773 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5777 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5778 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5781 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5784 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5786 $codenamestring = '';
5790 $codenamestring = ' "' . $nucleus['codename'].'"';
5793 if ( $member->isLoggedIn() && $member->isAdmin() )
5795 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5796 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5798 $newestVersion = getLatestVersion();
5799 $newestCompare = str_replace('/', '.', $newestVersion);
5800 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5802 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5805 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5806 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5812 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5819 $this->parser->parse($content);
5826 * AdminActionss::pagefoot()
5827 * Output admin page foot include quickmenu
5832 public function parse_pagefoot()
5834 global $action, $member, $manager;
5837 'action' => Admin::getAdminAction()
5839 $manager->notify('AdminPrePageFoot', $data);
5841 $content = $this->parser->skin->getContentFromDB('pagefoot');
5844 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5846 echo '<h2>' . _LOGOUT . "</h2>\n";
5848 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5849 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5853 echo "<div class=\"foot\">\n";
5854 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5856 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5859 echo "<div id=\"quickmenu\">\n";
5861 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5864 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5867 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5868 echo "<form method=\"get\" action=\"index.php\">\n";
5870 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5872 $showAll = requestVar('showall');
5874 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5876 // Super-Admins have access to all blogs! (no add item support though)
5877 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5878 $query = sprintf($query, sql_table('blog'));
5882 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5883 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5885 $template['name'] = 'blogid';
5886 $template['tabindex'] = 15000;
5887 $template['extra'] = _QMENU_ADD_SELECT;
5888 $template['selected'] = -1;
5889 $template['shorten'] = 10;
5890 $template['shortenel'] = '';
5891 $template['javascript'] = 'onchange="return form.submit()"';
5892 showlist($query, 'select', $template);
5897 echo "<h2>{$member->getDisplayName()}</h2>\n";
5899 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5900 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5901 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5904 if ( $member->isAdmin() )
5906 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5908 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5909 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5910 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5911 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5912 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5913 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5914 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5917 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5919 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5920 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5921 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5925 $data = array('options' => array());
5927 $manager->notify('QuickMenu', $data);
5929 if ( count($data['options']) > 0 )
5931 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5933 foreach ( $data['options'] as $option )
5935 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5940 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5943 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5947 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5950 echo "<!-- quickmenu -->\n";
5953 echo "<!-- content -->\n";
5956 echo "<!-- container -->\n";
5959 echo "<!-- adminwrapper -->\n";
5967 $this->parser->parse($content);
5974 * AdminActions::selectBlog()
5975 * Inserts a HTML select element with choices for all blogs to which the user has access
5976 * mode = 'blog' => shows blognames and values are blogids
5977 * mode = 'category' => show category names and values are catids
5979 * @param string $name
5980 * @param string $mode
5981 * @param integer $selected
5982 * @param integer $tabindex
5983 * @param integer $showNewCat
5984 * @param integer $iForcedBlogInclude ID for weblog always included
5985 * @param $iForcedBlogInclude
5986 * ID of a blog that always needs to be included, without checking if the
5987 * member is on the blog team (-1 = none)
5990 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5992 global $member, $CONF;
5994 // 0. get IDs of blogs to which member can post items (+ forced blog)
5995 $aBlogIds = array();
5996 if ( $iForcedBlogInclude != -1 )
5998 $aBlogIds[] = intval($iForcedBlogInclude);
6001 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
6003 $query = "SELECT bnumber FROM %s ORDER BY bname;";
6004 $query = sprintf($query, sql_table('blog'));
6008 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
6009 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
6012 $rblogids = DB::getResult($query);
6013 foreach ( $rblogids as $row )
6015 if ( $row['bnumber'] != $iForcedBlogInclude )
6017 $aBlogIds[] = intval($row['bnumber']);
6021 if ( count($aBlogIds) == 0 )
6026 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
6028 // 1. select blogs (we'll create optiongroups)
6029 // (only select those blogs that have the user on the team)
6030 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
6031 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
6032 $blogs = DB::getResult($queryBlogs);
6034 if ( $mode == 'category' )
6036 if ( $blogs->rowCount() > 1 )
6040 foreach ( $blogs as $rBlog )
6042 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6044 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
6047 // show selection to create new category when allowed/wanted
6050 // check if allowed to do so
6051 if ( $member->blogAdminRights($rBlog['bnumber']) )
6053 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
6057 // 2. for each category in that blog
6058 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
6059 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
6060 $categories = DB::getResult($catQuery);
6061 foreach ( $categories as $rCat )
6063 if ( $rCat['catid'] == $selected )
6065 $selectText = ' selected="selected" ';
6071 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
6074 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6082 foreach ( $blogs as $rBlog )
6084 echo '<option value="' . $rBlog['bnumber'] . '"';
6085 if ( $rBlog['bnumber'] == $selected )
6087 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
6091 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";