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 = Template::read($templateName);
830 $key = postVar('ackey');
833 Admin::error(_ERROR_ACTIVATE);
836 $info = MEMBER::getActivationInfo($key);
839 Admin::error(_ERROR_ACTIVATE);
842 $mem = MEMBER::createFromId($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 = Template::read($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 = Template::read($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 = '')
1217 $templates = array();
1218 if ( $templateName )
1220 $templates = Template::read($templateName);
1223 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1226 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1227 . "<label for=\"<%expid%>\"><%expname%></label>"
1229 . "<td><%expdesc%></td>\n"
1235 $template = $templates['SKINIE_EXPORT_LIST'];
1241 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1242 $query = sprintf($query, sql_table('skin_desc'));
1243 $res = DB::getResult($query);
1245 foreach ( $res as $row )
1248 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1249 'expid' => 'skinexp' . $row['sdnumber'],
1250 'expname' => Entity::hsc($row['sdname']),
1251 'expdesc' => Entity::hsc($row['sddesc']),
1253 echo Template::fill($template, $data);
1257 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1258 $query = sprintf($query, sql_table('template_desc'));
1259 $res = DB::getResult($query);
1260 foreach ( $res as $row )
1263 'typeid' => 'template[' . $row['tdnumber'] . ']',
1264 'expid' => 'templateexp' . $row['tdnumber'],
1265 'expname' => Entity::hsc($row['tdname']),
1266 'expdesc' => Entity::hsc($row['tddesc']),
1268 echo Template::fill($template, $data);
1276 * AdminActions::parse_adminskinoverview()
1277 * Parse skinvar adminskinoverview
1279 * @param string $templateName name of template to use
1282 public function parse_adminskinoverview($templateName = '')
1284 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1285 $query = sprintf($query, sql_table('skin_desc'));
1287 $template['content'] = 'adminskinlist';
1288 $template['tabindex'] = 10;
1289 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1290 Showlist($query, 'table', $template, $templateName);
1295 * AdminActions::parse_adminskinselectoptions()
1296 * Parse skinvar adminskinselectoptions
1301 public function parse_adminskinselectoptions($templateName = '')
1304 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1305 $query = sprintf($query, sql_table('skin_desc'));
1307 $template['name'] = 'adminskin';
1308 $template['selected'] = $CONF['AdminSkin'];
1309 $template['tabindex'] = 110;
1310 Showlist($query, 'select', $template, $templateName);
1315 * AdminActions::parse_adminspecialskinlist()
1316 * Parse skinvar adminspecialskinlist
1318 * @param string $templateName name of template to use
1320 public function parse_adminspecialskinlist($templateName = '')
1322 $templates = array();
1323 if ( $templateName )
1325 $templates = Template::read($templateName);
1328 $nType = $this->parser->skin->getAvailableTypes();
1329 $skinid = intRequestVar('skinid');
1331 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1332 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1334 $res = DB::getResult($query);
1335 if ( $res && $res->rowCount() > 0 )
1337 /* NOTE: set templates for HEAD/BODY/FOOT */
1338 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1340 $template['head'] = "<ul>\n";
1344 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1346 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1348 $template['body'] = '<li>'
1349 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1352 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1359 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1361 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1363 $template['foot'] = "</ul>\n";
1367 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1374 echo $template['head'];
1375 foreach ( $res as $row )
1378 'tabindex' => $tabstart++,
1379 'skinid' => $skinid,
1380 'skintype' => Entity::hsc(strtolower($row['stype']))
1382 echo Template::fill($template['body'], $data);
1385 echo $template['foot'];
1391 * AdminActions::parse_admintemplateoverview()
1392 * Parse skinvar admintemplateoverview
1394 * @param string $templateName name of template to use
1397 public function parse_admintemplateoverview($templateName = '')
1399 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1400 $query = sprintf($query, sql_table('template_desc'));
1402 $template['content'] = 'admintemplatelist';
1403 $template['tabindex'] = 10;
1405 Showlist($query, 'table', $template, $templateName);
1410 * AdminActions::parse_allowedadminskinactions()
1411 * Parse skinvar allowedadminskinactions
1416 public function parse_allowedadminskinactions()
1418 global $DIR_ADMINSKINS;
1419 $skinType = strtolower(trim(requestVar('type')));
1420 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1423 while ( $current = array_shift($actions) )
1425 // TODO: remove this
1426 // skip deprecated vars
1427 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1432 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1434 if ( count($actions) != 0 )
1443 * AdminActions::parse_allowedskinactions()
1444 * Parse skinvar allowedskinactions
1449 public function parse_allowedskinactions()
1451 $skinType = strtolower(trim(requestVar('type')));
1452 $skinid = intRequestVar('skinid');
1454 $skin = new Skin($skinid);
1455 $actions = $skin->getAllowedActionsForType($skinType);
1458 while ( $current = array_shift($actions) )
1460 // TODO: remove this
1461 // skip deprecated vars
1462 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1467 /* TODO: alternative function should be used or not? */
1468 echo helplink("skinvar-{$current}") . "$current</a>\n";
1470 if ( count($actions) != 0 )
1479 * AdminActions::parse_banlistdeletedlist()
1480 * Parse skinvar banlistdeletedlist
1482 * @param string $templateName name of template to use
1485 public function parse_banlistdeletedlist($templateName = '')
1489 $templates = array();
1490 if ( $templateName )
1492 $templates = Template::read($templateName);
1495 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1497 $template = "<li><%blogname%></li>\n";
1501 $template = $templates['BANLIST_DELETED_LIST'];
1504 $deleted = requestArray('delblogs');
1505 foreach ( $deleted as $delblog )
1507 $blog =& $manager->getBlog($delblog);
1509 'blogname' => Entity::hsc($blog->getName())
1511 echo Template::fill($template, $data);
1518 * AdminActions::parse_batchdeletelist()
1519 * Parse skinvar batchdeletelist
1524 public function parse_batchdeletelist()
1526 $selected = requestIntArray('batch');
1529 foreach ( $selected as $select )
1531 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1533 // add hidden vars for team & comment
1534 if ( requestVar('action') == 'batchteam' )
1536 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1538 if ( requestVar('action') == 'batchcomment' )
1540 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1546 * AdminActions::parse_batchdeletetype()
1547 * Parse skinvar batchdeletetype
1552 public function parse_batchdeletetype()
1554 echo Entity::hsc(requestVar('action'));
1559 * AdminActions::parse_batchmovebtn()
1560 * Parse skinvar batchmovebtn
1565 public function parse_batchmovebtn()
1567 $actionType = requestVar('action');
1568 switch ( $actionType )
1573 case 'batchcategory':
1581 * AdminActions::parse_batchmovelist()
1582 * Parse skinvar batchmovelist
1587 public function parse_batchmovelist()
1589 $selected = requestIntArray('batch');
1591 foreach ( $selected as $select )
1593 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1600 * AdminActions::parse_batchmovetitle()
1601 * Parse skinvar batchmovetitle
1606 public function parse_batchmovetitle()
1608 $actionType = requestVar('action');
1609 switch ( $actionType )
1614 case 'batchcategory':
1615 echo _MOVECAT_TITLE;
1622 * AdminActions::parse_batchmovetype()
1623 * Parse skinvar batchmovetype
1628 public function parse_batchmovetype()
1630 echo Entity::hsc(requestVar('action'));
1635 * AdminActions::parse_blogcatlist()
1636 * Parse skinvar blogcatlist
1641 public function parse_blogcatlist($templateName = '')
1644 $blogid = intRequestVar('blogid');
1645 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1646 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1648 $template['content'] = 'categorylist';
1649 $template['tabindex'] = 200;
1651 $batch = new Batch('category');
1652 $batch->showlist($query, 'table', $template, $templateName);
1657 * AdminActions::parse_blogid()
1658 * Parse skinvar blogid
1663 public function parse_blogid()
1665 echo intRequestVar('blogid');
1670 * AdminActions::parse_blognotifysetting()
1671 * Parse skinvar blognotifysetting
1676 public function parse_blognotifysetting($type)
1679 $blogid = intRequestVar('blogid');
1680 $blog = $manager->getBlog($blogid);
1685 if ( !$blog->notifyOnComment() )
1691 if ( !$blog->notifyOnVote() )
1697 if ( !$blog->notifyOnNewItem() )
1703 echo ' checked="checked"';
1708 * AdminActions::parse_blogsetting()
1709 * Parse skinvar blogsetting
1711 * @param string $which name of weblog setting
1714 public function parse_blogsetting($which)
1716 echo $this->parse_getblogsetting($which);
1721 * AdminActions::parse_blogsettingyesno()
1722 * Parse skinvar blogsettingyesno
1724 * @param string $type type of weblog setting
1725 * @param string $templateName name of template to use
1728 public function parse_blogsettingyesno($type, $templateName = '')
1732 $blogid = intRequestVar('blogid');
1733 $blog = $manager->getBlog($blogid);
1737 case 'convertbreaks':
1738 $checkedval = $blog->convertBreaks();
1741 case 'allowpastposting':
1742 $checkedval = $blog->allowPastPosting();
1746 $checkedval = $blog->commentsEnabled();
1750 $checkedval = $blog->isPublic();
1754 $checkedval = $blog->emailRequired();
1758 $checkedval = $blog->getSearchable();
1762 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1767 * AdminActions::parse_blogteamlist()
1768 * Parse skinvar blogteamlist
1770 * @param string $templateName name of template to use
1773 public function parse_blogteamlist($templateName = '')
1776 $blogid = intRequestVar('blogid');
1777 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1779 . "WHERE tmember=mnumber AND tblog= %d";
1780 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1782 $template['content'] = 'teamlist';
1783 $template['tabindex'] = 10;
1785 $batch = new Batch('team');
1786 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1791 * AdminActions::parse_blogteammembers()
1792 * Parse skinvar blogteammembers
1797 public function parse_blogteammembers()
1799 $blogid = intRequestVar('blogid');
1800 $query = "SELECT mname, mrealname "
1802 . "WHERE mnumber=tmember AND tblog=%d;";
1803 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1804 $res = DB::getResult($query);
1805 $memberNames = array();
1806 foreach ( $res as $row )
1808 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1810 echo implode(',', $memberNames);
1814 * AdminActions::parse_blogtime()
1815 * Parse skinvar blogtime
1817 * @param string $type type of time
1818 * @param string $format format for time expression
1819 * @param integer $offset offset of time
1822 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1826 if ( $type != 'blogtime' )
1828 /* return server time */
1829 $timestamp = time() + $offset;
1833 $bid = intRequestVar('blogid');
1834 $b = $manager->getBlog($bid);
1835 $timestamp = $b->getCorrectTime() + $offset;
1838 echo i18n::formatted_datetime($format, $timestamp);
1843 * AdminActions::parse_bookmarkletadmin()
1844 * Parse skinvar bookmarkletadmin
1849 public function parse_bookmarkletadmin()
1853 $blogid = intRequestVar('blogid');
1855 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1860 * AdminActions::parse_categories()
1861 * Parse skinvar categories
1863 * create category dropdown box
1865 * @param string $type name of setting for category
1868 public function parse_categories($startidx = 0)
1873 $itemid = intRequestVar('itemid');
1874 $item = &$manager->getItem($itemid, 1, 1);
1879 $blogid = intRequestVar('blogid');
1883 $blogid = $item['blogid'];
1885 $blog = &$manager->getBlog($blogid);
1887 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1889 $item['body'] = removeBreaks($item['body']);
1890 $item['more'] = removeBreaks($item['more']);
1893 $contents = array();
1894 if ( requestVar('action') == 'itemedit' )
1899 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1902 $catid = $blog->getDefaultCategory();
1907 $catid = $contents['catid'];
1910 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1916 * AdminActions::parse_category()
1917 * Parse skinvar category
1919 * @param string $type name of setting for category
1922 public function parse_category($type = 'name')
1924 echo $this->parse_getcategory($type);
1929 * AdminActions::parse_categorysetting()
1930 * Parse skinvar categorysetting
1932 * @param string $type type in category setting
1935 public function parse_categorysetting($type)
1937 $catid = intRequestVar('catid');
1938 if ( $type == 'id' )
1943 $blogid = intRequestVar('blogid');
1944 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1945 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1946 $row = DB::getRow($query);
1948 if ( $type != 'name' )
1950 echo Entity::hsc($row['cdesc']);
1954 echo Entity::hsc($row['cname']);
1961 * AdminActions::parse_codename()
1962 * Parse templatevar codename
1968 public function parse_checkedonval($value, $name)
1973 $itemid = intRequestVar('itemid');
1974 $item =& $manager->getItem($itemid, 1, 1);
1976 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1978 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1980 $item['body'] = removeBreaks($item['body']);
1981 $item['more'] = removeBreaks($item['more']);
1984 $contents = array();
1985 if ( requestVar('action') == 'itemedit' )
1989 if ( !isset($contents[$name]) )
1991 $contents[$name] = '';
1993 if ($contents[$name] == $value)
1995 echo 'checked="checked"';
2001 * AdminActions::parse_codename()
2002 * Parse templatevar codename
2007 * TODO: is this need???
2009 public function parse_codename()
2012 echo $nucleus['codename'];
2017 * AdminActions::parse_commentnavlist()
2018 * Parse skinvar commentnavlist
2023 public function parse_commentnavlist()
2025 global $CONF, $manager, $member;
2028 if ( postVar('start') )
2030 $start = intPostVar('start');
2037 // amount of items to show
2038 if ( postVar('amount') )
2040 $amount = intPostVar('amount');
2044 $amount = (integer) $CONF['DefaultListSize'];
2050 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2052 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2054 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2056 if ( $this->skintype == 'itemcommentlist' )
2058 $itemid = intRequestVar('itemid');
2059 $query .= " citem={$itemid}";
2060 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2062 $nonComments = _NOCOMMENTS;
2064 elseif ( $this->skintype == 'browseowncomments' )
2067 $query .= ' cmember=' . $member->getID();
2068 $template['canAddBan'] = 0;
2070 $nonComments = _NOCOMMENTS_YOUR;
2072 elseif ( $this->skintype == 'blogcommentlist' )
2075 $query .= ' cblog=' . intRequestVar('blogid');
2076 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2077 $bid = intRequestVar('blogid');
2078 $nonComments = _NOCOMMENTS_BLOG;
2081 $search = postVar('search');
2082 if ( !empty($search) )
2084 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2087 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2089 $template['content'] = 'commentlist';
2091 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2092 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2097 * AdminActions::parse_configsettingsedit()
2098 * Parse skinvar configsettingsedit
2100 * @param string $type type of global configuration
2103 public function parse_configsettingsedit($type)
2108 case 'DefaultListSize':
2109 if ( !array_key_exists('DefaultListSize', $CONF) )
2111 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2112 $query = sprintf($query, sql_table('config'));
2113 DB::execute($query);
2114 $CONF['DefaultListSize'] = 10;
2116 elseif ( intval($CONF['DefaultListSize']) < 1 )
2118 $CONF['DefaultListSize'] = 10;
2120 echo intval($CONF['DefaultListSize']);
2122 case 'SessionCookie':
2123 $value = $CONF['SessionCookie'];
2124 $txt1 = _SETTINGS_COOKIESESSION;
2125 $txt2 = _SETTINGS_COOKIEMONTH;
2126 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2129 $value = $CONF['URLMode'];
2130 $txt1 = _SETTINGS_URLMODE_NORMAL;
2131 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2132 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2135 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2137 echo Entity::hsc($CONF[$type]);
2145 * AdminActions::parse_configsettingsyesno()
2146 * Parse skinvar configsettingsyesno
2148 * @param string $type type of global setting
2149 * @param integer $tabindex tabindex attribute of input element
2152 public function parse_configsettingsyesno($type, $tabindex)
2155 if ( array_key_exists($type, $CONF) )
2157 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2163 * AdminActions::parse_contents()
2164 * Parse skinvar contents
2166 * @param string $which part for item
2169 public function parse_contents($which)
2171 if ( !array_key_exists($which, Admin::$contents) )
2173 Admin::$contents[$which] = '';
2175 echo Entity::hsc(Admin::$contents[$which]);
2179 * AdminActions::parse_currenttime()
2180 * Parse skinvar currenttime
2182 * @param string $what
2185 public function parse_currenttime($what)
2187 $nu = getdate(Admin::$blog->getCorrectTime());
2192 * AdminActions::parse_customhelplink()
2193 * Parse skinvar customhelplink
2195 * @param string $topic name of topic
2196 * @param string $tplName name of template
2197 * @param string $url string as URI
2198 * @param string $iconURL string as URI for icon
2199 * @param string $alt alternative text for image element
2200 * @param string $title title for anchor element
2203 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2205 $this->customHelp($topic, $url, $iconURL);
2210 * AdminActions::parse_date()
2211 * Parse skinvar date
2213 public function parse_date($format = 'c')
2215 global $CONF, $manager;
2216 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2221 * AdminActions::parse_defaultadminskintypes()
2222 * Parse skinvar defaultadminskintypes
2224 * @param string $tabindex index number for tabindex attribute of input element
2225 * @param string $templateName name of template
2228 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2230 $templates = array();
2232 if ( $templateName )
2234 $templates = Template::read($templateName);
2237 $types = $this->parser->skin->getAvailableTypes();
2240 /* NOTE: set templates for HEAD/BODY/FOOT */
2241 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2243 $template['head'] = "<ul>\n";
2247 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2249 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2251 $template['body'] = "<li>"
2252 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2257 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2259 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2261 $template['foot'] = "</ul>\n";
2265 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2268 $handler = new AdminActions('template');
2269 $parser = new PARSER($handler);
2271 /* NOTE: do output */
2272 echo $template['head'];
2273 foreach ( $types as $type => $fName )
2275 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2277 'tabindex' => $tabindex,
2278 'skintype' => $type,
2280 'help' => $helplink,
2281 'skinid' => intrequestVar('skinid'),
2283 $parser->parse(Template::fill($template['body'], $data));
2286 echo $template['foot'];
2292 * AdminActions::parse_defblogselect()
2293 * Parse skinvar defblogselect
2295 * @param string $templateName name of template
2298 public function parse_defblogselect($templateName = '')
2302 $query = "SELECT bname as text, bnumber as value FROM %s;";
2303 $query = sprintf($query, sql_table('blog'));
2305 $template['name'] = 'DefaultBlog';
2306 $template['selected'] = $CONF['DefaultBlog'];
2307 $template['tabindex'] = 10;
2309 Showlist($query, 'select', $template, $templateName);
2315 * AdminActions::parse_defcatselect()
2316 * Parse skinvar defcatselect
2318 * @param string $templateName name of template
2321 public function parse_defcatselect($templateName = '')
2325 $blogid = intRequestVar('blogid');
2326 $blog = $manager->getBlog($blogid);
2328 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2329 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2331 $template['name'] = 'defcat';
2332 $template['selected'] = $blog->getDefaultCategory();
2333 $template['tabindex'] = 110;
2335 Showlist($query, 'select', $template, $templateName);
2341 * AdminActions::parse_defskinselect()
2342 * Parse skinvar defskinselect
2344 * @param string $type type of skin
2345 * @param string $templateName name of template
2348 public function parse_defskinselect($type = 'blog', $templateName = '')
2350 global $CONF, $manager;
2352 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2353 $query = sprintf($query, sql_table('skin_desc'));
2355 $blogid = intRequestVar('blogid');
2359 $template['selected'] = $CONF['BaseSkin'];
2363 $blog = $manager->getBlog($blogid);
2364 $template['selected'] = $blog->getDefaultSkin();
2367 if ( $type != 'blog' )
2369 $nname = 'BaseSkin';
2376 $template['name'] = $nname;
2377 $template['tabindex'] = 50;
2379 Showlist($query, 'select', $template, $templateName);
2385 * AdminActions::parse_deletecomment()
2386 * Parse skinvar deletecomment
2388 * @param string $type type of infomation for comment
2391 public function parse_deletecomment($type = 'id')
2393 $commentid = intRequestVar('commentid');
2394 $comment = COMMENT::getComment($commentid);
2399 echo intRequestVar('commentid');
2402 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2404 echo $comment['member'];
2408 echo $comment['user'];
2412 $body = strip_tags($comment['body']);
2413 echo Entity::hsc(shorten($body, 300, '...'));
2419 * AdminActions::parse_deleteitembody()
2420 * Parse skinvar deleteitembody
2425 public function parse_deleteitembody()
2429 $itemid = intRequestVar('itemid');
2430 $item =& $manager->getItem($itemid, 1, 1);
2432 $body = strip_tags($item['body']);
2434 echo Entity::hsc(shorten($body, 300, '...'));
2440 * AdminActions::parse_deleteitemid()
2441 * Parse skinvar deleteitemid
2446 public function parse_deleteitemid()
2448 echo (integer) intRequestVar('itemid');
2453 * AdminActions::parse_deleteitemtitle()
2454 * Parse skinvar deleteitemtitle
2459 public function parse_deleteitemtitle()
2463 $itemid = intRequestVar('itemid');
2464 $item =& $manager->getItem($itemid, 1, 1);
2466 echo Entity::hsc(strip_tags($item['title']));
2472 * AdminActions::parse_editadminskin()
2473 * Parse skinvar editadminskin
2475 * @param string $type type of skin setting
2478 public function parse_editadminskin($type = 'id')
2480 $skinid = intRequestVar('skinid');
2481 $skin = new Skin($skinid);
2485 echo intRequestVar('skinid');
2488 echo Entity::hsc($skin->getName());
2491 echo Entity::hsc($skin->getDescription());
2494 echo Entity::hsc($skin->getContentType());
2497 echo Entity::hsc($skin->getIncludePrefix());
2500 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2508 * AdminActions::parse_editadminskintype()
2509 * Parse skinvar editadminskintype
2511 * @param string $type name of skin type
2514 public function parse_editadminskintype($type = 'id')
2516 global $CONF, $manager, $member;
2518 $fNames = $this->parser->skin->getAvailableTypes();
2519 $sType = strtolower(trim(requestVar('type')));
2524 echo intRequestVar('skinid');
2527 echo Entity::hsc($this->parser->skin->getName());
2530 echo Entity::hsc($this->parser->skin->getDescription());
2533 echo Entity::hsc($this->parser->skin->getContentType());
2536 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2539 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2540 echo Entity::hsc($skinType);
2543 echo Entity::hsc($sType);
2546 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2549 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2550 echo Entity::hsc($incMode);
2559 * AdminActions::parse_editcomment()
2560 * Parse skinvar editcomment
2562 * @param string $type type of comment setting
2565 public function parse_editcomment($type = 'id')
2569 $commentid = intRequestVar('commentid');
2570 $comment = COMMENT::getComment($commentid);
2572 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2577 echo intRequestVar('commentid');
2580 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2582 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2586 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2590 echo date("Y-m-d @ H:i", $comment['timestamp']);
2593 $comment['body'] = str_replace('<br />', '', $comment['body']);
2594 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2595 echo $comment['body'];
2598 echo $comment['userid'];
2601 echo $comment['userid'];
2604 echo $comment[$type];
2611 * AdminActions::parse_editdesturl()
2612 * Parse skinvar editdesturl
2614 public function parse_editdesturl()
2616 if ( requestVar('desturl') )
2618 echo Entity::hsc(requestVar('desturl'));
2624 * AdminActions::parse_editmemberlist()
2625 * Parse skinvar editmemberlist
2627 * @param string $templateName name of template
2630 public function parse_editmemberlist($templateName = '')
2633 // show list of members with actions
2634 $query = 'SELECT * FROM '.sql_table('member');
2635 $template['content'] = 'memberlist';
2636 $template['tabindex'] = 10;
2638 $batch = new Batch('member');
2639 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2644 * AdminActions::parse_editmember()
2645 * Parse skinvar editmember
2647 * @param string $type type of information for member
2648 * @return string $tempateName name of template to use
2651 public function parse_editmember($type = 'id', $templateName = '')
2653 global $CONF, $manager, $member;
2655 $memberid = intRequestVar('memberid');
2656 $mem = MEMBER::createFromID($memberid);
2661 echo intRequestVar('memberid');
2664 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2666 echo Entity::hsc($mem->getDisplayName());
2670 $dispName = Entity::hsc($mem->getDisplayName());
2671 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2673 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2682 echo Entity::hsc($mem->getRealName());
2685 echo Entity::hsc($mem->getEmail());
2688 echo Entity::hsc($mem->getURL());
2691 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2694 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2697 echo Entity::hsc($mem->getNotes());
2700 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2709 * AdminActions::parse_editpluginfo()
2710 * Parse skinvar editpluginfo
2712 * @param string $type type of plugin info
2715 public function parse_editpluginfo($type)
2719 $pid = intRequestVar('plugid');
2726 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2733 * AdminActions::parse_editplugoptionslist()
2734 * Parse skinvar editplugoptionslist
2736 * @param string $templateName name of template
2739 public function parse_editplugoptionslist($templateName = '')
2743 $pid = intRequestVar('plugid');
2744 $aOptions = array();
2747 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2748 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2749 $resource = DB::getResult($query);
2751 foreach ( $resource as $row )
2753 array_push($aOIDs, $row['oid']);
2754 $aOptions[$row['oid']] = array(
2755 'oid' => $row['oid'],
2756 'value' => $row['odef'],
2757 'name' => $row['oname'],
2758 'description' => $row['odesc'],
2759 'type' => $row['otype'],
2760 'typeinfo' => $row['oextra'],
2765 // fill out actual values
2766 if ( count($aOIDs) > 0 )
2768 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2769 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2771 $result = DB::getResult($query);
2773 foreach ( $result as $row )
2775 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2781 'context' => 'global',
2783 'options' => &$aOptions
2785 $manager->notify('PrePluginOptionsEdit', $data);
2787 $template['content'] = 'plugoptionlist';
2789 $amount = Showlist($aOptions, 'table', $template, $templateName);
2793 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2799 * AdminActions::parse_editskin()
2800 * Parse skinvar editskin
2802 * @param string $type type of skin
2805 public function parse_editskin($type = 'id')
2807 $skinid = intRequestVar('skinid');
2808 $skin = new SKIN($skinid);
2812 echo intRequestVar('skinid');
2815 echo Entity::hsc($skin->getName());
2818 echo Entity::hsc($skin->getDescription());
2821 echo Entity::hsc($skin->getContentType());
2824 echo Entity::hsc($skin->getIncludePrefix());
2827 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2835 * AdminActions::parse_editskintype()
2836 * Parse skinvar editskintype
2838 * @param string $type name of type for skin type
2841 public function parse_editskintype($type = 'id')
2843 global $CONF, $manager, $member;
2844 $skinid = intRequestVar('skinid');
2845 $skin = new SKIN($skinid);
2846 $fNames = $skin->getAvailableTypes();
2847 $sType = strtolower(trim(requestVar('type')));
2852 echo intRequestVar('skinid');
2855 echo Entity::hsc($skin->getName());
2858 echo Entity::hsc($skin->getDescription());
2861 echo Entity::hsc($skin->getContentType());
2864 echo Entity::hsc($skin->getContentFromDB($sType));
2867 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2868 echo Entity::hsc($skinType);
2871 echo Entity::hsc($sType);
2874 echo Entity::hsc($skin->getIncludePrefix());
2877 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2878 echo Entity::hsc($incMode);
2887 * AdminActions::parse_adminurl()
2888 * Parse skinvar adminurl
2889 * (shortcut for admin url)
2894 public function parse_adminurl()
2896 $this->parse_sitevar('adminurl');
2901 * AdminActions::parse_edittemplateinfo()
2902 * Parse skinvar edittemplateinfo
2904 * @param string $type name of type for skin
2905 * @param string $description description for skin
2906 * @param string $name name of skin
2907 * @param string $help
2908 * @param string $tabindex index value for tabindex attribute of input element
2909 * @param string $big
2910 * @param string $tplt name of template
2913 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2917 $t_id = intRequestVar('templateid');
2918 $t_name = Template::getNameFromId($t_id);
2919 $t_desc = Template::getDesc($t_id);
2920 $template = &Template::read($t_name);
2928 echo Entity::hsc($t_name);
2931 echo Entity::hsc($t_desc);
2933 case 'extratemplate':
2935 $pluginfields = array();
2936 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2941 $tmplt = Template::read($desc);
2943 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2947 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2951 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2954 foreach ( $pluginfields as $pfkey => $pfvalue )
2956 $data = array('explugtplname' => Entity::hsc($pfkey));
2958 echo Template::fill($base, $data);
2960 foreach ( $pfvalue as $pffield => $pfdesc )
2962 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2967 $desc = defined($desc) ? constant($desc) : $desc;
2968 $name = defined($name) ? constant($name) : $name;
2969 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2977 * AdminActions::parse_editadmintemplateinfo()
2978 * Parse skinvar editadmintemplateinfo
2980 * @param string $type type of skin template
2981 * @param string $description description of template
2982 * @param string $name name of stemplate
2983 * @param string $tabindex index number for tabindex attribute of input element
2984 * @param string $big
2985 * @param string $tplt
2987 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2991 $t_id = intRequestVar('templateid');
2992 $t_name = Template::getNameFromId($t_id);
2993 $t_desc = Template::getDesc($t_id);
2994 $template = &Template::read($t_name);
3002 echo Entity::hsc($t_name);
3005 echo Entity::hsc($t_desc);
3007 case 'extratemplate':
3009 $pluginfields = array();
3010 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3015 $tmplt = Template::read($desc);
3017 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3021 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3025 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3028 foreach ( $pluginfields as $pfkey => $pfvalue )
3030 $data = array('explugtplname' => Entity::hsc($pfkey));
3032 echo Template::fill($base, $data);
3034 foreach ( $pfvalue as $pffield => $pfdesc )
3036 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3041 $desc = defined($desc) ? constant($desc) : $desc;
3042 $name = defined($name) ? constant($name) : $name;
3043 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3050 * AdminActions::parse_eventformextra()
3051 * Parse skinvar eventformextra
3053 * @param string $type name of type for event form extra
3056 public function parse_eventformextra($type = 'activation')
3065 $key = requestVar('ackey');
3068 Admin::error(_ERROR_ACTIVATE);
3070 $info = MEMBER::getActivationInfo($key);
3073 Admin::error(_ERROR_ACTIVATE);
3075 $mem = MEMBER::createFromId($info->vmember);
3078 Admin::error(_ERROR_ACTIVATE);
3081 'type' => 'activation',
3085 case 'membermailform-notloggedin':
3086 $data = array('type' => 'membermailform-notloggedin',);
3089 $manager->notify('FormExtra', $data);
3094 * AdminActions::parse_extrahead()
3095 * Parse skinvar extrahead
3097 public function parse_extrahead()
3101 $extrahead = Admin::getAdminextrahead();
3104 'extrahead' => &$extrahead,
3105 'action' => Admin::getAdminAction()
3108 $manager->notify('AdminPrePageHead', $data);
3114 * AdminActions::parse_member()
3115 * Parse skinvar member
3116 * (includes a member info thingie)
3118 * @param string $what which memberdata is needed
3121 public function parse_member($what)
3123 global $memberinfo, $member, $CONF;
3125 // 1. only allow the member-details-page specific variables on member pages
3126 if ( $this->skintype == 'member' )
3131 echo Entity::hsc($memberinfo->getDisplayName());
3134 echo Entity::hsc($memberinfo->getRealName());
3137 echo Entity::hsc($memberinfo->getNotes());
3140 echo Entity::hsc($memberinfo->getURL());
3143 echo Entity::hsc($memberinfo->getEmail());
3146 echo Entity::hsc($memberinfo->getID());
3151 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3152 if ( $member->isLoggedIn() )
3157 echo $member->getDisplayName();
3159 case 'yourrealname':
3160 echo $member->getRealName();
3163 echo $member->getNotes();
3166 echo $member->getURL();
3169 echo $member->getEmail();
3172 echo $member->getID();
3174 case 'yourprofileurl':
3175 if ( $CONF['URLMode'] == 'pathinfo' )
3177 echo Link::create_member_link($member->getID());
3181 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3190 * AdminActions::parse_version()
3191 * Parse skinvar version
3192 * (include nucleus versionnumber)
3197 public function parse_version()
3200 echo 'Nucleus CMS ' . $nucleus['version'];
3205 * AdminActions::parse_sitevar()
3206 * Parse skinvar sitevar
3207 * (include a sitevar)
3209 * @param string $which
3212 public function parse_sitevar($which)
3218 echo $CONF['IndexURL'];
3221 echo $CONF['SiteName'];
3224 echo $CONF['AdminEmail'];
3227 echo $CONF['AdminURL'];
3234 * AdminActions::parse_actionurl()
3240 public function parse_actionurl()
3243 echo Entity::hsc($CONF['ActionURL']);
3248 * AdminActions::parse_charset()
3249 * Parse skinvar charset
3254 public function parse_charset()
3256 echo i18n::get_current_charset();
3261 * AdminActions::parse_getblogsetting()
3262 * Parse skinvar getblogsetting
3264 public function parse_getblogsetting($which)
3266 global $blog, $manager;
3272 elseif ( $bid = intRequestVar('blogid') )
3274 $b = $manager->getBlog($bid);
3284 return Entity::hsc($b->getID());
3287 return Entity::hsc($b->getURL());
3290 return Entity::hsc($b->getName());
3293 return Entity::hsc($b->getDescription());
3296 return Entity::hsc($b->getShortName());
3298 case 'notifyaddress':
3299 return Entity::hsc($b->getNotifyAddress());
3302 return Entity::hsc($b->getMaxComments());
3305 return Entity::hsc($b->getUpdateFile());
3308 return Entity::hsc($b->getTimeOffset());
3315 * AdminActions::parse_geteditpluginfo()
3316 * Parse skinvar geteditpluginfo
3318 * @param string $type name of setting for edit plugin info
3321 public function parse_geteditpluginfo($type)
3324 $pid = intRequestVar('plugid');
3331 return Entity::hsc($manager->getPluginNameFromPid($pid));
3338 * AdminActions::parse_getmember()
3339 * Parse skinvar getmember
3340 * (includes a member info thingie)
3342 * @param string $what name of setting for member
3345 public function parse_getmember($what)
3347 global $memberinfo, $member;
3348 // 1. only allow the member-details-page specific variables on member pages
3349 if ( $this->skintype == 'member' )
3354 return Entity::hsc($memberinfo->getDisplayName());
3357 return Entity::hsc($memberinfo->getRealName());
3360 return Entity::hsc($memberinfo->getNotes());
3363 return Entity::hsc($memberinfo->getURL());
3366 return Entity::hsc($memberinfo->getEmail());
3369 return Entity::hsc($memberinfo->getID());
3373 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3374 if ( $member->isLoggedIn() )
3379 return $member->getDisplayName();
3381 case 'yourrealname':
3382 return $member->getRealName();
3385 return $member->getNotes();
3388 return $member->getURL();
3391 return $member->getEmail();
3394 return $member->getID();
3402 * AdminActions::parse_headmessage()
3403 * Parse skinvar headmessage
3408 public function parse_headmessage()
3410 if ( !empty(Admin::$headMess) )
3412 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3418 * AdminActions::parse_helplink()
3419 * Parse skinvar helplink
3421 * @param string $topic name of topic for help
3424 public function parse_helplink($topic = '')
3426 if ( !empty($topic) )
3434 * AdminActions::parse_helpplugname()
3435 * Parse skinvar helpplugname
3440 public function parse_helpplugname()
3442 $plugid = intGetVar('plugid');
3443 Entity::hsc($manager->getPluginNameFromPid($plugid));
3448 * AdminActions::parse_ilistaddnew()
3449 * Parse skinvar ilistaddnew
3454 public function parse_ilistaddnew()
3456 $blogid = intRequestVar('blogid');
3457 if ( intPostVar('start') == 0 )
3459 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3465 * AdminActions::parse_importskininfo()
3466 * Parse skinvar importskininfo
3468 * @param string $type name of information for imported skin
3471 public function parse_importskininfo($type)
3476 echo Entity::hsc(requestVar('skininfo'));
3479 $dataArr = requestArray('skinnames');
3480 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3483 $dataArr = requestArray('tpltnames');
3484 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3487 $dataArr = requestArray('skinclashes');
3488 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3491 $dataArr = requestArray('tpltclashes');
3492 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3495 echo Entity::hsc(requestVar('skinfile'));
3498 echo Entity::hsc(requestVar('mode'));
3505 * AdminActions::parse_inputyesno()
3506 * Parse skinvar inputyesno
3508 * some init stuff for all forms
3513 public function parse_init()
3518 if ( requestVar('action') == 'itemedit' )
3520 $authorid = Admin::$item['authorid'];
3523 Admin::$blog->insertJavaScriptInfo($authorid);
3528 * AdminActions::parse_inputyesno()
3529 * Parse skinvar inputyesno
3531 * @param string $name
3532 * @param string $checkedval
3533 * @param string $tabindex
3534 * @param string $value1
3535 * @param string $value2
3536 * @param string $yesval
3537 * @param string $noval
3538 * @param string $isAdmin
3539 * @param string $templateName
3542 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3544 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3549 * AdminActions::parse_insertpluginfo()
3550 * Parse templatevar insertpluginfo
3552 public function parse_insertpluginfo($type)
3554 $option = Admin::getAdminaOption();
3558 return $option['pid'];
3561 return Entity::hsc($option['pfile']);
3568 * AdminActions::parse_insplugoptcontent()
3569 * Parse skinvar insplugoptcontent
3574 public function parse_insplugoptcontent()
3576 $option = Admin::getAdminaOption();
3578 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3579 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3582 listplug_plugOptionRow($option);
3589 * AdminActions::parse_iprangeinput()
3590 * Parse skinvar iprangeinput
3595 public function parse_iprangeinput()
3597 if ( requestVar('ip') )
3599 $iprangeVal = Entity::hsc(requestVar('ip'));
3600 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3601 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3602 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3603 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3604 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3608 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3609 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3615 * AdminActions::parse_itemnavlist()
3616 * Parse skinvar itemnavlist
3621 public function parse_itemnavlist($templateName)
3623 global $CONF, $manager, $member;
3625 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3626 . " FROM %s, %s, %s, %s"
3627 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3629 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3631 if ( $this->skintype == 'itemlist' )
3634 if ( array_key_exists('blogid', $_REQUEST) )
3636 $blogid = intRequestVar('blogid');
3638 else if ( array_key_exists('itemid', $_REQUEST) )
3640 $itemid = intRequestVar('itemid');
3641 $item = &$manager->getItem($itemid, 1, 1);
3642 $blogid = (integer) $item['blogid'];
3644 $blog =& $manager->getBlog($blogid);
3646 $query .= " AND iblog={$blogid}";
3647 $template['now'] = $blog->getCorrectTime(time());
3649 // non-blog-admins can only edit/delete their own items
3650 if ( !$member->blogAdminRights($blogid) )
3652 $query .= ' AND iauthor = ' . $member->getID();
3655 elseif ( $this->skintype == 'browseownitems' )
3657 $query .= ' AND iauthor = ' . $member->getID();
3659 $template['now'] = time();
3662 // search through items
3663 $search = postVar('search');
3665 if ( !empty($search) )
3667 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3668 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3669 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3672 if ( postVar('start') )
3674 $start = intPostVar('start');
3681 // amount of items to show
3682 if ( postVar('amount') )
3684 $amount = intPostVar('amount');
3688 $amount = (integer) $CONF['DefaultListSize'];
3695 $query .= ' ORDER BY itime DESC'
3696 . " LIMIT {$start},{$amount}";
3698 $template['content'] = 'itemlist';
3700 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3701 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3706 * AdminActions::parse_itemtime()
3707 * date change on edit item
3709 * @param string $key key of PHP's getDate()
3712 public function parse_itemtime($key)
3717 $itemid = intRequestVar('itemid');
3718 $item =& $manager->getItem($itemid, 1, 1);
3720 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3722 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3724 $item['body'] = removeBreaks($item['body']);
3725 $item['more'] = removeBreaks($item['more']);
3728 $contents = array();
3729 if ( requestVar('action') == 'itemedit' )
3733 elseif ( requestVar('action') == 'createitem' )
3736 'contents' => &$contents,
3737 'blog' => &$this->blog
3739 $manager->notify('PreAddItemForm', $data);
3741 $itemtime = getdate($contents['timestamp']);
3742 echo $itemtime[$key];
3747 * AdminActions::parse_jstoolbaroptions()
3748 * Parse skinvar jstoolbaroptions
3753 public function parse_jstoolbaroptions()
3757 _SETTINGS_JSTOOLBAR_NONE,
3758 _SETTINGS_JSTOOLBAR_SIMPLE,
3759 _SETTINGS_JSTOOLBAR_FULL
3763 foreach ( $options as $option )
3765 $text = "<option value=\"%d\"%s>%s</option>\n";
3766 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3767 echo sprintf($text, $i, $extra, $option);
3773 * AdminActions::parse_localeselectoptions()
3774 * Parse skinvar localeselectoptions
3779 public function parse_localeselectoptions()
3781 $locales = i18n::get_available_locale_list();
3783 $memid = intRequestVar('memberid');
3786 $mem = MEMBER::createFromID($memid);
3787 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3789 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3793 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3798 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3800 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3804 echo "<option value=\"\">en_Latn_US</option>\n";
3807 foreach ( $locales as $locale )
3809 if ( $locale == 'en_Latn_US' )
3815 if ( $locale == $mem->getLocale() )
3817 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3821 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3826 if ( $locale == i18n::get_current_locale() )
3828 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3832 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3840 * AdminActions::parse_listplugplugoptionrow()
3841 * Parse templatevar listplugplugoptionrow
3843 * @param string $templateName name of template
3846 public function parse_listplugplugoptionrow($templateName = '')
3848 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3853 * AdminActions::parse_mediadirwarning()
3854 * Parse skinvar mediadirwarning
3859 public function parse_mediadirwarning()
3862 if ( !is_dir($DIR_MEDIA) )
3864 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3866 if ( !is_readable($DIR_MEDIA) )
3868 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3870 if ( !is_writeable($DIR_MEDIA) )
3872 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3878 * AdminActions::parse_movedistselect()
3879 * Parse skinvar movedistselect
3881 public function parse_movedistselect()
3883 $actionType = requestVar('action');
3884 switch ( $actionType )
3887 $this->selectBlog('destcatid', 'category');
3889 case 'batchcategory':
3890 $this->selectBlog('destblogid');
3893 if ( $this->skintype == 'itemmove' )
3895 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3896 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3897 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3898 $this->selectBlog('catid', 'category', $catid, 10, 1);
3906 * AdminActions::parse_moveitemid()
3907 * Parse skinvar moveitemid
3912 public function parse_moveitemid()
3914 echo intRequestVar('itemid');
3919 * AdminActions::parse_newestcompare()
3920 * Parse skinvar newestcompare
3925 public function parse_newestcompare()
3929 $newestVersion = getLatestVersion();
3930 $newestCompare = str_replace('/', '.', $newestVersion);
3931 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3933 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3935 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3936 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3942 * AdminActions::parse_newmemberselect()
3943 * Parse skinvar newmemberselect
3945 * @param string $templateName name of template to use
3948 public function parse_newmemberselect($templateName = '')
3950 $blogid = intRequestVar('blogid');
3952 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3953 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3954 $res = DB::getResult($query);
3957 foreach ( $res as $row )
3959 $tmem[] = intval($row['tmember']);
3962 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3963 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3966 'name' => 'memberid',
3967 'tabindex' => 10000,
3970 Showlist($query, 'select', $template, $templateName);
3975 * AdminActions::parse_newpluginlist()
3976 * Parse skinvar newpluginlist
3981 public function parse_newpluginlist()
3983 $candidates = $this->newPlugCandidates;
3984 foreach ( $candidates as $name )
3986 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3992 * AdminActions::parse_outputspecialdirs()
3993 * Parse skinvar outputspecialdirs
3995 * @param string $type type of setting for directory
3998 public function parse_outputspecialdirs($type)
4000 global $DIR_MEDIA, $DIR_NUCLEUS;
4005 echo Entity::hsc($DIR_NUCLEUS);
4008 echo Entity::hsc($DIR_MEDIA);
4015 * AdminActions::parse_passrequestvars()
4016 * Parse skinvar passrequestvars
4021 public function parse_passrequestvars()
4023 $passvar = Admin::getAdminpassvar();
4024 $oldaction = postVar('oldaction');
4026 if ( ($oldaction != 'logout')
4027 && ($oldaction != 'login')
4029 && !postVar('customaction') )
4037 * AdminActions::parse_pluginextras()
4038 * Parse skinvar pluginextras
4040 * @param string $type type of plugin context
4043 public function parse_pluginextras($type = 'global')
4049 $id = intRequestVar('memberid');
4050 $mem = MEMBER::createFromID($id);
4051 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4054 $id = intRequestVar('blogid');
4055 $blg = $manager->getBlog($id);
4056 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4058 case 'createaccount':
4060 'type' => 'createaccount.php',
4062 'postlabel' => '<br />',
4064 'postfield' => '<br /><br />'
4066 $manager->notify('RegistrationFormExtraFields', $data);
4069 $manager->notify('GeneralSettingsFormExtras', array());
4076 * AdminActions::parse_pluginhelp()
4077 * Parse skinvar pluginhelp
4082 public function parse_pluginhelp()
4084 global $manager, $DIR_PLUGINS;
4086 $plugid = intGetVar('plugid');
4087 $plugName = $manager->getPluginNameFromPid($plugid);
4088 $plug =& $manager->getPlugin($plugName);
4090 if ( $plug->supportsFeature('HelpPage') > 0 )
4092 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4093 if ( @file_exists($helpfile . 'php') )
4095 @include($helpfile . 'php');
4098 elseif ( @file_exists($helpfile . 'html') )
4100 @include($helpfile . 'html');
4104 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4105 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4110 * AdminActions::parse_pluginlistlist()
4111 * Parse skinvar pluginlistlist
4113 * @param string $templateName name of template to use
4116 public function parse_pluginlistlist($templateName = '')
4118 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4119 $query = sprintf($query, sql_table('plugin'));
4121 $template['content'] = 'pluginlist';
4122 $template['tabindex'] = 10;
4124 Showlist($query, 'table', $template, $templateName);
4130 * AdminActions::parse_pluginoptions()
4131 * Parse skinvar pluginoptions
4133 * @param string $type type of plugin option
4136 public function parse_pluginoptions($context='global', $templateName='')
4138 global $itemid, $manager;
4143 $contextid = intRequestVar('memberid');
4146 $contextid = intRequestVar('blogid');
4149 $contextid = intRequestVar('catid');
4152 $contextid = $itemid;
4156 /* Actually registererd plugin options */
4157 $aIdToValue = array();
4158 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4159 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4160 $res = DB::getResult($query);
4161 foreach ( $res as $row )
4163 $aIdToValue[$row['oid']] = $row['ovalue'];
4166 /* Currently available plugin options */
4167 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4168 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4169 $res = DB::getResult($query);
4172 foreach ($res as $row )
4174 if ( !array_key_exists($row['oid'], $aIdToValue) )
4176 $value = $row['odef'];
4180 $value = $aIdToValue[$row['oid']];
4184 'pid' => $row['pid'],
4185 'pfile' => $row['pfile'],
4186 'oid' => $row['oid'],
4188 'name' => $row['oname'],
4189 'description' => $row['odesc'],
4190 'type' => $row['otype'],
4191 'typeinfo' => $row['oextra'],
4192 'contextid' => $contextid,
4198 'context' => $context,
4199 'contextid' => $contextid,
4200 'options' => &$options
4202 $manager->notify('PrePluginOptionsEdit', $data);
4204 $template = array();
4205 if ( $templateName )
4207 $templates = Template::read($templateName);
4208 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4210 $template['title'] = "<tr>"
4211 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4216 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4219 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4221 $template['body'] = "<tr>"
4222 . "<%listplugplugoptionrow%>"
4227 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4233 include_libs('ACTIONS.php');
4234 $handler = new Actions($this->skintype);
4235 $parser = new PARSER($handler);
4237 foreach ( $options as $option )
4240 if ( $prevPid != $option['pid'] )
4242 $prevPid = $option['pid'];
4243 $parser->parse($template['title']);
4246 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4248 if ( @$meta['access'] != 'hidden' )
4250 $parsed = $parser->parse($template['body']);
4258 * AdminActions::parse_qmenuaddselect()
4259 * Parse skinvar qmanuaddselect
4261 * @param string $templateName name of template to use
4264 public function parse_qmenuaddselect($templateName = '')
4267 $showAll = requestVar('showall');
4268 if ( $member->isAdmin() && ($showAll == 'yes') )
4270 // Super-Admins have access to all blogs! (no add item support though)
4271 $query = 'SELECT bnumber as value, bname as text'
4272 . ' FROM ' . sql_table('blog')
4273 . ' ORDER BY bname';
4277 $query = 'SELECT bnumber as value, bname as text'
4278 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4279 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4280 . ' ORDER BY bname';
4283 $template['name'] = 'blogid';
4284 $template['tabindex'] = 15000;
4285 $template['extra'] = _QMENU_ADD_SELECT;
4286 $template['selected'] = -1;
4287 $template['shorten'] = 10;
4288 $template['shortenel'] = '';
4289 $template['javascript'] = 'onchange="return form.submit()"';
4291 Showlist($query, 'select', $template, $templateName);
4297 * AdminActions::parse_quickmenu()
4298 * Parse skinvar quickmenu
4300 * @param string $templateName name of template to use
4303 public function parse_quickmenu($templateName = '')
4306 $templates = array();
4307 $template = array();
4308 if ( !empty($templateName) )
4310 $templates = Template::read($templateName);
4312 $pluginExtras = array();
4316 'options' => &$pluginExtras
4319 if ( count($pluginExtras) > 0 )
4321 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4323 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4327 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4329 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4331 $template['head'] = "<ul>\n";
4335 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4337 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4339 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4343 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4345 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4347 $template['foot'] = "</ul>\n";
4351 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4354 $handler = new Actions($this->skintype);
4355 $parser = new PARSER($handler);
4357 $parser->parse($template['title']);
4358 echo $template['head'];
4359 foreach ( $pluginExtras as $aInfo )
4362 'plugadminurl' => Entity::hsc($aInfo['url']),
4363 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4364 'plugadmintitle' => Entity::hsc($aInfo['title']),
4366 echo Template::fill($template['body'], $data);
4368 echo $template['foot'];
4374 * AdminActions::parse_requestblogid()
4375 * Parse skinvar requestblogid
4380 public function parse_requestblogid()
4382 echo intRequestVar('blogid');
4387 * AdminActions::parse_requestiprange()
4388 * Parse skinvar requestiprange
4393 public function parse_requestiprange()
4395 if ( requestVar('iprange') )
4397 echo Entity::hsc(requestVar('iprange'));
4399 elseif ( requestVar('ip') )
4401 echo Entity::hsc(requestVar('ip'));
4407 * AdminActions::parse_selectlocaladminskinfiles()
4408 * Parse skinvar selectlocaladminskinfiles
4413 public function parse_selectlocaladminskinfiles()
4415 global $DIR_SKINS, $manager;
4417 $adminskindir = $DIR_SKINS . 'admin/';
4418 $candidates = SkinImport::searchForCandidates($adminskindir);
4420 foreach ( $candidates as $skinname => $skinfile )
4422 $html = Entity::hsc($skinfile);
4423 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4430 * AdminActions::parse_selectlocalskinfiles()
4431 * Parse skinvar selectlocalskinfiles
4436 public function parse_selectlocalskinfiles()
4440 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4442 foreach ( $candidates as $skinname => $skinfile )
4444 $html = Entity::hsc($skinfile);
4445 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4452 * AdminActions::parse_skineditallowedlist()
4453 * Parse skinvar skineditallowedlist
4455 * @param string $type type of skin
4456 * @param string $templateName name of template
4459 public function parse_skineditallowedlist($type, $templateName = '')
4464 $query = "SELECT bshortname, bname FROM %s;";
4466 'content' => 'shortblognames'
4468 $query = sprintf($query, sql_table('blog'));
4469 Showlist($query, 'table', $show, $templateName);
4472 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4474 'content' => 'shortnames'
4476 $query = sprintf($query, sql_table('template_desc'));
4477 Showlist($query, 'table', $show, $templateName);
4484 * AdminActions::parse_skinielist()
4485 * Parse skinvar skinielist
4487 * @param string $type type of skin
4488 * @param string $templateName name of template to use
4491 public function parse_skinielist($type, $templateName = '')
4493 $templates = array();
4494 if ( $templateName )
4496 $templates = Template::read($templateName);
4498 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4500 $template = $templates['SKINIE_EXPORT_LIST'];
4505 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4506 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4508 . "<td><%expdesc%></td>\n"
4515 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4516 foreach ( $res as $row )
4519 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4520 'expid' => 'skinexp' . $row['sdnumber'],
4521 'expname' => Entity::hsc($row['sdname']),
4522 'expdesc' => Entity::hsc($row['sddesc'])
4524 echo Template::fill($template, $data);
4528 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4529 foreach ( $res as $row )
4532 'typeid' => 'template[' . $row['tdnumber'] . ']',
4533 'expid' => 'templateexp' . $row['tdnumber'],
4534 'expname' => Entity::hsc($row['tdname']),
4535 'expdesc' => Entity::hsc($row['tddesc'])
4537 echo Template::fill($template, $data);
4545 * AdminActions::parse_skinoverview()
4546 * Parse skinvar skinoverview
4548 * @param string $templateName name of template to use
4551 public function parse_skinoverview($templateName = '')
4554 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4555 $query = sprintf($query, sql_table('skin_desc'));
4557 $template['content'] = 'skinlist';
4558 $template['tabindex'] = 10;
4560 Showlist($query, 'table', $template, $templateName);
4565 * AdminActions::parse_skintypehelp()
4566 * Check editing skintypehelp
4571 public function parse_skintypehelp()
4573 $nowSkinType = strtolower(trim(requestVar('type')));
4575 /* TODO: use Skin class */
4576 $regularType = array(
4587 if ( in_array($nowSkinType, $regularType) )
4589 help('skinpart' . $nowSkinType);
4593 help('skinpartspecial');
4599 * AdminActions::parse_specialskinlist()
4600 * Parse skinvar specialskinlist
4602 * @param string $templateName name of template to use
4605 public function parse_specialskinlist($templateName = '')
4607 $templates = array();
4608 if ( $templateName )
4610 $templates = Template::read($templateName);
4613 /* TODO: use Skin class */
4624 $skinid = intRequestVar('skinid');
4625 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4626 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4628 $res = DB::getResult($query);
4629 if ( $res && $res->rowCount() > 0 )
4632 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4634 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4638 $template['head'] = "<ul>\n";
4640 echo Template::fill($template['head'], $data);
4641 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4643 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4644 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4645 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4649 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4653 foreach ( $res as $row )
4656 'tabindex' => $tabstart++,
4657 'skinid' => $skinid,
4658 'skintype' => Entity::hsc(strtolower($row['stype']))
4660 echo Template::fill($template['body'], $data);
4663 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4665 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4669 $template['foot'] = "</ul>\n";
4671 echo Template::fill($template['foot'], $data);
4677 * AdminActions::parse_sprinttext()
4680 * @param string $which
4681 * @param string $val
4684 public function parse_sprinttext($which, $val)
4686 if ( !defined($which) )
4692 $base = constant($which);
4695 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4697 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4699 $met = 'parse_' . $matchies[0];
4703 $arg = trim($args[0], '()');
4704 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4707 if ( method_exists($this, $met) )
4709 $value = call_user_func(array(&$this, $met), $arg);
4713 if ( !isset($value) || empty($value) )
4717 echo sprintf($base, $value);
4722 * AdminActions::parse_systemsettings()
4723 * Parse skinvar systemsettings
4725 * @param string $type type of settings for system
4726 * @param string $templateName name of template to use
4729 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4731 global $member, $CONF, $nucleus;
4733 $member->isAdmin() or Admin::disallow();
4735 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4736 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4743 case 'sqlserverinfo':
4744 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4746 case 'sqlclientinfo':
4747 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4749 case 'magicquotesgpc':
4750 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4752 case 'magicquotesruntime':
4753 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4755 case 'registerglobals':
4756 echo ini_get('register_globals') ? 'On' : 'Off';
4759 $templates = array();
4760 if ( $templateName )
4762 $templates = Template::read($templateName);
4764 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4766 $template = "<tr>\n"
4767 . "<td><%key%></td>\n"
4768 . "<td><%value%></td>\n"
4773 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4776 $gdinfo = gd_info();
4778 foreach ( $gdinfo as $key => $value )
4780 if ( is_bool($value) )
4782 $value = $value ? $enable : $disable;
4786 $value = Entity::hsc($value);
4792 echo Template::fill($template, $data);
4797 phpinfo(INFO_MODULES);
4798 $im = ob_get_contents();
4800 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4802 case 'nucleusversion':
4803 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4805 case 'nucleuspatchlevel':
4806 echo getNucleusPatchLevel();
4812 echo $CONF['ItemURL'];
4814 case 'alertonheaderssent':
4815 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4817 case 'nucleuscodename':
4818 if ( $nucleus['codename'] != '' )
4820 echo ' "' . $nucleus['codename'] . '"';
4823 case 'versioncheckurl':
4824 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4831 * AdminActions::parse_templateoverview()
4832 * Parse skinvar templateoverview
4834 * @param string $templateName name of template to use
4837 public function parse_templateoverview($templateName = '')
4839 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4840 $query = sprintf($query, sql_table('template_desc'));
4842 $template['content'] = 'templatelist';
4843 $template['tabindex'] = 10;
4845 Showlist($query, 'table', $template, $templateName);
4851 * AdminActions::parse_ticket()
4857 public function parse_ticket()
4860 $manager->addTicketHidden();
4865 * AdminActions::parse_versioncheckurl()
4866 * Parse skinvar versioncheckurl
4871 public function parse_versioncheckurl()
4873 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4878 * AdminActions::parse_yrbloglist()
4879 * Parse skinvar yrbloglist
4881 * @param string $templateName name of template to use
4884 public function parse_yrbloglist($templateName = '')
4887 $showAll = requestVar('showall');
4889 if ( $member->isAdmin() && ($showAll == 'yes') )
4891 // Super-Admins have access to all blogs! (no add item support though)
4892 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4894 . " ORDER BY bnumber;";
4895 $query = sprintf($query, sql_table('blog'));
4899 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4901 . " WHERE tblog=bnumber and tmember=%d"
4902 . " ORDER BY bnumber;";
4903 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4906 $template['content'] = 'bloglist';
4907 $template['superadmin'] = $member->isAdmin();
4909 $amount = Showlist($query, 'table', $template, $templateName);
4911 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4913 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4915 $total = DB::getValue($query);
4916 if ( $total > $amount )
4918 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4924 echo _OVERVIEW_NOBLOGS;
4926 elseif( $amount != 0 )
4928 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4930 $query = "SELECT ititle, inumber, bshortname"
4932 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4933 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4935 $template['content'] = 'draftlist';
4937 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4938 if ( $amountdrafts == 0 )
4940 echo _OVERVIEW_NODRAFTS;
4947 * AdminActions::checkCondition()
4948 * Checks conditions for if statements
4950 * @param string $field type of <%if%>
4951 * @param string $name property of field
4952 * @param string $value value of property
4953 * @return boolean condition
4955 protected function checkCondition($field, $name='', $value = '')
4957 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4967 $blog =& $manager->getBlog($blogid);
4971 $blogid = getBlogIDFromCatID($catid);
4972 $blog =& $manager->getBlog($blogid);
4974 elseif ( intRequestVar('catid') )
4976 $catid = intRequestVar('catid');
4977 $blogid = getBlogIDFromCatID($catid);
4978 $blog =& $manager->getBlog($blogid);
4985 $condition = ($blog && $this->ifCategory($name, $value));
4988 $condition = $member->isLoggedIn();
4991 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4994 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4997 $condition = $member->isLoggedIn() && $member->isAdmin();
4999 case 'allowloginedit':
5000 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5003 $condition = ($itemidnext != '');
5006 $condition = ($itemidprev != '');
5008 case 'archiveprevexists':
5009 $condition = ($archiveprevexists == true);
5011 case 'archivenextexists':
5012 $condition = ($archivenextexists == true);
5015 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5018 $condition = $this->ifHasPlugin($name, $value);
5021 $condition = (Admin::getAdminAction() == $name);
5023 case 'adminoldaction':
5024 $condition = (Admin::getAdminAction() == $name);
5026 case 'addresschange':
5027 $condition = ($this->ifAddresscange());
5029 case 'bechangepass':
5030 $condition = ($this->beChangePassword());
5032 case 'skincandidates':
5033 $condition = ($this->ifSkincandidates());
5036 $condition = requestVar('nameclashes');
5038 case 'existsnewplugin':
5039 $condition = ($this->existsNewPlugin());
5046 $condition = (boolean) ($member->getAutosave() == $value);
5053 $condition = (Admin::$blog->getSetting($name) == $value);
5055 case 'itemproperty':
5060 if ( array_key_exists($name, Admin::$item) )
5062 $condition = (boolean) (Admin::$item[$name] == $value);
5066 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5073 * AdminActions::_ifHasPlugin()
5074 * hasplugin,PlugName
5075 * -> checks if plugin exists
5076 * hasplugin,PlugName,OptionName
5077 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5078 * hasplugin,PlugName,OptionName=value
5079 * -> checks if the option OptionName from plugin PlugName is set to value
5081 * @param string $name name of plugin
5082 * @param string $value
5085 private function ifHasPlugin($name, $value)
5089 // (pluginInstalled method won't write a message in the actionlog on failure)
5090 if ( $manager->pluginInstalled("NP_{$name}") )
5092 $plugin =& $manager->getPlugin("NP_{$name}");
5093 if ( $plugin != NULL )
5101 list($name2, $value2) = preg_split('#=#', $value, 2);
5102 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5106 else if ( $plugin->getOption($name2) == $value2 )
5117 * AdminActions::beChangePassword()
5122 private function beChangePassword()
5124 return intRequestVar('bNeedsPasswordChange');
5128 * AdminActions::ifSkincandidates()
5129 * Checks if a plugin exists and call its doIf function
5135 private function ifSkincandidates()
5138 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5139 return (count($candidates) > 0);
5143 * AdminActions::ifPlugin()
5144 * Checks if a plugin exists and call its doIf function
5146 * @param string $name name of plugin
5147 * @param string $key
5148 * @param string $value
5151 private function ifPlugin($name, $key = '', $value = '')
5155 $plugin =& $manager->getPlugin("NP_{$name}");
5161 $params = func_get_args();
5162 array_shift($params);
5164 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5168 * AdminActions::ifCategory()
5169 * Different checks for a category
5171 * @param string $key key for information of category
5172 * @param string $value value for information of category
5175 private function ifCategory($key = '', $value='')
5177 global $blog, $catid;
5179 // when no parameter is defined, just check if a category is selected
5180 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5182 return $blog->isValidCategory($catid);
5185 // check category name
5186 if ( $key == 'catname' )
5188 $value = $blog->getCategoryIdFromName($value);
5189 if ($value == $catid)
5191 return $blog->isValidCategory($catid);
5195 // check category id
5196 if (($key == 'catid') && ($value == $catid))
5198 return $blog->isValidCategory($catid);
5205 * AdminActions::ifOnTeam()
5206 * Checks if a member is on the team of a blog and return his rights
5208 * @param string $blogName name of weblog
5211 private function ifOnTeam($blogName = '')
5213 global $blog, $member, $manager;
5215 // when no blog found
5216 if ( ($blogName == '') && !is_object($blog) )
5221 // explicit blog selection
5222 if ($blogName != '')
5224 $blogid = getBlogIDFromName($blogName);
5227 if (($blogName == '') || !$manager->existsBlogID($blogid))
5230 $blogid = $blog->getID();
5232 return $member->teamRights($blogid);
5236 * AdminActions::ifAdmin()
5237 * Checks if a member is admin of a blog
5239 * @param string $blogName name of weblog
5242 private function ifAdmin($blogName = '')
5244 global $blog, $member, $manager;
5246 // when no blog found
5247 if (($blogName == '') && (!is_object($blog)))
5252 // explicit blog selection
5253 if ($blogName != '')
5255 $blogid = getBlogIDFromName($blogName);
5258 if (($blogName == '') || !$manager->existsBlogID($blogid))
5261 $blogid = $blog->getID();
5264 return $member->isBlogAdmin($blogid);
5268 * AdminActions::ifAddresscange()
5269 * Check e-Mail address is changed
5274 private function ifAddresscange()
5276 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5281 $info = MEMBER::getActivationInfo($key);
5286 $mem = MEMBER::createFromId($info->vmember);
5291 if ( $info->vtype == 'addresschange' )
5299 * AdminActions::templateEditRow()
5302 * @param array $template
5303 * @param string $desc
5304 * @param string $name
5305 * @param string $help
5306 * @param integer $tabindex
5307 * @param boolean $big
5308 * @param array $tmplt
5311 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5315 if ( !array_key_exists($name, $template) )
5317 $template[$name] = '';
5325 $tmplt = skinableTEMPLATE::read($tplt);
5329 'description' => $desc,
5330 'help' => empty($help) ? '' : helpHtml('template' . $help),
5333 'tabindex' => $tabindex,
5334 'rows' => $big ? 10 : 5,
5337 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5339 $base['head'] = "</tr>"
5341 . "<td><%description%><%help%></td>\n"
5342 . "<td id=\"td<%count%>\">\n"
5343 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5347 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5350 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5352 $base['tail'] = "</textarea>\n"
5357 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5360 echo TEMPLATE::fill($base['head'], $data);
5361 echo ENTITY::hsc($template[$name]);
5362 echo TEMPLATE::fill($base['tail'], $data);
5370 * AdminActions::customHelp()
5371 * shows a link to custom help file
5374 * @param string $tplName
5375 * @param string $url
5376 * @param string $iconURL
5377 * @param string $alt
5378 * @param string $title
5382 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5384 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5388 * AdminActions::customHelp()
5389 * shows a link to custom help file
5392 * @param string $tplName
5393 * @param string $url
5394 * @param string $iconURL
5395 * @param string $alt
5396 * @param string $title
5400 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5404 $templates = array();
5408 $templates = Template::read($tplName);
5411 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5413 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5417 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5422 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5425 if ( empty($onclick) )
5427 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5429 elseif ( preg_match('#^onclick#', $onclick) )
5431 $onclick = $onclick;
5435 $onclick = 'onclick="' . $onclick . '"';
5440 'helptarget' => $id,
5441 'onclick' => $onclick,
5442 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5444 return Template::fill($template, $data);
5448 * AdminActions::customHelpHtml()
5451 * @param string $tplName
5452 * @param string $url
5453 * @param string $iconURL
5454 * @param string $alt
5455 * @param string $title
5456 * @param string $onclick
5457 * @return string anchor element with help uri
5459 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5463 $templates = array();
5467 $templates = Template::read($tplName);
5469 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5471 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5475 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5478 if ( empty($iconURL) )
5480 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5483 if ( function_exists('getimagesize') )
5485 $size = getimagesize($iconURL);
5486 $width = 'width="' . $size[0] . '" ';
5487 $height = 'height="' . $size[1] . '" ';
5491 'iconurl' => $iconURL,
5493 'height' => $height,
5494 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5495 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5498 $icon = Template::fill($template, $data);
5499 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5501 return $help . $icon;
5505 * AdminActions::input_yesno
5508 * @param $checkedval
5515 * @param $templateName
5518 public function input_yesno($name,
5529 $templates = array();
5530 if ( $templateName )
5532 $templates = Template::read($templateName);
5535 if ( $name == 'admin' )
5537 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5539 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5540 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5541 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5542 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5546 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5551 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5553 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5557 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5559 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5562 if ( !isset($template) )
5564 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5565 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5566 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5567 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5572 $id = Entity::hsc($name);
5573 $id = str_replace('[', '-', $id);
5574 $id = str_replace(']', '-', $id);
5575 $id1 = $id . Entity::hsc($value1);
5576 $id2 = $id . Entity::hsc($value2);
5578 'name' => Entity::hsc($name),
5579 'yesval' => Entity::hsc($value1),
5580 'noval' => Entity::hsc($value2),
5583 'yesvaltext' => $yesval,
5584 'novaltext' => $noval,
5585 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5586 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5587 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5592 return Template::fill($template, $dat);
5596 echo Template::fill($template, $dat);
5602 * AdminActions::existsNewPlugin()
5603 * Check exists new plugin
5606 * @return boolean exists or not
5608 private function existsNewPlugin()
5610 global $DIR_PLUGINS;
5612 $query = "SELECT * FROM %s;";
5613 $query = sprintf($query, sql_table('plugin'));
5614 $res = DB::getResult($query);
5616 $installed = array();
5617 foreach( $res as $row )
5619 $installed[] = $row['pfile'];
5622 $files = scandir($DIR_PLUGINS);
5624 $candidates = array();
5625 foreach ( $files as $file )
5627 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5629 if ( !in_array($matches[1], $installed) )
5631 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5635 $this->newPlugCandidates = $candidates;
5636 return (count($candidates) > 0);
5640 * AdminActions::pagehead()
5641 * Output admin page head
5646 public function parse_pagehead()
5648 global $member, $nucleus, $CONF, $manager;
5650 $extrahead = Admin::getAdminextrahead();
5652 'extrahead' => &$extrahead,
5653 'action' => Admin::getAdminAction()
5655 $manager->notify('AdminPrePageHead', $data);
5657 $content = $this->parser->skin->getContentFromDB('pagehead');
5660 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5664 if ( !array_key_exists('AdminCSS', $CONF) )
5666 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5667 $CONF['AdminCSS'] = 'original';
5671 /* HTTP 1.1 application for no caching */
5672 header("Cache-Control: no-cache, must-revalidate");
5673 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5675 $root_element = 'html';
5676 $charset = i18n::get_current_charset();
5677 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5678 $xml_version_info = self::$xml_version_info;
5679 $formal_public_identifier = self::$formal_public_identifier;
5680 $system_identifier = self::$system_identifier;
5681 $xhtml_namespace = self::$xhtml_namespace;
5683 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5684 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5685 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5687 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5690 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5692 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5693 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5694 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5695 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5696 echo "{$extrahead}\n";
5699 echo "<div id=\"adminwrapper\">\n";
5700 echo "<div class=\"header\">\n";
5701 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5703 echo "<div id=\"container\">\n";
5704 echo "<div id=\"content\">\n";
5705 echo "<div class=\"loginname\">\n";
5707 if ( !$member->isLoggedIn() )
5709 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5713 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5714 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5717 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5720 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5722 $codenamestring = '';
5726 $codenamestring = ' "' . $nucleus['codename'].'"';
5729 if ( $member->isLoggedIn() && $member->isAdmin() )
5731 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5732 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5734 $newestVersion = getLatestVersion();
5735 $newestCompare = str_replace('/', '.', $newestVersion);
5736 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5738 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5741 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5742 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5748 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5755 $this->parser->parse($content);
5762 * AdminActionss::pagefoot()
5763 * Output admin page foot include quickmenu
5768 public function parse_pagefoot()
5770 global $action, $member, $manager;
5773 'action' => Admin::getAdminAction()
5775 $manager->notify('AdminPrePageFoot', $data);
5777 $content = $this->parser->skin->getContentFromDB('pagefoot');
5780 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5782 echo '<h2>' . _LOGOUT . "</h2>\n";
5784 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5785 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5789 echo "<div class=\"foot\">\n";
5790 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5792 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5795 echo "<div id=\"quickmenu\">\n";
5797 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5800 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5803 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5804 echo "<form method=\"get\" action=\"index.php\">\n";
5806 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5808 $showAll = requestVar('showall');
5810 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5812 // Super-Admins have access to all blogs! (no add item support though)
5813 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5814 $query = sprintf($query, sql_table('blog'));
5818 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5819 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5821 $template['name'] = 'blogid';
5822 $template['tabindex'] = 15000;
5823 $template['extra'] = _QMENU_ADD_SELECT;
5824 $template['selected'] = -1;
5825 $template['shorten'] = 10;
5826 $template['shortenel'] = '';
5827 $template['javascript'] = 'onchange="return form.submit()"';
5828 showlist($query, 'select', $template);
5833 echo "<h2>{$member->getDisplayName()}</h2>\n";
5835 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5836 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5837 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5840 if ( $member->isAdmin() )
5842 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5844 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5845 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5846 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5847 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5848 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5849 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5850 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5853 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5855 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5856 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5857 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5861 $data = array('options' => array());
5863 $manager->notify('QuickMenu', $data);
5865 if ( count($data['options']) > 0 )
5867 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5869 foreach ( $data['options'] as $option )
5871 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5876 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5879 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5883 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5886 echo "<!-- quickmenu -->\n";
5889 echo "<!-- content -->\n";
5892 echo "<!-- container -->\n";
5895 echo "<!-- adminwrapper -->\n";
5903 $this->parser->skin->parse('pagefoot');
5910 * AdminActions::selectBlog()
5911 * Inserts a HTML select element with choices for all blogs to which the user has access
5912 * mode = 'blog' => shows blognames and values are blogids
5913 * mode = 'category' => show category names and values are catids
5915 * @param string $name
5916 * @param string $mode
5917 * @param integer $selected
5918 * @param integer $tabindex
5919 * @param integer $showNewCat
5920 * @param integer $iForcedBlogInclude ID for weblog always included
5921 * @param $iForcedBlogInclude
5922 * ID of a blog that always needs to be included, without checking if the
5923 * member is on the blog team (-1 = none)
5926 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5928 global $member, $CONF;
5930 // 0. get IDs of blogs to which member can post items (+ forced blog)
5931 $aBlogIds = array();
5932 if ( $iForcedBlogInclude != -1 )
5934 $aBlogIds[] = intval($iForcedBlogInclude);
5937 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5939 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5940 $query = sprintf($query, sql_table('blog'));
5944 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5945 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5948 $rblogids = DB::getResult($query);
5949 foreach ( $rblogids as $row )
5951 if ( $row['bnumber'] != $iForcedBlogInclude )
5953 $aBlogIds[] = intval($row['bnumber']);
5957 if ( count($aBlogIds) == 0 )
5962 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5964 // 1. select blogs (we'll create optiongroups)
5965 // (only select those blogs that have the user on the team)
5966 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5967 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5968 $blogs = DB::getResult($queryBlogs);
5970 if ( $mode == 'category' )
5972 if ( $blogs->rowCount() > 1 )
5976 foreach ( $blogs as $rBlog )
5978 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5980 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5983 // show selection to create new category when allowed/wanted
5986 // check if allowed to do so
5987 if ( $member->blogAdminRights($rBlog['bnumber']) )
5989 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5993 // 2. for each category in that blog
5994 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5995 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5996 $categories = DB::getResult($catQuery);
5997 foreach ( $categories as $rCat )
5999 if ( $rCat['catid'] == $selected )
6001 $selectText = ' selected="selected" ';
6007 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
6010 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6018 foreach ( $blogs as $rBlog )
6020 echo '<option value="' . $rBlog['bnumber'] . '"';
6021 if ( $rBlog['bnumber'] == $selected )
6023 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
6027 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";