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(
157 * AdminActions::$skin_type_friendly_names
158 * friendly name for wrapped page types
160 static private $default_skin_types = array(
161 'actionlog' => _ADM_SKPRT_ACTIONLOG,
162 'activate' => _ADM_SKPRT_ACTIVATE,
163 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
164 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
165 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
166 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
167 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
168 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
169 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
170 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
171 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
172 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
173 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
174 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
175 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
176 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
177 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
178 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
179 'banlist' => _ADM_SKPRT_BANLIST,
180 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
181 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
182 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
183 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
184 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
185 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
186 'batchitem' => _ADM_SKPRT_BATCHITEM,
187 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
188 'batchmove' => _ADM_SKPRT_BATCHMOVE,
189 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
190 'batchteam' => _ADM_SKPRT_BATCHTEAM,
191 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
192 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
193 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
194 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
195 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
196 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
197 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
198 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
199 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
200 'createitem' => _ADM_SKPRT_CREATEITEM,
201 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
202 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT, /* not yet */
203 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS, /* not yet */
204 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED, /* not yet */
205 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
206 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
207 'forgotpassword' => _ADM_SKPRT_FORGOTPASSWORD, /* not yet */
208 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
209 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
210 'itemedit' => _ADM_SKPRT_ITEMEDIT,
211 'itemlist' => _ADM_SKPRT_ITEMLIST,
212 'itemmove' => _ADM_SKPRT_ITEMMOVE,
213 'login' => FALSE, //missing
214 'manage' => _ADM_SKPRT_MANAGE,
215 'manageteam' => _ADM_SKPRT_MANAGETEAM,
216 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
217 'memberedit' => FALSE, //missing
218 'overview' => _ADM_SKPRT_OVERVIEW,
219 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
220 'pagehead' => _ADM_SKPRT_PAGEHEAD,
221 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
222 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
223 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
224 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
225 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
226 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
227 'skindelete' => _ADM_SKPRT_SKINDELETE,
228 'skinedit' => _ADM_SKPRT_SKINEDIT,
229 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
230 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
231 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
232 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
233 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
234 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
235 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
236 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
237 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
238 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
239 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
240 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
244 * AdminActions::getAvailableSkinTypes()
248 * @return array list of friendly names for page actions
250 static public function getAvailableSkinTypes()
252 return self::$default_skin_types;
256 * AdminActions::getDefaultTypes()
260 * @return array list of friendly names for page actions
262 static public function getDefaultTypes()
264 return self::$default_skin_types;
268 * AdminActions::__construct()
269 * Constructor for a new Actions object
271 * @param string $type
274 public function __construct($type)
276 // call constructor of superclass first
277 parent::__construct();
278 $this->skintype = $type;
279 if ( !class_exists('Navlist') || !class_exists('Batch') )
282 include $DIR_LIBS . 'ENCAPSULATE.php';
288 * AdminActions::getAvailableActions()
291 * @return array allowed actions for the page type
293 public function getAvailableActions()
295 $extra_actions = array();
297 switch ( $this->skintype )
300 $extra_actions = array(
305 $extra_actions = array(
310 case 'activatesetpwd':
311 $extra_actions = array(
315 $extra_actions = array(
321 case 'adminerrorpage':
322 $extra_actions = array(
325 case 'adminskindelete':
326 $extra_actions = array(
330 case 'adminskinedit':
331 $extra_actions = array(
333 'defaultadminskintypes',
334 'adminspecialskinlist',
337 case 'adminskinedittype':
338 $extra_actions = array(
341 'allowedadminskinactions',
342 'adminskineditallowedlist',
345 case 'adminskiniedoimport':
346 $extra_actions = array(
350 case 'adminskinieimport':
351 $extra_actions = array(
355 case 'adminskinieoverview':
356 $extra_actions = array(
357 'selectlocaladminskinfiles',
361 case 'adminskinoverview':
362 $extra_actions = array(
366 case 'adminskinremovetype':
367 $extra_actions = array(
371 case 'admintemplatedelete':
372 $extra_actions = array(
373 'editadmintemplateinfo',
375 case 'admintemplateedit':
376 $extra_actions = array(
377 'editadmintemplateinfo',
380 case 'admntemplateoverview':
381 $extra_actions = array(
382 'admintemplateoverview',
385 case 'backupoverview':
386 $extra_actions = array(
389 case 'backuprestore':
390 $extra_actions = array(
394 $extra_actions = array(
400 case 'banlistdelete':
401 $extra_actions = array(
406 case 'banlistdeleteconfirm':
407 $extra_actions = array(
408 'banlistdeletedlist',
413 $extra_actions = array(
419 case 'batchcategory':
420 $extra_actions = array(
426 $extra_actions = array(
432 $extra_actions = array(
438 $extra_actions = array(
444 $extra_actions = array(
450 $extra_actions = array(
459 $extra_actions = array(
468 $extra_actions = array(
474 case 'blogcommentlist':
475 $extra_actions = array(
482 $extra_actions = array(
498 $extra_actions = array(
502 case 'browseowncomments':
503 $extra_actions = array(
507 case 'browseownitems':
508 $extra_actions = array(
512 case 'categorydelete':
513 $extra_actions = array(
519 $extra_actions = array(
526 case 'commentdelete':
527 $extra_actions = array(
532 $extra_actions = array(
536 case 'createaccountinput':
537 $extra_actions = array(
542 case 'createaccountsuccess':
543 $extra_actions = array(
\r
544 /* nothing special */
547 case 'createaccountdisable':
548 $extra_actions = array(
553 $extra_actions = array(
564 $extra_actions = array(
570 $extra_actions = array(
575 case 'editmembersettings':
576 $extra_actions = array(
577 'adminskinselectoptions',
579 'localeselectoptions',
583 case 'forgotpassword':
584 $extra_actions = array(
588 case 'itemcommentlist':
589 $extra_actions = array(
595 $extra_actions = array(
602 $extra_actions = array(
613 $extra_actions = array(
620 $extra_actions = array(
626 $extra_actions = array(
630 $extra_actions = array(
639 $extra_actions = array(
644 $extra_actions = array(
649 $extra_actions = array(
654 $extra_actions = array(
660 $extra_actions = array(
665 case 'pluginoptions':
666 $extra_actions = array(
668 'editplugoptionslist',
672 $extra_actions = array(
675 'configsettingsedit',
676 'configsettingsyesno',
679 'localeselectoptions',
685 $extra_actions = array(
690 $extra_actions = array(
695 $extra_actions = array(
701 $extra_actions = array(
704 'allowedskinactions',
705 'skineditallowedlist',
706 'skineditallowedlist',
709 case 'skiniedoimport':
710 $extra_actions = array(
715 $extra_actions = array(
719 case 'skinieoverview':
720 $extra_actions = array(
721 'selectlocalskinfiles',
726 $extra_actions = array(
730 case 'skinremovetype':
731 $extra_actions = array(
735 case 'systemoverview':
736 $extra_actions = array(
741 $extra_actions = array(
747 case 'templatedelete':
748 $extra_actions = array(
753 $extra_actions = array(
757 case 'templateoverview':
758 $extra_actions = array(
762 case 'usermanagement':
763 $extra_actions = array(
769 $extra_actions = array(
778 'selectlocaladminskinfiles',
786 $defined_actions = array_merge(self::$default_actions, $extra_actions);
788 return array_merge($defined_actions, parent::getAvailableActions());
792 * AdminActions::parse_actionloglist()
793 * Parse skinvar actionloglist
795 * @param string $templateName name of template to use
798 public function parse_actionloglist($templateName = '')
800 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
801 $query = sprintf($query, sql_table('actionlog'));
803 $template['content'] = 'actionlist';
804 $amount = showlist($query, 'table', $template, $templateName);
810 * AdminActions::parse_activationmessage()
811 * Parse skinvar activationmessage
813 * @param string $type type of message
814 * @param string $templateName name of template to use
817 public function parse_activationmessage($type, $templateName = '')
819 global $CONF, $manager;
823 if ( !empty($templateName))
825 $template = Template::read($templateName);
828 $key = postVar('ackey');
831 Admin::error(_ERROR_ACTIVATE);
834 $info = MEMBER::getActivationInfo($key);
837 Admin::error(_ERROR_ACTIVATE);
840 $mem = MEMBER::createFromId($info->vmember);
843 Admin::error(_ERROR_ACTIVATE);
845 switch ( $info->vtype )
848 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
850 $title = $template['ACTIVATE_FORGOT_TITLE'];
854 $title = _ACTIVATE_FORGOT_TITLE;
856 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
858 $text = $template['ACTIVATE_FORGOT_TEXT'];
862 $text = _ACTIVATE_FORGOT_TEXT;
866 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
868 $title = $template['ACTIVATE_REGISTER_TITLE'];
872 $title = _ACTIVATE_REGISTER_TITLE;
874 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
876 $text = $template['ACTIVATE_REGISTER_TEXT'];
880 $text = _ACTIVATE_REGISTER_TEXT;
883 case 'addresschange':
884 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
886 $title = $template['ACTIVATE_CHANGE_TITLE'];
890 $title = _ACTIVATE_CHANGE_TITLE;
892 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
894 $text = $template['ACTIVATE_CHANGE_TEXT'];
898 $text = _ACTIVATE_CHANGE_TEXT;
903 'memberName' => Entity::hsc($mem->getDisplayName()),
904 'realName' => Entity::hsc($mem->getRealName()),
909 echo Template::fill($title, $aVars);
912 echo Template::fill($text, $aVars);
915 echo Entity::hsc($key);
922 * AdminActions::parse_addtickettourl()
923 * Parse skinvar addtickettourl
925 * @param string $url URI for ticket
928 public function parse_addtickettourl($url)
931 $url = $manager->addTicketToUrl($url);
932 echo Entity::hsc($url);
937 * AdminActions::parse_adminbanlist()
938 * Parse skinvar adminbanlist
940 * @param string $templateName name of template to use
943 public function parse_adminbanlist($templateName = '')
945 $blogid = intRequestVar('blogid');
947 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
948 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
950 $template['content'] = 'banlist';
952 $amount = Showlist($query, 'table', $template, $templateName);
962 * AdminActions::parse_adminbatchaction()
963 * Parse skinvar adminbatchaction
968 public function parse_adminbatchaction()
970 echo Entity::hsc(requestVar('batchaction'));
975 * AdminActions::parse_adminbatchlist()
976 * Parse skinvar adminbatchlist
978 * @param string $templateName name of template to use
981 public function parse_adminbatchlist($templateName = '')
984 $templates = array();
986 if ( !empty($templateName) )
988 $templates = Template::read($templateName);
991 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
993 $template = '<li><%text(_BATCH_EXECUTING)%> '
994 . '<b><%adminbatchaction%></b> '
995 . '<%batchlisttype%> '
996 . '<b><%batchid%></b>... '
997 . '<b><%batchlistmsg%></b>'
1002 $template = $templates['ADMIN_BATCHLIST'];
1005 $selected = requestIntArray('batch');
1006 $action = requestVar('batchaction');
1008 switch ( $this->skintype )
1011 $batchlisttype = _BATCH_ONITEM;
1012 $deleteaction = 'deleteOneItem';
1013 $moveaction = 'moveOneItem';
1014 $destid = intRequestVar('destcatid');
1016 case 'batchcomment':
1017 $batchlisttype = _BATCH_ONCOMMENT;
1018 $deleteaction = 'deleteOneComment';
1021 $batchlisttype = _BATCH_ONMEMBER;
1022 $deleteaction = 'deleteOneMember';
1023 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1024 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1025 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1026 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1029 $blogid = intRequestVar('blogid');
1030 $batchlisttype = _BATCH_ONTEAM;
1031 $deleteaction = 'deleteOneTeamMember';
1032 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1033 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1034 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1035 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1037 case 'batchcategory':
1038 $batchlisttype = _BATCH_ONCATEGORY;
1039 $deleteaction = 'deleteOneCategory';
1040 $moveaction = 'moveOneCategory';
1041 $destid = intRequestVar('destblogid');
1045 // walk over all selectedids and perform action
1046 foreach ( $selected as $selectedid )
1049 $selectedid = intval($selectedid);
1053 if ( $this->skintype != 'batchteam' )
1055 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1059 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1063 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1067 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1071 // there should always remain at least one super-admin
1072 $r = DB::getResult($unsetchksql);
1073 if ( $r->rowCount() < 2 )
1075 $error = $unseterrmsg;
1079 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1083 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1087 'batchid' => $selectedid,
1088 'batchlisttype' => Entity::hsc($batchlisttype),
1089 'adminbatchaction' => Entity::hsc($action),
1090 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1093 $handler = new AdminActions('template');
1094 $parser = new Parser($handler);
1096 $output = Template::fill($template, $data);
1098 $parser->parse($output);
1099 $output = ob_get_contents();
1101 echo "{$output}<br />";
1107 * AdminActions::parse_adminbloglink()
1108 * Parse skinvar adminbloglink
1110 * @param string $templateName name of template to use
1113 public function parse_adminbloglink($templateName = '')
1116 $blogid = intRequestVar('blogid');
1117 $blog =& $manager->getBlog($blogid);
1118 $templates = array();
1120 if ( !empty($templateName) )
1122 $templates = Template::read($templateName);
1125 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1127 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1131 $template = $templates['ADMIN_BLOGLINK'];
1135 'url' => Entity::hsc($blog->getURL()),
1136 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1137 'blogname' => Entity::hsc($blog->getName())
1140 echo Template::fill($template, $data);
1145 * AdminActions::parse_adminerrormesg()
1146 * Parse skinvar adminerrormesg
1151 public function parse_adminerrormesg()
1156 if ( requestVar('errormessage') )
1158 $message = requestVar('errormessage');
1160 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1162 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1164 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1166 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1168 echo Entity::hsc($message);
1173 * AdminActions::parse_adminskineditallowedlist()
1174 * Parse skinvar adminskineditallowedlist
1176 * @param string $type template/blog
1177 * @param string $templateName name of template to use
1180 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1184 /* TODO: blog seems not to be used */
1186 $query = "SELECT bshortname, bname FROM %s";
1187 $query = sprintf($query, sql_table('blog'));
1189 'content' => 'shortblognames'
1191 Showlist($query, 'table', $show, $templateName);
1194 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1195 $query = sprintf($query, sql_table('template_desc'));
1197 'content' => 'shortnames'
1199 Showlist($query, 'table', $show, $templateName);
1206 * AdminActions::parse_adminskinielist()
1207 * Parse skinvar adminskinielist
1209 * @param string $type skin/template
1210 * @param string $templateName name of template to use
1213 public function parse_adminskinielist($type, $templateName = '')
1215 $templates = array();
1216 if ( $templateName )
1218 $templates = Template::read($templateName);
1221 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1224 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1225 . "<label for=\"<%expid%>\"><%expname%></label>"
1227 . "<td><%expdesc%></td>\n"
1233 $template = $templates['SKINIE_EXPORT_LIST'];
1239 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1240 $query = sprintf($query, sql_table('skin_desc'));
1241 $res = DB::getResult($query);
1243 foreach ( $res as $row )
1246 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1247 'expid' => 'skinexp' . $row['sdnumber'],
1248 'expname' => Entity::hsc($row['sdname']),
1249 'expdesc' => Entity::hsc($row['sddesc']),
1251 echo Template::fill($template, $data);
1255 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1256 $query = sprintf($query, sql_table('template_desc'));
1257 $res = DB::getResult($query);
1258 foreach ( $res as $row )
1261 'typeid' => 'template[' . $row['tdnumber'] . ']',
1262 'expid' => 'templateexp' . $row['tdnumber'],
1263 'expname' => Entity::hsc($row['tdname']),
1264 'expdesc' => Entity::hsc($row['tddesc']),
1266 echo Template::fill($template, $data);
1274 * AdminActions::parse_adminskinoverview()
1275 * Parse skinvar adminskinoverview
1277 * @param string $templateName name of template to use
1280 public function parse_adminskinoverview($templateName = '')
1282 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1283 $query = sprintf($query, sql_table('skin_desc'));
1285 $template['content'] = 'adminskinlist';
1286 $template['tabindex'] = 10;
1287 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1288 Showlist($query, 'table', $template, $templateName);
1293 * AdminActions::parse_adminskinselectoptions()
1294 * Parse skinvar adminskinselectoptions
1299 public function parse_adminskinselectoptions($templateName = '')
1302 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1303 $query = sprintf($query, sql_table('skin_desc'));
1305 $template['name'] = 'adminskin';
1306 $template['selected'] = $CONF['AdminSkin'];
1307 $template['tabindex'] = 110;
1308 Showlist($query, 'select', $template, $templateName);
1313 * AdminActions::parse_adminspecialskinlist()
1314 * Parse skinvar adminspecialskinlist
1316 * @param string $templateName name of template to use
1318 public function parse_adminspecialskinlist($templateName = '')
1320 $templates = array();
1321 if ( $templateName )
1323 $templates = Template::read($templateName);
1326 $nType = $this->parser->skin->getAvailableTypes();
1327 $skinid = intRequestVar('skinid');
1329 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1330 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1332 $res = DB::getResult($query);
1333 if ( $res && $res->rowCount() > 0 )
1335 /* NOTE: set templates for HEAD/BODY/FOOT */
1336 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1338 $template['head'] = "<ul>\n";
1342 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1344 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1346 $template['body'] = '<li>'
1347 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1350 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1357 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1359 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1361 $template['foot'] = "</ul>\n";
1365 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1372 echo $template['head'];
1373 foreach ( $res as $row )
1376 'tabindex' => $tabstart++,
1377 'skinid' => $skinid,
1378 'skintype' => Entity::hsc(strtolower($row['stype']))
1380 echo Template::fill($template['body'], $data);
1383 echo $template['foot'];
1389 * AdminActions::parse_admintemplateoverview()
1390 * Parse skinvar admintemplateoverview
1392 * @param string $templateName name of template to use
1395 public function parse_admintemplateoverview($templateName = '')
1397 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1398 $query = sprintf($query, sql_table('template_desc'));
1400 $template['content'] = 'admintemplatelist';
1401 $template['tabindex'] = 10;
1403 Showlist($query, 'table', $template, $templateName);
1408 * AdminActions::parse_allowedadminskinactions()
1409 * Parse skinvar allowedadminskinactions
1414 public function parse_allowedadminskinactions()
1416 global $DIR_ADMINSKINS;
1417 $skinType = strtolower(trim(requestVar('type')));
1418 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1421 while ( $current = array_shift($actions) )
1423 // TODO: remove this
1424 // skip deprecated vars
1425 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1430 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1432 if ( count($actions) != 0 )
1441 * AdminActions::parse_allowedskinactions()
1442 * Parse skinvar allowedskinactions
1447 public function parse_allowedskinactions()
1449 $skinType = strtolower(trim(requestVar('type')));
1450 $skinid = intRequestVar('skinid');
1452 $skin = new Skin($skinid);
1453 $actions = $skin->getAllowedActionsForType($skinType);
1456 while ( $current = array_shift($actions) )
1458 // TODO: remove this
1459 // skip deprecated vars
1460 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1465 /* TODO: alternative function should be used or not? */
1466 echo helplink("skinvar-{$current}") . "$current</a>\n";
1468 if ( count($actions) != 0 )
1477 * AdminActions::parse_banlistdeletedlist()
1478 * Parse skinvar banlistdeletedlist
1480 * @param string $templateName name of template to use
1483 public function parse_banlistdeletedlist($templateName = '')
1487 $templates = array();
1488 if ( $templateName )
1490 $templates = Template::read($templateName);
1493 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1495 $template = "<li><%blogname%></li>\n";
1499 $template = $templates['BANLIST_DELETED_LIST'];
1502 $deleted = requestArray('delblogs');
1503 foreach ( $deleted as $delblog )
1505 $blog =& $manager->getBlog($delblog);
1507 'blogname' => Entity::hsc($blog->getName())
1509 echo Template::fill($template, $data);
1516 * AdminActions::parse_batchdeletelist()
1517 * Parse skinvar batchdeletelist
1522 public function parse_batchdeletelist()
1524 $selected = requestIntArray('batch');
1527 foreach ( $selected as $select )
1529 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1531 // add hidden vars for team & comment
1532 if ( requestVar('action') == 'batchteam' )
1534 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1536 if ( requestVar('action') == 'batchcomment' )
1538 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1544 * AdminActions::parse_batchdeletetype()
1545 * Parse skinvar batchdeletetype
1550 public function parse_batchdeletetype()
1552 echo Entity::hsc(requestVar('action'));
1557 * AdminActions::parse_batchmovebtn()
1558 * Parse skinvar batchmovebtn
1563 public function parse_batchmovebtn()
1565 $actionType = requestVar('action');
1566 switch ( $actionType )
1571 case 'batchcategory':
1579 * AdminActions::parse_batchmovelist()
1580 * Parse skinvar batchmovelist
1585 public function parse_batchmovelist()
1587 $selected = requestIntArray('batch');
1589 foreach ( $selected as $select )
1591 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1598 * AdminActions::parse_batchmovetitle()
1599 * Parse skinvar batchmovetitle
1604 public function parse_batchmovetitle()
1606 $actionType = requestVar('action');
1607 switch ( $actionType )
1612 case 'batchcategory':
1613 echo _MOVECAT_TITLE;
1620 * AdminActions::parse_batchmovetype()
1621 * Parse skinvar batchmovetype
1626 public function parse_batchmovetype()
1628 echo Entity::hsc(requestVar('action'));
1633 * AdminActions::parse_blogcatlist()
1634 * Parse skinvar blogcatlist
1639 public function parse_blogcatlist($templateName = '')
1642 $blogid = intRequestVar('blogid');
1643 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1644 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1646 $template['content'] = 'categorylist';
1647 $template['tabindex'] = 200;
1649 $batch = new Batch('category');
1650 $batch->showlist($query, 'table', $template, $templateName);
1655 * AdminActions::parse_blogid()
1656 * Parse skinvar blogid
1661 public function parse_blogid()
1663 echo intRequestVar('blogid');
1668 * AdminActions::parse_blognotifysetting()
1669 * Parse skinvar blognotifysetting
1674 public function parse_blognotifysetting($type)
1677 $blogid = intRequestVar('blogid');
1678 $blog = $manager->getBlog($blogid);
1683 if ( !$blog->notifyOnComment() )
1689 if ( !$blog->notifyOnVote() )
1695 if ( !$blog->notifyOnNewItem() )
1701 echo ' checked="checked"';
1706 * AdminActions::parse_blogsetting()
1707 * Parse skinvar blogsetting
1709 * @param string $which name of weblog setting
1712 public function parse_blogsetting($which)
1714 echo $this->parse_getblogsetting($which);
1719 * AdminActions::parse_blogsettingyesno()
1720 * Parse skinvar blogsettingyesno
1722 * @param string $type type of weblog setting
1723 * @param string $templateName name of template to use
1726 public function parse_blogsettingyesno($type, $templateName = '')
1730 $blogid = intRequestVar('blogid');
1731 $blog = $manager->getBlog($blogid);
1735 case 'convertbreaks':
1736 $checkedval = $blog->convertBreaks();
1739 case 'allowpastposting':
1740 $checkedval = $blog->allowPastPosting();
1744 $checkedval = $blog->commentsEnabled();
1748 $checkedval = $blog->isPublic();
1752 $checkedval = $blog->emailRequired();
1756 $checkedval = $blog->getSearchable();
1760 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1765 * AdminActions::parse_blogteamlist()
1766 * Parse skinvar blogteamlist
1768 * @param string $templateName name of template to use
1771 public function parse_blogteamlist($templateName = '')
1774 $blogid = intRequestVar('blogid');
1775 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1777 . "WHERE tmember=mnumber AND tblog= %d";
1778 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1780 $template['content'] = 'teamlist';
1781 $template['tabindex'] = 10;
1783 $batch = new Batch('team');
1784 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1789 * AdminActions::parse_blogteammembers()
1790 * Parse skinvar blogteammembers
1795 public function parse_blogteammembers()
1797 $blogid = intRequestVar('blogid');
1798 $query = "SELECT mname, mrealname "
1800 . "WHERE mnumber=tmember AND tblog=%d;";
1801 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1802 $res = DB::getResult($query);
1803 $memberNames = array();
1804 foreach ( $res as $row )
1806 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1808 echo implode(',', $memberNames);
1812 * AdminActions::parse_blogtime()
1813 * Parse skinvar blogtime
1815 * @param string $type type of time
1816 * @param string $format format for time expression
1817 * @param integer $offset offset of time
1820 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1824 if ( $type != 'blogtime' )
1826 /* return server time */
1827 $timestamp = time() + $offset;
1831 $bid = intRequestVar('blogid');
1832 $b = $manager->getBlog($bid);
1833 $timestamp = $b->getCorrectTime() + $offset;
1836 echo i18n::formatted_datetime($format, $timestamp);
1841 * AdminActions::parse_bookmarkletadmin()
1842 * Parse skinvar bookmarkletadmin
1847 public function parse_bookmarkletadmin()
1851 $blogid = intRequestVar('blogid');
1853 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1858 * AdminActions::parse_categories()
1859 * Parse skinvar categories
1861 * create category dropdown box
1863 * @param string $type name of setting for category
1866 public function parse_categories($startidx = 0)
1871 $itemid = intRequestVar('itemid');
1872 $item = &$manager->getItem($itemid, 1, 1);
1877 $blogid = intRequestVar('blogid');
1881 $blogid = $item['blogid'];
1883 $blog = &$manager->getBlog($blogid);
1885 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1887 $item['body'] = removeBreaks($item['body']);
1888 $item['more'] = removeBreaks($item['more']);
1891 $contents = array();
1892 if ( requestVar('action') == 'itemedit' )
1897 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1900 $catid = $blog->getDefaultCategory();
1905 $catid = $contents['catid'];
1908 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1914 * AdminActions::parse_category()
1915 * Parse skinvar category
1917 * @param string $type name of setting for category
1920 public function parse_category($type = 'name')
1922 echo $this->parse_getcategory($type);
1927 * AdminActions::parse_categorysetting()
1928 * Parse skinvar categorysetting
1930 * @param string $type type in category setting
1933 public function parse_categorysetting($type)
1935 $catid = intRequestVar('catid');
1936 if ( $type == 'id' )
1941 $blogid = intRequestVar('blogid');
1942 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1943 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1944 $row = DB::getRow($query);
1946 if ( $type != 'name' )
1948 echo Entity::hsc($row['cdesc']);
1952 echo Entity::hsc($row['cname']);
1959 * AdminActions::parse_codename()
1960 * Parse templatevar codename
1966 public function parse_checkedonval($value, $name)
1971 $itemid = intRequestVar('itemid');
1972 $item =& $manager->getItem($itemid, 1, 1);
1974 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1976 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1978 $item['body'] = removeBreaks($item['body']);
1979 $item['more'] = removeBreaks($item['more']);
1982 $contents = array();
1983 if ( requestVar('action') == 'itemedit' )
1987 if ( !isset($contents[$name]) )
1989 $contents[$name] = '';
1991 if ($contents[$name] == $value)
1993 echo 'checked="checked"';
1999 * AdminActions::parse_codename()
2000 * Parse templatevar codename
2005 * TODO: is this need???
2007 public function parse_codename()
2010 echo $nucleus['codename'];
2015 * AdminActions::parse_commentnavlist()
2016 * Parse skinvar commentnavlist
2021 public function parse_commentnavlist()
2023 global $CONF, $manager, $member;
2026 if ( postVar('start') )
2028 $start = intPostVar('start');
2035 // amount of items to show
2036 if ( postVar('amount') )
2038 $amount = intPostVar('amount');
2042 $amount = (integer) $CONF['DefaultListSize'];
2048 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2050 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2052 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2054 if ( $this->skintype == 'itemcommentlist' )
2056 $itemid = intRequestVar('itemid');
2057 $query .= " citem={$itemid}";
2058 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2060 $nonComments = _NOCOMMENTS;
2062 elseif ( $this->skintype == 'browseowncomments' )
2065 $query .= ' cmember=' . $member->getID();
2066 $template['canAddBan'] = 0;
2068 $nonComments = _NOCOMMENTS_YOUR;
2070 elseif ( $this->skintype == 'blogcommentlist' )
2073 $query .= ' cblog=' . intRequestVar('blogid');
2074 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2075 $bid = intRequestVar('blogid');
2076 $nonComments = _NOCOMMENTS_BLOG;
2079 $search = postVar('search');
2080 if ( !empty($search) )
2082 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2085 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2087 $template['content'] = 'commentlist';
2089 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2090 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2095 * AdminActions::parse_configsettingsedit()
2096 * Parse skinvar configsettingsedit
2098 * @param string $type type of global configuration
2101 public function parse_configsettingsedit($type)
2106 case 'DefaultListSize':
2107 if ( !array_key_exists('DefaultListSize', $CONF) )
2109 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2110 $query = sprintf($query, sql_table('config'));
2111 DB::execute($query);
2112 $CONF['DefaultListSize'] = 10;
2114 elseif ( intval($CONF['DefaultListSize']) < 1 )
2116 $CONF['DefaultListSize'] = 10;
2118 echo intval($CONF['DefaultListSize']);
2120 case 'SessionCookie':
2121 $value = $CONF['SessionCookie'];
2122 $txt1 = _SETTINGS_COOKIESESSION;
2123 $txt2 = _SETTINGS_COOKIEMONTH;
2124 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2127 $value = $CONF['URLMode'];
2128 $txt1 = _SETTINGS_URLMODE_NORMAL;
2129 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2130 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2133 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2135 echo Entity::hsc($CONF[$type]);
2143 * AdminActions::parse_configsettingsyesno()
2144 * Parse skinvar configsettingsyesno
2146 * @param string $type type of global setting
2147 * @param integer $tabindex tabindex attribute of input element
2150 public function parse_configsettingsyesno($type, $tabindex)
2153 if ( array_key_exists($type, $CONF) )
2155 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2161 * AdminActions::parse_contents()
2162 * Parse skinvar contents
2164 * @param string $which part for item
2167 public function parse_contents($which)
2169 if ( !array_key_exists($which, Admin::$contents) )
2171 Admin::$contents[$which] = '';
2173 echo Entity::hsc(Admin::$contents[$which]);
2177 * AdminActions::parse_currenttime()
2178 * Parse skinvar currenttime
2180 * @param string $what
2183 public function parse_currenttime($what)
2185 $nu = getdate(Admin::$blog->getCorrectTime());
2190 * AdminActions::parse_customhelplink()
2191 * Parse skinvar customhelplink
2193 * @param string $topic name of topic
2194 * @param string $tplName name of template
2195 * @param string $url string as URI
2196 * @param string $iconURL string as URI for icon
2197 * @param string $alt alternative text for image element
2198 * @param string $title title for anchor element
2201 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2203 $this->customHelp($topic, $url, $iconURL);
2208 * AdminActions::parse_date()
2209 * Parse skinvar date
2211 public function parse_date($format = 'c')
2213 global $CONF, $manager;
2214 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2219 * AdminActions::parse_defaultadminskintypes()
2220 * Parse skinvar defaultadminskintypes
2222 * @param string $tabindex index number for tabindex attribute of input element
2223 * @param string $templateName name of template
2226 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2228 $templates = array();
2230 if ( $templateName )
2232 $templates = Template::read($templateName);
2235 $types = $this->parser->skin->getAvailableTypes();
2238 /* NOTE: set templates for HEAD/BODY/FOOT */
2239 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2241 $template['head'] = "<ul>\n";
2245 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2247 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2249 $template['body'] = "<li>"
2250 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2255 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2257 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2259 $template['foot'] = "</ul>\n";
2263 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2266 $handler = new AdminActions('template');
2267 $parser = new PARSER($handler);
2269 /* NOTE: do output */
2270 echo $template['head'];
2271 foreach ( $types as $type => $fName )
2273 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2275 'tabindex' => $tabindex,
2276 'skintype' => $type,
2278 'help' => $helplink,
2279 'skinid' => intrequestVar('skinid'),
2281 $parser->parse(Template::fill($template['body'], $data));
2284 echo $template['foot'];
2290 * AdminActions::parse_defblogselect()
2291 * Parse skinvar defblogselect
2293 * @param string $templateName name of template
2296 public function parse_defblogselect($templateName = '')
2300 $query = "SELECT bname as text, bnumber as value FROM %s;";
2301 $query = sprintf($query, sql_table('blog'));
2303 $template['name'] = 'DefaultBlog';
2304 $template['selected'] = $CONF['DefaultBlog'];
2305 $template['tabindex'] = 10;
2307 Showlist($query, 'select', $template, $templateName);
2313 * AdminActions::parse_defcatselect()
2314 * Parse skinvar defcatselect
2316 * @param string $templateName name of template
2319 public function parse_defcatselect($templateName = '')
2323 $blogid = intRequestVar('blogid');
2324 $blog = $manager->getBlog($blogid);
2326 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2327 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2329 $template['name'] = 'defcat';
2330 $template['selected'] = $blog->getDefaultCategory();
2331 $template['tabindex'] = 110;
2333 Showlist($query, 'select', $template, $templateName);
2339 * AdminActions::parse_defskinselect()
2340 * Parse skinvar defskinselect
2342 * @param string $type type of skin
2343 * @param string $templateName name of template
2346 public function parse_defskinselect($type = 'blog', $templateName = '')
2348 global $CONF, $manager;
2350 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2351 $query = sprintf($query, sql_table('skin_desc'));
2353 $blogid = intRequestVar('blogid');
2357 $template['selected'] = $CONF['BaseSkin'];
2361 $blog = $manager->getBlog($blogid);
2362 $template['selected'] = $blog->getDefaultSkin();
2365 if ( $type != 'blog' )
2367 $nname = 'BaseSkin';
2374 $template['name'] = $nname;
2375 $template['tabindex'] = 50;
2377 Showlist($query, 'select', $template, $templateName);
2383 * AdminActions::parse_deletecomment()
2384 * Parse skinvar deletecomment
2386 * @param string $type type of infomation for comment
2389 public function parse_deletecomment($type = 'id')
2391 $commentid = intRequestVar('commentid');
2392 $comment = COMMENT::getComment($commentid);
2397 echo intRequestVar('commentid');
2400 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2402 echo $comment['member'];
2406 echo $comment['user'];
2410 $body = strip_tags($comment['body']);
2411 echo Entity::hsc(shorten($body, 300, '...'));
2417 * AdminActions::parse_deleteitembody()
2418 * Parse skinvar deleteitembody
2423 public function parse_deleteitembody()
2427 $itemid = intRequestVar('itemid');
2428 $item =& $manager->getItem($itemid, 1, 1);
2430 $body = strip_tags($item['body']);
2432 echo Entity::hsc(shorten($body, 300, '...'));
2438 * AdminActions::parse_deleteitemid()
2439 * Parse skinvar deleteitemid
2444 public function parse_deleteitemid()
2446 echo (integer) intRequestVar('itemid');
2451 * AdminActions::parse_deleteitemtitle()
2452 * Parse skinvar deleteitemtitle
2457 public function parse_deleteitemtitle()
2461 $itemid = intRequestVar('itemid');
2462 $item =& $manager->getItem($itemid, 1, 1);
2464 echo Entity::hsc(strip_tags($item['title']));
2470 * AdminActions::parse_editadminskin()
2471 * Parse skinvar editadminskin
2473 * @param string $type type of skin setting
2476 public function parse_editadminskin($type = 'id')
2478 $skinid = intRequestVar('skinid');
2479 $skin = new Skin($skinid);
2483 echo intRequestVar('skinid');
2486 echo Entity::hsc($skin->getName());
2489 echo Entity::hsc($skin->getDescription());
2492 echo Entity::hsc($skin->getContentType());
2495 echo Entity::hsc($skin->getIncludePrefix());
2498 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2506 * AdminActions::parse_editadminskintype()
2507 * Parse skinvar editadminskintype
2509 * @param string $type name of skin type
2512 public function parse_editadminskintype($type = 'id')
2514 global $CONF, $manager, $member;
2516 $fNames = $this->parser->skin->getAvailableTypes();
2517 $sType = strtolower(trim(requestVar('type')));
2522 echo intRequestVar('skinid');
2525 echo Entity::hsc($this->parser->skin->getName());
2528 echo Entity::hsc($this->parser->skin->getDescription());
2531 echo Entity::hsc($this->parser->skin->getContentType());
2534 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2537 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2538 echo Entity::hsc($skinType);
2541 echo Entity::hsc($sType);
2544 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2547 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2548 echo Entity::hsc($incMode);
2557 * AdminActions::parse_editcomment()
2558 * Parse skinvar editcomment
2560 * @param string $type type of comment setting
2563 public function parse_editcomment($type = 'id')
2567 $commentid = intRequestVar('commentid');
2568 $comment = COMMENT::getComment($commentid);
2570 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2575 echo intRequestVar('commentid');
2578 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2580 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2584 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2588 echo date("Y-m-d @ H:i", $comment['timestamp']);
2591 $comment['body'] = str_replace('<br />', '', $comment['body']);
2592 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2593 echo $comment['body'];
2596 echo $comment['userid'];
2599 echo $comment['userid'];
2602 echo $comment[$type];
2609 * AdminActions::parse_editdesturl()
2610 * Parse skinvar editdesturl
2612 public function parse_editdesturl()
2614 if ( requestVar('desturl') )
2616 echo Entity::hsc(requestVar('desturl'));
2622 * AdminActions::parse_editmemberlist()
2623 * Parse skinvar editmemberlist
2625 * @param string $templateName name of template
2628 public function parse_editmemberlist($templateName = '')
2631 // show list of members with actions
2632 $query = 'SELECT * FROM '.sql_table('member');
2633 $template['content'] = 'memberlist';
2634 $template['tabindex'] = 10;
2636 $batch = new Batch('member');
2637 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2642 * AdminActions::parse_editmember()
2643 * Parse skinvar editmember
2645 * @param string $type type of information for member
2646 * @return string $tempateName name of template to use
2649 public function parse_editmember($type = 'id', $templateName = '')
2651 global $CONF, $manager, $member;
2653 $memberid = intRequestVar('memberid');
2654 $mem = MEMBER::createFromID($memberid);
2659 echo intRequestVar('memberid');
2662 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2664 echo Entity::hsc($mem->getDisplayName());
2668 $dispName = Entity::hsc($mem->getDisplayName());
2669 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2671 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2680 echo Entity::hsc($mem->getRealName());
2683 echo Entity::hsc($mem->getEmail());
2686 echo Entity::hsc($mem->getURL());
2689 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2692 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2695 echo Entity::hsc($mem->getNotes());
2698 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2707 * AdminActions::parse_editpluginfo()
2708 * Parse skinvar editpluginfo
2710 * @param string $type type of plugin info
2713 public function parse_editpluginfo($type)
2717 $pid = intRequestVar('plugid');
2724 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2731 * AdminActions::parse_editplugoptionslist()
2732 * Parse skinvar editplugoptionslist
2734 * @param string $templateName name of template
2737 public function parse_editplugoptionslist($templateName = '')
2741 $pid = intRequestVar('plugid');
2742 $aOptions = array();
2745 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2746 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2747 $resource = DB::getResult($query);
2749 foreach ( $resource as $row )
2751 array_push($aOIDs, $row['oid']);
2752 $aOptions[$row['oid']] = array(
2753 'oid' => $row['oid'],
2754 'value' => $row['odef'],
2755 'name' => $row['oname'],
2756 'description' => $row['odesc'],
2757 'type' => $row['otype'],
2758 'typeinfo' => $row['oextra'],
2763 // fill out actual values
2764 if ( count($aOIDs) > 0 )
2766 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2767 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2769 $result = DB::getResult($query);
2771 foreach ( $result as $row )
2773 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2779 'context' => 'global',
2781 'options' => &$aOptions
2783 $manager->notify('PrePluginOptionsEdit', $data);
2785 $template['content'] = 'plugoptionlist';
2787 $amount = Showlist($aOptions, 'table', $template, $templateName);
2791 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2797 * AdminActions::parse_editskin()
2798 * Parse skinvar editskin
2800 * @param string $type type of skin
2803 public function parse_editskin($type = 'id')
2805 $skinid = intRequestVar('skinid');
2806 $skin = new SKIN($skinid);
2810 echo intRequestVar('skinid');
2813 echo Entity::hsc($skin->getName());
2816 echo Entity::hsc($skin->getDescription());
2819 echo Entity::hsc($skin->getContentType());
2822 echo Entity::hsc($skin->getIncludePrefix());
2825 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2833 * AdminActions::parse_editskintype()
2834 * Parse skinvar editskintype
2836 * @param string $type name of type for skin type
2839 public function parse_editskintype($type = 'id')
2841 global $CONF, $manager, $member;
2842 $skinid = intRequestVar('skinid');
2843 $skin = new SKIN($skinid);
2844 $fNames = $skin->getAvailableTypes();
2845 $sType = strtolower(trim(requestVar('type')));
2850 echo intRequestVar('skinid');
2853 echo Entity::hsc($skin->getName());
2856 echo Entity::hsc($skin->getDescription());
2859 echo Entity::hsc($skin->getContentType());
2862 echo Entity::hsc($skin->getContentFromDB($sType));
2865 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2866 echo Entity::hsc($skinType);
2869 echo Entity::hsc($sType);
2872 echo Entity::hsc($skin->getIncludePrefix());
2875 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2876 echo Entity::hsc($incMode);
2885 * AdminActions::parse_adminurl()
2886 * Parse skinvar adminurl
2887 * (shortcut for admin url)
2892 public function parse_adminurl()
2894 $this->parse_sitevar('adminurl');
2899 * AdminActions::parse_edittemplateinfo()
2900 * Parse skinvar edittemplateinfo
2902 * @param string $type name of type for skin
2903 * @param string $description description for skin
2904 * @param string $name name of skin
2905 * @param string $help
2906 * @param string $tabindex index value for tabindex attribute of input element
2907 * @param string $big
2908 * @param string $tplt name of template
2911 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2915 $t_id = intRequestVar('templateid');
2916 $t_name = Template::getNameFromId($t_id);
2917 $t_desc = Template::getDesc($t_id);
2918 $template = &Template::read($t_name);
2926 echo Entity::hsc($t_name);
2929 echo Entity::hsc($t_desc);
2931 case 'extratemplate':
2933 $pluginfields = array();
2934 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2939 $tmplt = Template::read($desc);
2941 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2945 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2949 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2952 foreach ( $pluginfields as $pfkey => $pfvalue )
2954 $data = array('explugtplname' => Entity::hsc($pfkey));
2956 echo Template::fill($base, $data);
2958 foreach ( $pfvalue as $pffield => $pfdesc )
2960 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2965 $desc = defined($desc) ? constant($desc) : $desc;
2966 $name = defined($name) ? constant($name) : $name;
2967 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2975 * AdminActions::parse_editadmintemplateinfo()
2976 * Parse skinvar editadmintemplateinfo
2978 * @param string $type type of skin template
2979 * @param string $description description of template
2980 * @param string $name name of stemplate
2981 * @param string $tabindex index number for tabindex attribute of input element
2982 * @param string $big
2983 * @param string $tplt
2985 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2989 $t_id = intRequestVar('templateid');
2990 $t_name = Template::getNameFromId($t_id);
2991 $t_desc = Template::getDesc($t_id);
2992 $template = &Template::read($t_name);
3000 echo Entity::hsc($t_name);
3003 echo Entity::hsc($t_desc);
3005 case 'extratemplate':
3007 $pluginfields = array();
3008 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3013 $tmplt = Template::read($desc);
3015 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3019 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3023 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3026 foreach ( $pluginfields as $pfkey => $pfvalue )
3028 $data = array('explugtplname' => Entity::hsc($pfkey));
3030 echo Template::fill($base, $data);
3032 foreach ( $pfvalue as $pffield => $pfdesc )
3034 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3039 $desc = defined($desc) ? constant($desc) : $desc;
3040 $name = defined($name) ? constant($name) : $name;
3041 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3048 * AdminActions::parse_eventformextra()
3049 * Parse skinvar eventformextra
3051 * @param string $type name of type for event form extra
3054 public function parse_eventformextra($type = 'activation')
3063 $key = requestVar('ackey');
3066 Admin::error(_ERROR_ACTIVATE);
3068 $info = MEMBER::getActivationInfo($key);
3071 Admin::error(_ERROR_ACTIVATE);
3073 $mem = MEMBER::createFromId($info->vmember);
3076 Admin::error(_ERROR_ACTIVATE);
3079 'type' => 'activation',
3083 case 'membermailform-notloggedin':
3084 $data = array('type' => 'membermailform-notloggedin',);
3087 $manager->notify('FormExtra', $data);
3092 * AdminActions::parse_extrahead()
3093 * Parse skinvar extrahead
3095 public function parse_extrahead()
3099 $extrahead = Admin::getAdminextrahead();
3102 'extrahead' => &$extrahead,
3103 'action' => Admin::getAdminAction()
3106 $manager->notify('AdminPrePageHead', $data);
3112 * AdminActions::parse_member()
3113 * Parse skinvar member
3114 * (includes a member info thingie)
3116 * @param string $what which memberdata is needed
3119 public function parse_member($what)
3121 global $memberinfo, $member, $CONF;
3123 // 1. only allow the member-details-page specific variables on member pages
3124 if ( $this->skintype == 'member' )
3129 echo Entity::hsc($memberinfo->getDisplayName());
3132 echo Entity::hsc($memberinfo->getRealName());
3135 echo Entity::hsc($memberinfo->getNotes());
3138 echo Entity::hsc($memberinfo->getURL());
3141 echo Entity::hsc($memberinfo->getEmail());
3144 echo Entity::hsc($memberinfo->getID());
3149 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3150 if ( $member->isLoggedIn() )
3155 echo $member->getDisplayName();
3157 case 'yourrealname':
3158 echo $member->getRealName();
3161 echo $member->getNotes();
3164 echo $member->getURL();
3167 echo $member->getEmail();
3170 echo $member->getID();
3172 case 'yourprofileurl':
3173 if ( $CONF['URLMode'] == 'pathinfo' )
3175 echo Link::create_member_link($member->getID());
3179 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3188 * AdminActions::parse_version()
3189 * Parse skinvar version
3190 * (include nucleus versionnumber)
3195 public function parse_version()
3198 echo 'Nucleus CMS ' . $nucleus['version'];
3203 * AdminActions::parse_sitevar()
3204 * Parse skinvar sitevar
3205 * (include a sitevar)
3207 * @param string $which
3210 public function parse_sitevar($which)
3216 echo $CONF['IndexURL'];
3219 echo $CONF['SiteName'];
3222 echo $CONF['AdminEmail'];
3225 echo $CONF['AdminURL'];
3232 * AdminActions::parse_actionurl()
3238 public function parse_actionurl()
3241 echo Entity::hsc($CONF['ActionURL']);
3246 * AdminActions::parse_charset()
3247 * Parse skinvar charset
3252 public function parse_charset()
3254 echo i18n::get_current_charset();
3259 * AdminActions::parse_getblogsetting()
3260 * Parse skinvar getblogsetting
3262 public function parse_getblogsetting($which)
3264 global $blog, $manager;
3270 elseif ( $bid = intRequestVar('blogid') )
3272 $b = $manager->getBlog($bid);
3282 return Entity::hsc($b->getID());
3285 return Entity::hsc($b->getURL());
3288 return Entity::hsc($b->getName());
3291 return Entity::hsc($b->getDescription());
3294 return Entity::hsc($b->getShortName());
3296 case 'notifyaddress':
3297 return Entity::hsc($b->getNotifyAddress());
3300 return Entity::hsc($b->getMaxComments());
3303 return Entity::hsc($b->getUpdateFile());
3306 return Entity::hsc($b->getTimeOffset());
3313 * AdminActions::parse_geteditpluginfo()
3314 * Parse skinvar geteditpluginfo
3316 * @param string $type name of setting for edit plugin info
3319 public function parse_geteditpluginfo($type)
3322 $pid = intRequestVar('plugid');
3329 return Entity::hsc($manager->getPluginNameFromPid($pid));
3336 * AdminActions::parse_getmember()
3337 * Parse skinvar getmember
3338 * (includes a member info thingie)
3340 * @param string $what name of setting for member
3343 public function parse_getmember($what)
3345 global $memberinfo, $member;
3346 // 1. only allow the member-details-page specific variables on member pages
3347 if ( $this->skintype == 'member' )
3352 return Entity::hsc($memberinfo->getDisplayName());
3355 return Entity::hsc($memberinfo->getRealName());
3358 return Entity::hsc($memberinfo->getNotes());
3361 return Entity::hsc($memberinfo->getURL());
3364 return Entity::hsc($memberinfo->getEmail());
3367 return Entity::hsc($memberinfo->getID());
3371 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3372 if ( $member->isLoggedIn() )
3377 return $member->getDisplayName();
3379 case 'yourrealname':
3380 return $member->getRealName();
3383 return $member->getNotes();
3386 return $member->getURL();
3389 return $member->getEmail();
3392 return $member->getID();
3400 * AdminActions::parse_headmessage()
3401 * Parse skinvar headmessage
3406 public function parse_headmessage()
3408 if ( !empty(Admin::$headMess) )
3410 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3416 * AdminActions::parse_helplink()
3417 * Parse skinvar helplink
3419 * @param string $topic name of topic for help
3422 public function parse_helplink($topic = '')
3424 if ( !empty($topic) )
3432 * AdminActions::parse_helpplugname()
3433 * Parse skinvar helpplugname
3438 public function parse_helpplugname()
3440 $plugid = intGetVar('plugid');
3441 Entity::hsc($manager->getPluginNameFromPid($plugid));
3446 * AdminActions::parse_ilistaddnew()
3447 * Parse skinvar ilistaddnew
3452 public function parse_ilistaddnew()
3454 $blogid = intRequestVar('blogid');
3455 if ( intPostVar('start') == 0 )
3457 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3463 * AdminActions::parse_importskininfo()
3464 * Parse skinvar importskininfo
3466 * @param string $type name of information for imported skin
3469 public function parse_importskininfo($type)
3474 echo Entity::hsc(requestVar('skininfo'));
3477 $dataArr = requestArray('skinnames');
3478 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3481 $dataArr = requestArray('tpltnames');
3482 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3485 $dataArr = requestArray('skinclashes');
3486 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3489 $dataArr = requestArray('tpltclashes');
3490 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3493 echo Entity::hsc(requestVar('skinfile'));
3496 echo Entity::hsc(requestVar('mode'));
3503 * AdminActions::parse_inputyesno()
3504 * Parse skinvar inputyesno
3506 * some init stuff for all forms
3511 public function parse_init()
3516 if ( requestVar('action') == 'itemedit' )
3518 $authorid = Admin::$item['authorid'];
3521 Admin::$blog->insertJavaScriptInfo($authorid);
3526 * AdminActions::parse_inputyesno()
3527 * Parse skinvar inputyesno
3529 * @param string $name
3530 * @param string $checkedval
3531 * @param string $tabindex
3532 * @param string $value1
3533 * @param string $value2
3534 * @param string $yesval
3535 * @param string $noval
3536 * @param string $isAdmin
3537 * @param string $templateName
3540 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3542 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3547 * AdminActions::parse_insertpluginfo()
3548 * Parse templatevar insertpluginfo
3550 public function parse_insertpluginfo($type)
3552 $option = Admin::getAdminaOption();
3556 return $option['pid'];
3559 return Entity::hsc($option['pfile']);
3566 * AdminActions::parse_insplugoptcontent()
3567 * Parse skinvar insplugoptcontent
3572 public function parse_insplugoptcontent()
3574 $option = Admin::getAdminaOption();
3576 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3577 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3580 listplug_plugOptionRow($option);
3587 * AdminActions::parse_iprangeinput()
3588 * Parse skinvar iprangeinput
3593 public function parse_iprangeinput()
3595 if ( requestVar('ip') )
3597 $iprangeVal = Entity::hsc(requestVar('ip'));
3598 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3599 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3600 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3601 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3602 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3606 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3607 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3613 * AdminActions::parse_itemnavlist()
3614 * Parse skinvar itemnavlist
3619 public function parse_itemnavlist($templateName)
3621 global $CONF, $manager, $member;
3623 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3624 . " FROM %s, %s, %s, %s"
3625 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3627 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3629 if ( $this->skintype == 'itemlist' )
3632 if ( array_key_exists('blogid', $_REQUEST) )
3634 $blogid = intRequestVar('blogid');
3636 else if ( array_key_exists('itemid', $_REQUEST) )
3638 $itemid = intRequestVar('itemid');
3639 $item = &$manager->getItem($itemid, 1, 1);
3640 $blogid = (integer) $item['blogid'];
3642 $blog =& $manager->getBlog($blogid);
3644 $query .= " AND iblog={$blogid}";
3645 $template['now'] = $blog->getCorrectTime(time());
3647 // non-blog-admins can only edit/delete their own items
3648 if ( !$member->blogAdminRights($blogid) )
3650 $query .= ' AND iauthor = ' . $member->getID();
3653 elseif ( $this->skintype == 'browseownitems' )
3655 $query .= ' AND iauthor = ' . $member->getID();
3657 $template['now'] = time();
3660 // search through items
3661 $search = postVar('search');
3663 if ( !empty($search) )
3665 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3666 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3667 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3670 if ( postVar('start') )
3672 $start = intPostVar('start');
3679 // amount of items to show
3680 if ( postVar('amount') )
3682 $amount = intPostVar('amount');
3686 $amount = (integer) $CONF['DefaultListSize'];
3693 $query .= ' ORDER BY itime DESC'
3694 . " LIMIT {$start},{$amount}";
3696 $template['content'] = 'itemlist';
3698 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3699 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3704 * AdminActions::parse_itemtime()
3705 * date change on edit item
3707 * @param string $key key of PHP's getDate()
3710 public function parse_itemtime($key)
3715 $itemid = intRequestVar('itemid');
3716 $item =& $manager->getItem($itemid, 1, 1);
3718 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3720 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3722 $item['body'] = removeBreaks($item['body']);
3723 $item['more'] = removeBreaks($item['more']);
3726 $contents = array();
3727 if ( requestVar('action') == 'itemedit' )
3731 elseif ( requestVar('action') == 'createitem' )
3734 'contents' => &$contents,
3735 'blog' => &$this->blog
3737 $manager->notify('PreAddItemForm', $data);
3739 $itemtime = getdate($contents['timestamp']);
3740 echo $itemtime[$key];
3745 * AdminActions::parse_jstoolbaroptions()
3746 * Parse skinvar jstoolbaroptions
3751 public function parse_jstoolbaroptions()
3755 _SETTINGS_JSTOOLBAR_NONE,
3756 _SETTINGS_JSTOOLBAR_SIMPLE,
3757 _SETTINGS_JSTOOLBAR_FULL
3761 foreach ( $options as $option )
3763 $text = "<option value=\"%d\"%s>%s</option>\n";
3764 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3765 echo sprintf($text, $i, $extra, $option);
3771 * AdminActions::parse_localeselectoptions()
3772 * Parse skinvar localeselectoptions
3777 public function parse_localeselectoptions()
3779 $locales = i18n::get_available_locale_list();
3781 $memid = intRequestVar('memberid');
3784 $mem = MEMBER::createFromID($memid);
3785 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3787 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3791 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3796 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3798 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3802 echo "<option value=\"\">en_Latn_US</option>\n";
3805 foreach ( $locales as $locale )
3807 if ( $locale == 'en_Latn_US' )
3813 if ( $locale == $mem->getLocale() )
3815 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3819 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3824 if ( $locale == i18n::get_current_locale() )
3826 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3830 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3838 * AdminActions::parse_listplugplugoptionrow()
3839 * Parse templatevar listplugplugoptionrow
3841 * @param string $templateName name of template
3844 public function parse_listplugplugoptionrow($templateName = '')
3846 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3851 * AdminActions::parse_mediadirwarning()
3852 * Parse skinvar mediadirwarning
3857 public function parse_mediadirwarning()
3860 if ( !is_dir($DIR_MEDIA) )
3862 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3864 if ( !is_readable($DIR_MEDIA) )
3866 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3868 if ( !is_writeable($DIR_MEDIA) )
3870 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3876 * AdminActions::parse_movedistselect()
3877 * Parse skinvar movedistselect
3879 public function parse_movedistselect()
3881 $actionType = requestVar('action');
3882 switch ( $actionType )
3885 $this->selectBlog('destcatid', 'category');
3887 case 'batchcategory':
3888 $this->selectBlog('destblogid');
3891 if ( $this->skintype == 'itemmove' )
3893 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3894 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3895 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3896 $this->selectBlog('catid', 'category', $catid, 10, 1);
3904 * AdminActions::parse_moveitemid()
3905 * Parse skinvar moveitemid
3910 public function parse_moveitemid()
3912 echo intRequestVar('itemid');
3917 * AdminActions::parse_newestcompare()
3918 * Parse skinvar newestcompare
3923 public function parse_newestcompare()
3927 $newestVersion = getLatestVersion();
3928 $newestCompare = str_replace('/', '.', $newestVersion);
3929 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3931 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3933 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3934 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3940 * AdminActions::parse_newmemberselect()
3941 * Parse skinvar newmemberselect
3943 * @param string $templateName name of template to use
3946 public function parse_newmemberselect($templateName = '')
3948 $blogid = intRequestVar('blogid');
3950 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3951 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3952 $res = DB::getResult($query);
3955 foreach ( $res as $row )
3957 $tmem[] = intval($row['tmember']);
3960 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3961 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3964 'name' => 'memberid',
3965 'tabindex' => 10000,
3968 Showlist($query, 'select', $template, $templateName);
3973 * AdminActions::parse_newpluginlist()
3974 * Parse skinvar newpluginlist
3979 public function parse_newpluginlist()
3981 $candidates = $this->newPlugCandidates;
3982 foreach ( $candidates as $name )
3984 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3990 * AdminActions::parse_outputspecialdirs()
3991 * Parse skinvar outputspecialdirs
3993 * @param string $type type of setting for directory
3996 public function parse_outputspecialdirs($type)
3998 global $DIR_MEDIA, $DIR_NUCLEUS;
4003 echo Entity::hsc($DIR_NUCLEUS);
4006 echo Entity::hsc($DIR_MEDIA);
4013 * AdminActions::parse_passrequestvars()
4014 * Parse skinvar passrequestvars
4019 public function parse_passrequestvars()
4021 $passvar = Admin::getAdminpassvar();
4022 $oldaction = postVar('oldaction');
4024 if ( ($oldaction != 'logout')
4025 && ($oldaction != 'login')
4027 && !postVar('customaction') )
4035 * AdminActions::parse_pluginextras()
4036 * Parse skinvar pluginextras
4038 * @param string $type type of plugin context
4041 public function parse_pluginextras($type = 'global')
4047 $id = intRequestVar('memberid');
4048 $mem = MEMBER::createFromID($id);
4049 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4052 $id = intRequestVar('blogid');
4053 $blg = $manager->getBlog($id);
4054 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4056 case 'createaccount':
4058 'type' => 'createaccount.php',
4060 'postlabel' => '<br />',
4062 'postfield' => '<br /><br />'
4064 $manager->notify('RegistrationFormExtraFields', $data);
4067 $manager->notify('GeneralSettingsFormExtras', array());
4074 * AdminActions::parse_pluginhelp()
4075 * Parse skinvar pluginhelp
4080 public function parse_pluginhelp()
4082 global $manager, $DIR_PLUGINS;
4084 $plugid = intGetVar('plugid');
4085 $plugName = $manager->getPluginNameFromPid($plugid);
4086 $plug =& $manager->getPlugin($plugName);
4088 if ( $plug->supportsFeature('HelpPage') > 0 )
4090 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4091 if ( @file_exists($helpfile . 'php') )
4093 @include($helpfile . 'php');
4096 elseif ( @file_exists($helpfile . 'html') )
4098 @include($helpfile . 'html');
4102 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4103 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4108 * AdminActions::parse_pluginlistlist()
4109 * Parse skinvar pluginlistlist
4111 * @param string $templateName name of template to use
4114 public function parse_pluginlistlist($templateName = '')
4116 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4117 $query = sprintf($query, sql_table('plugin'));
4119 $template['content'] = 'pluginlist';
4120 $template['tabindex'] = 10;
4122 Showlist($query, 'table', $template, $templateName);
4128 * AdminActions::parse_pluginoptions()
4129 * Parse skinvar pluginoptions
4131 * @param string $type type of plugin option
4134 public function parse_pluginoptions($context='global', $templateName='')
4136 global $itemid, $manager;
4141 $contextid = intRequestVar('memberid');
4144 $contextid = intRequestVar('blogid');
4147 $contextid = intRequestVar('catid');
4150 $contextid = $itemid;
4154 /* Actually registererd plugin options */
4155 $aIdToValue = array();
4156 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4157 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4158 $res = DB::getResult($query);
4159 foreach ( $res as $row )
4161 $aIdToValue[$row['oid']] = $row['ovalue'];
4164 /* Currently available plugin options */
4165 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4166 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4167 $res = DB::getResult($query);
4170 foreach ($res as $row )
4172 if ( !array_key_exists($row['oid'], $aIdToValue) )
4174 $value = $row['odef'];
4178 $value = $aIdToValue[$row['oid']];
4182 'pid' => $row['pid'],
4183 'pfile' => $row['pfile'],
4184 'oid' => $row['oid'],
4186 'name' => $row['oname'],
4187 'description' => $row['odesc'],
4188 'type' => $row['otype'],
4189 'typeinfo' => $row['oextra'],
4190 'contextid' => $contextid,
4196 'context' => $context,
4197 'contextid' => $contextid,
4198 'options' => &$options
4200 $manager->notify('PrePluginOptionsEdit', $data);
4202 $template = array();
4203 if ( $templateName )
4205 $templates = Template::read($templateName);
4206 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4208 $template['title'] = "<tr>"
4209 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4214 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4217 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4219 $template['body'] = "<tr>"
4220 . "<%listplugplugoptionrow%>"
4225 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4231 include_libs('ACTIONS.php');
4232 $handler = new Actions($this->skintype);
4233 $parser = new PARSER($handler);
4235 foreach ( $options as $option )
4238 if ( $prevPid != $option['pid'] )
4240 $prevPid = $option['pid'];
4241 $parser->parse($template['title']);
4244 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4246 if ( @$meta['access'] != 'hidden' )
4248 $parsed = $parser->parse($template['body']);
4256 * AdminActions::parse_qmenuaddselect()
4257 * Parse skinvar qmanuaddselect
4259 * @param string $templateName name of template to use
4262 public function parse_qmenuaddselect($templateName = '')
4265 $showAll = requestVar('showall');
4266 if ( $member->isAdmin() && ($showAll == 'yes') )
4268 // Super-Admins have access to all blogs! (no add item support though)
4269 $query = 'SELECT bnumber as value, bname as text'
4270 . ' FROM ' . sql_table('blog')
4271 . ' ORDER BY bname';
4275 $query = 'SELECT bnumber as value, bname as text'
4276 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4277 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4278 . ' ORDER BY bname';
4281 $template['name'] = 'blogid';
4282 $template['tabindex'] = 15000;
4283 $template['extra'] = _QMENU_ADD_SELECT;
4284 $template['selected'] = -1;
4285 $template['shorten'] = 10;
4286 $template['shortenel'] = '';
4287 $template['javascript'] = 'onchange="return form.submit()"';
4289 Showlist($query, 'select', $template, $templateName);
4295 * AdminActions::parse_quickmenu()
4296 * Parse skinvar quickmenu
4298 * @param string $templateName name of template to use
4301 public function parse_quickmenu($templateName = '')
4304 $templates = array();
4305 $template = array();
4306 if ( !empty($templateName) )
4308 $templates = Template::read($templateName);
4310 $pluginExtras = array();
4314 'options' => &$pluginExtras
4317 if ( count($pluginExtras) > 0 )
4319 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4321 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4325 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4327 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4329 $template['head'] = "<ul>\n";
4333 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4335 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4337 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4341 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4343 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4345 $template['foot'] = "</ul>\n";
4349 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4352 $handler = new Actions($this->skintype);
4353 $parser = new PARSER($handler);
4355 $parser->parse($template['title']);
4356 echo $template['head'];
4357 foreach ( $pluginExtras as $aInfo )
4360 'plugadminurl' => Entity::hsc($aInfo['url']),
4361 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4362 'plugadmintitle' => Entity::hsc($aInfo['title']),
4364 echo Template::fill($template['body'], $data);
4366 echo $template['foot'];
4372 * AdminActions::parse_requestblogid()
4373 * Parse skinvar requestblogid
4378 public function parse_requestblogid()
4380 echo intRequestVar('blogid');
4385 * AdminActions::parse_requestiprange()
4386 * Parse skinvar requestiprange
4391 public function parse_requestiprange()
4393 if ( requestVar('iprange') )
4395 echo Entity::hsc(requestVar('iprange'));
4397 elseif ( requestVar('ip') )
4399 echo Entity::hsc(requestVar('ip'));
4405 * AdminActions::parse_selectlocaladminskinfiles()
4406 * Parse skinvar selectlocaladminskinfiles
4411 public function parse_selectlocaladminskinfiles()
4413 global $DIR_SKINS, $manager;
4415 $adminskindir = $DIR_SKINS . 'admin/';
4416 $candidates = SkinImport::searchForCandidates($adminskindir);
4418 foreach ( $candidates as $skinname => $skinfile )
4420 $html = Entity::hsc($skinfile);
4421 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4428 * AdminActions::parse_selectlocalskinfiles()
4429 * Parse skinvar selectlocalskinfiles
4434 public function parse_selectlocalskinfiles()
4438 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4440 foreach ( $candidates as $skinname => $skinfile )
4442 $html = Entity::hsc($skinfile);
4443 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4450 * AdminActions::parse_skineditallowedlist()
4451 * Parse skinvar skineditallowedlist
4453 * @param string $type type of skin
4454 * @param string $templateName name of template
4457 public function parse_skineditallowedlist($type, $templateName = '')
4462 $query = "SELECT bshortname, bname FROM %s;";
4464 'content' => 'shortblognames'
4466 $query = sprintf($query, sql_table('blog'));
4467 Showlist($query, 'table', $show, $templateName);
4470 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4472 'content' => 'shortnames'
4474 $query = sprintf($query, sql_table('template_desc'));
4475 Showlist($query, 'table', $show, $templateName);
4482 * AdminActions::parse_skinielist()
4483 * Parse skinvar skinielist
4485 * @param string $type type of skin
4486 * @param string $templateName name of template to use
4489 public function parse_skinielist($type, $templateName = '')
4491 $templates = array();
4492 if ( $templateName )
4494 $templates = Template::read($templateName);
4496 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4498 $template = $templates['SKINIE_EXPORT_LIST'];
4503 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4504 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4506 . "<td><%expdesc%></td>\n"
4513 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4514 foreach ( $res as $row )
4517 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4518 'expid' => 'skinexp' . $row['sdnumber'],
4519 'expname' => Entity::hsc($row['sdname']),
4520 'expdesc' => Entity::hsc($row['sddesc'])
4522 echo Template::fill($template, $data);
4526 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4527 foreach ( $res as $row )
4530 'typeid' => 'template[' . $row['tdnumber'] . ']',
4531 'expid' => 'templateexp' . $row['tdnumber'],
4532 'expname' => Entity::hsc($row['tdname']),
4533 'expdesc' => Entity::hsc($row['tddesc'])
4535 echo Template::fill($template, $data);
4543 * AdminActions::parse_skinoverview()
4544 * Parse skinvar skinoverview
4546 * @param string $templateName name of template to use
4549 public function parse_skinoverview($templateName = '')
4552 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4553 $query = sprintf($query, sql_table('skin_desc'));
4555 $template['content'] = 'skinlist';
4556 $template['tabindex'] = 10;
4558 Showlist($query, 'table', $template, $templateName);
4563 * AdminActions::parse_skintypehelp()
4564 * Check editing skintypehelp
4569 public function parse_skintypehelp()
4571 $nowSkinType = strtolower(trim(requestVar('type')));
4573 /* TODO: use Skin class */
4574 $regularType = array(
4585 if ( in_array($nowSkinType, $regularType) )
4587 help('skinpart' . $nowSkinType);
4591 help('skinpartspecial');
4597 * AdminActions::parse_specialskinlist()
4598 * Parse skinvar specialskinlist
4600 * @param string $templateName name of template to use
4603 public function parse_specialskinlist($templateName = '')
4605 $templates = array();
4606 if ( $templateName )
4608 $templates = Template::read($templateName);
4611 /* TODO: use Skin class */
4622 $skinid = intRequestVar('skinid');
4623 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4624 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4626 $res = DB::getResult($query);
4627 if ( $res && $res->rowCount() > 0 )
4630 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4632 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4636 $template['head'] = "<ul>\n";
4638 echo Template::fill($template['head'], $data);
4639 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4641 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4642 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4643 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4647 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4651 foreach ( $res as $row )
4654 'tabindex' => $tabstart++,
4655 'skinid' => $skinid,
4656 'skintype' => Entity::hsc(strtolower($row['stype']))
4658 echo Template::fill($template['body'], $data);
4661 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4663 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4667 $template['foot'] = "</ul>\n";
4669 echo Template::fill($template['foot'], $data);
4675 * AdminActions::parse_sprinttext()
4678 * @param string $which
4679 * @param string $val
4682 public function parse_sprinttext($which, $val)
4684 if ( !defined($which) )
4690 $base = constant($which);
4693 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4695 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4697 $met = 'parse_' . $matchies[0];
4701 $arg = trim($args[0], '()');
4702 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4705 if ( method_exists($this, $met) )
4707 $value = call_user_func(array(&$this, $met), $arg);
4711 if ( !isset($value) || empty($value) )
4715 echo sprintf($base, $value);
4720 * AdminActions::parse_systemsettings()
4721 * Parse skinvar systemsettings
4723 * @param string $type type of settings for system
4724 * @param string $templateName name of template to use
4727 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4729 global $member, $CONF, $nucleus;
4731 $member->isAdmin() or Admin::disallow();
4733 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4734 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4741 case 'sqlserverinfo':
4742 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4744 case 'sqlclientinfo':
4745 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4747 case 'magicquotesgpc':
4748 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4750 case 'magicquotesruntime':
4751 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4753 case 'registerglobals':
4754 echo ini_get('register_globals') ? 'On' : 'Off';
4757 $templates = array();
4758 if ( $templateName )
4760 $templates = Template::read($templateName);
4762 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4764 $template = "<tr>\n"
4765 . "<td><%key%></td>\n"
4766 . "<td><%value%></td>\n"
4771 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4774 $gdinfo = gd_info();
4776 foreach ( $gdinfo as $key => $value )
4778 if ( is_bool($value) )
4780 $value = $value ? $enable : $disable;
4784 $value = Entity::hsc($value);
4790 echo Template::fill($template, $data);
4795 phpinfo(INFO_MODULES);
4796 $im = ob_get_contents();
4798 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4800 case 'nucleusversion':
4801 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4803 case 'nucleuspatchlevel':
4804 echo getNucleusPatchLevel();
4810 echo $CONF['ItemURL'];
4812 case 'alertonheaderssent':
4813 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4815 case 'nucleuscodename':
4816 if ( $nucleus['codename'] != '' )
4818 echo ' "' . $nucleus['codename'] . '"';
4821 case 'versioncheckurl':
4822 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4829 * AdminActions::parse_templateoverview()
4830 * Parse skinvar templateoverview
4832 * @param string $templateName name of template to use
4835 public function parse_templateoverview($templateName = '')
4837 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4838 $query = sprintf($query, sql_table('template_desc'));
4840 $template['content'] = 'templatelist';
4841 $template['tabindex'] = 10;
4843 Showlist($query, 'table', $template, $templateName);
4849 * AdminActions::parse_ticket()
4855 public function parse_ticket()
4858 $manager->addTicketHidden();
4863 * AdminActions::parse_versioncheckurl()
4864 * Parse skinvar versioncheckurl
4869 public function parse_versioncheckurl()
4871 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4876 * AdminActions::parse_yrbloglist()
4877 * Parse skinvar yrbloglist
4879 * @param string $templateName name of template to use
4882 public function parse_yrbloglist($templateName = '')
4885 $showAll = requestVar('showall');
4887 if ( $member->isAdmin() && ($showAll == 'yes') )
4889 // Super-Admins have access to all blogs! (no add item support though)
4890 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4892 . " ORDER BY bnumber;";
4893 $query = sprintf($query, sql_table('blog'));
4897 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4899 . " WHERE tblog=bnumber and tmember=%d"
4900 . " ORDER BY bnumber;";
4901 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4904 $template['content'] = 'bloglist';
4905 $template['superadmin'] = $member->isAdmin();
4907 $amount = Showlist($query, 'table', $template, $templateName);
4909 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4911 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4913 $total = DB::getValue($query);
4914 if ( $total > $amount )
4916 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4922 echo _OVERVIEW_NOBLOGS;
4924 elseif( $amount != 0 )
4926 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4928 $query = "SELECT ititle, inumber, bshortname"
4930 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4931 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4933 $template['content'] = 'draftlist';
4935 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4936 if ( $amountdrafts == 0 )
4938 echo _OVERVIEW_NODRAFTS;
4945 * AdminActions::checkCondition()
4946 * Checks conditions for if statements
4948 * @param string $field type of <%if%>
4949 * @param string $name property of field
4950 * @param string $value value of property
4951 * @return boolean condition
4953 protected function checkCondition($field, $name='', $value = '')
4955 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4965 $blog =& $manager->getBlog($blogid);
4969 $blogid = getBlogIDFromCatID($catid);
4970 $blog =& $manager->getBlog($blogid);
4972 elseif ( intRequestVar('catid') )
4974 $catid = intRequestVar('catid');
4975 $blogid = getBlogIDFromCatID($catid);
4976 $blog =& $manager->getBlog($blogid);
4983 $condition = ($blog && $this->ifCategory($name, $value));
4986 $condition = $member->isLoggedIn();
4989 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4992 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4995 $condition = $member->isLoggedIn() && $member->isAdmin();
4997 case 'allowloginedit':
4998 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5001 $condition = ($itemidnext != '');
5004 $condition = ($itemidprev != '');
5006 case 'archiveprevexists':
5007 $condition = ($archiveprevexists == true);
5009 case 'archivenextexists':
5010 $condition = ($archivenextexists == true);
5013 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5016 $condition = $this->ifHasPlugin($name, $value);
5019 $condition = (Admin::getAdminAction() == $name);
5021 case 'adminoldaction':
5022 $condition = (Admin::getAdminAction() == $name);
5024 case 'addresschange':
5025 $condition = ($this->ifAddresscange());
5027 case 'bechangepass':
5028 $condition = ($this->beChangePassword());
5030 case 'skincandidates':
5031 $condition = ($this->ifSkincandidates());
5034 $condition = requestVar('nameclashes');
5036 case 'existsnewplugin':
5037 $condition = ($this->existsNewPlugin());
5044 $condition = (boolean) ($member->getAutosave() == $value);
5051 $condition = (Admin::$blog->getSetting($name) == $value);
5053 case 'itemproperty':
5058 if ( array_key_exists($name, Admin::$item) )
5060 $condition = (boolean) (Admin::$item[$name] == $value);
5064 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5071 * AdminActions::_ifHasPlugin()
5072 * hasplugin,PlugName
5073 * -> checks if plugin exists
5074 * hasplugin,PlugName,OptionName
5075 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5076 * hasplugin,PlugName,OptionName=value
5077 * -> checks if the option OptionName from plugin PlugName is set to value
5079 * @param string $name name of plugin
5080 * @param string $value
5083 private function ifHasPlugin($name, $value)
5087 // (pluginInstalled method won't write a message in the actionlog on failure)
5088 if ( $manager->pluginInstalled("NP_{$name}") )
5090 $plugin =& $manager->getPlugin("NP_{$name}");
5091 if ( $plugin != NULL )
5099 list($name2, $value2) = preg_split('#=#', $value, 2);
5100 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5104 else if ( $plugin->getOption($name2) == $value2 )
5115 * AdminActions::beChangePassword()
5120 private function beChangePassword()
5122 return intRequestVar('bNeedsPasswordChange');
5126 * AdminActions::ifSkincandidates()
5127 * Checks if a plugin exists and call its doIf function
5133 private function ifSkincandidates()
5136 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5137 return (count($candidates) > 0);
5141 * AdminActions::ifPlugin()
5142 * Checks if a plugin exists and call its doIf function
5144 * @param string $name name of plugin
5145 * @param string $key
5146 * @param string $value
5149 private function ifPlugin($name, $key = '', $value = '')
5153 $plugin =& $manager->getPlugin("NP_{$name}");
5159 $params = func_get_args();
5160 array_shift($params);
5162 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5166 * AdminActions::ifCategory()
5167 * Different checks for a category
5169 * @param string $key key for information of category
5170 * @param string $value value for information of category
5173 private function ifCategory($key = '', $value='')
5175 global $blog, $catid;
5177 // when no parameter is defined, just check if a category is selected
5178 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5180 return $blog->isValidCategory($catid);
5183 // check category name
5184 if ( $key == 'catname' )
5186 $value = $blog->getCategoryIdFromName($value);
5187 if ($value == $catid)
5189 return $blog->isValidCategory($catid);
5193 // check category id
5194 if (($key == 'catid') && ($value == $catid))
5196 return $blog->isValidCategory($catid);
5203 * AdminActions::ifOnTeam()
5204 * Checks if a member is on the team of a blog and return his rights
5206 * @param string $blogName name of weblog
5209 private function ifOnTeam($blogName = '')
5211 global $blog, $member, $manager;
5213 // when no blog found
5214 if ( ($blogName == '') && !is_object($blog) )
5219 // explicit blog selection
5220 if ($blogName != '')
5222 $blogid = getBlogIDFromName($blogName);
5225 if (($blogName == '') || !$manager->existsBlogID($blogid))
5228 $blogid = $blog->getID();
5230 return $member->teamRights($blogid);
5234 * AdminActions::ifAdmin()
5235 * Checks if a member is admin of a blog
5237 * @param string $blogName name of weblog
5240 private function ifAdmin($blogName = '')
5242 global $blog, $member, $manager;
5244 // when no blog found
5245 if (($blogName == '') && (!is_object($blog)))
5250 // explicit blog selection
5251 if ($blogName != '')
5253 $blogid = getBlogIDFromName($blogName);
5256 if (($blogName == '') || !$manager->existsBlogID($blogid))
5259 $blogid = $blog->getID();
5262 return $member->isBlogAdmin($blogid);
5266 * AdminActions::ifAddresscange()
5267 * Check e-Mail address is changed
5272 private function ifAddresscange()
5274 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5279 $info = MEMBER::getActivationInfo($key);
5284 $mem = MEMBER::createFromId($info->vmember);
5289 if ( $info->vtype == 'addresschange' )
5297 * AdminActions::templateEditRow()
5300 * @param array $template
5301 * @param string $desc
5302 * @param string $name
5303 * @param string $help
5304 * @param integer $tabindex
5305 * @param boolean $big
5306 * @param array $tmplt
5309 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5313 if ( !array_key_exists($name, $template) )
5315 $template[$name] = '';
5323 $tmplt = skinableTEMPLATE::read($tplt);
5327 'description' => $desc,
5328 'help' => empty($help) ? '' : helpHtml('template' . $help),
5331 'tabindex' => $tabindex,
5332 'rows' => $big ? 10 : 5,
5335 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5337 $base['head'] = "</tr>"
5339 . "<td><%description%><%help%></td>\n"
5340 . "<td id=\"td<%count%>\">\n"
5341 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5345 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5348 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5350 $base['tail'] = "</textarea>\n"
5355 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5358 echo TEMPLATE::fill($base['head'], $data);
5359 echo ENTITY::hsc($template[$name]);
5360 echo TEMPLATE::fill($base['tail'], $data);
5368 * AdminActions::customHelp()
5369 * shows a link to custom help file
5372 * @param string $tplName
5373 * @param string $url
5374 * @param string $iconURL
5375 * @param string $alt
5376 * @param string $title
5380 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5382 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5386 * AdminActions::customHelp()
5387 * shows a link to custom help file
5390 * @param string $tplName
5391 * @param string $url
5392 * @param string $iconURL
5393 * @param string $alt
5394 * @param string $title
5398 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5402 $templates = array();
5406 $templates = Template::read($tplName);
5409 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5411 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5415 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5420 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5423 if ( empty($onclick) )
5425 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5427 elseif ( preg_match('#^onclick#', $onclick) )
5429 $onclick = $onclick;
5433 $onclick = 'onclick="' . $onclick . '"';
5438 'helptarget' => $id,
5439 'onclick' => $onclick,
5440 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5442 return Template::fill($template, $data);
5446 * AdminActions::customHelpHtml()
5449 * @param string $tplName
5450 * @param string $url
5451 * @param string $iconURL
5452 * @param string $alt
5453 * @param string $title
5454 * @param string $onclick
5455 * @return string anchor element with help uri
5457 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5461 $templates = array();
5465 $templates = Template::read($tplName);
5467 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5469 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5473 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5476 if ( empty($iconURL) )
5478 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5481 if ( function_exists('getimagesize') )
5483 $size = getimagesize($iconURL);
5484 $width = 'width="' . $size[0] . '" ';
5485 $height = 'height="' . $size[1] . '" ';
5489 'iconurl' => $iconURL,
5491 'height' => $height,
5492 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5493 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5496 $icon = Template::fill($template, $data);
5497 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5499 return $help . $icon;
5503 * AdminActions::input_yesno
5506 * @param $checkedval
5513 * @param $templateName
5516 public function input_yesno($name,
5527 $templates = array();
5528 if ( $templateName )
5530 $templates = Template::read($templateName);
5533 if ( $name == 'admin' )
5535 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5537 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5538 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5539 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5540 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5544 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5549 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5551 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5555 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5557 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5560 if ( !isset($template) )
5562 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5563 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5564 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5565 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5570 $id = Entity::hsc($name);
5571 $id = str_replace('[', '-', $id);
5572 $id = str_replace(']', '-', $id);
5573 $id1 = $id . Entity::hsc($value1);
5574 $id2 = $id . Entity::hsc($value2);
5576 'name' => Entity::hsc($name),
5577 'yesval' => Entity::hsc($value1),
5578 'noval' => Entity::hsc($value2),
5581 'yesvaltext' => $yesval,
5582 'novaltext' => $noval,
5583 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5584 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5585 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5590 return Template::fill($template, $dat);
5594 echo Template::fill($template, $dat);
5600 * AdminActions::existsNewPlugin()
5601 * Check exists new plugin
5604 * @return boolean exists or not
5606 private function existsNewPlugin()
5608 global $DIR_PLUGINS;
5610 $query = "SELECT * FROM %s;";
5611 $query = sprintf($query, sql_table('plugin'));
5612 $res = DB::getResult($query);
5614 $installed = array();
5615 foreach( $res as $row )
5617 $installed[] = $row['pfile'];
5620 $files = scandir($DIR_PLUGINS);
5622 $candidates = array();
5623 foreach ( $files as $file )
5625 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5627 if ( !in_array($matches[1], $installed) )
5629 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5633 $this->newPlugCandidates = $candidates;
5634 return (count($candidates) > 0);
5638 * AdminActions::pagehead()
5639 * Output admin page head
5644 public function parse_pagehead()
5646 global $member, $nucleus, $CONF, $manager;
5648 $extrahead = Admin::getAdminextrahead();
5650 'extrahead' => &$extrahead,
5651 'action' => Admin::getAdminAction()
5653 $manager->notify('AdminPrePageHead', $data);
5655 $content = $this->parser->skin->getContentFromDB('pagehead');
5658 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5662 if ( !array_key_exists('AdminCSS', $CONF) )
5664 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5665 $CONF['AdminCSS'] = 'original';
5669 /* HTTP 1.1 application for no caching */
5670 header("Cache-Control: no-cache, must-revalidate");
5671 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5673 $root_element = 'html';
5674 $charset = i18n::get_current_charset();
5675 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5676 $xml_version_info = self::$xml_version_info;
5677 $formal_public_identifier = self::$formal_public_identifier;
5678 $system_identifier = self::$system_identifier;
5679 $xhtml_namespace = self::$xhtml_namespace;
5681 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5682 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5683 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5685 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5688 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5690 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5691 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5692 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5693 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5694 echo "{$extrahead}\n";
5697 echo "<div id=\"adminwrapper\">\n";
5698 echo "<div class=\"header\">\n";
5699 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5701 echo "<div id=\"container\">\n";
5702 echo "<div id=\"content\">\n";
5703 echo "<div class=\"loginname\">\n";
5705 if ( !$member->isLoggedIn() )
5707 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5711 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5712 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5715 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5718 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5720 $codenamestring = '';
5724 $codenamestring = ' "' . $nucleus['codename'].'"';
5727 if ( $member->isLoggedIn() && $member->isAdmin() )
5729 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5730 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5732 $newestVersion = getLatestVersion();
5733 $newestCompare = str_replace('/', '.', $newestVersion);
5734 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5736 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5739 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5740 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5746 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5753 $this->parser->parse($content);
5760 * AdminActionss::pagefoot()
5761 * Output admin page foot include quickmenu
5766 public function parse_pagefoot()
5768 global $action, $member, $manager;
5771 'action' => Admin::getAdminAction()
5773 $manager->notify('AdminPrePageFoot', $data);
5775 $content = $this->parser->skin->getContentFromDB('pagefoot');
5778 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5780 echo '<h2>' . _LOGOUT . "</h2>\n";
5782 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5783 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5787 echo "<div class=\"foot\">\n";
5788 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5790 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5793 echo "<div id=\"quickmenu\">\n";
5795 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5798 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5801 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5802 echo "<form method=\"get\" action=\"index.php\">\n";
5804 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5806 $showAll = requestVar('showall');
5808 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5810 // Super-Admins have access to all blogs! (no add item support though)
5811 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5812 $query = sprintf($query, sql_table('blog'));
5816 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5817 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5819 $template['name'] = 'blogid';
5820 $template['tabindex'] = 15000;
5821 $template['extra'] = _QMENU_ADD_SELECT;
5822 $template['selected'] = -1;
5823 $template['shorten'] = 10;
5824 $template['shortenel'] = '';
5825 $template['javascript'] = 'onchange="return form.submit()"';
5826 showlist($query, 'select', $template);
5831 echo "<h2>{$member->getDisplayName()}</h2>\n";
5833 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5834 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5835 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5838 if ( $member->isAdmin() )
5840 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5842 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5843 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5844 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5845 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5846 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5847 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5848 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5851 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5853 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5854 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5855 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5859 $data = array('options' => array());
5861 $manager->notify('QuickMenu', $data);
5863 if ( count($data['options']) > 0 )
5865 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5867 foreach ( $data['options'] as $option )
5869 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5874 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5877 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5881 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5884 echo "<!-- quickmenu -->\n";
5887 echo "<!-- content -->\n";
5890 echo "<!-- container -->\n";
5893 echo "<!-- adminwrapper -->\n";
5901 $this->parser->skin->parse('pagefoot');
5908 * AdminActions::selectBlog()
5909 * Inserts a HTML select element with choices for all blogs to which the user has access
5910 * mode = 'blog' => shows blognames and values are blogids
5911 * mode = 'category' => show category names and values are catids
5913 * @param string $name
5914 * @param string $mode
5915 * @param integer $selected
5916 * @param integer $tabindex
5917 * @param integer $showNewCat
5918 * @param integer $iForcedBlogInclude ID for weblog always included
5919 * @param $iForcedBlogInclude
5920 * ID of a blog that always needs to be included, without checking if the
5921 * member is on the blog team (-1 = none)
5924 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5926 global $member, $CONF;
5928 // 0. get IDs of blogs to which member can post items (+ forced blog)
5929 $aBlogIds = array();
5930 if ( $iForcedBlogInclude != -1 )
5932 $aBlogIds[] = intval($iForcedBlogInclude);
5935 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5937 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5938 $query = sprintf($query, sql_table('blog'));
5942 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5943 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5946 $rblogids = DB::getResult($query);
5947 foreach ( $rblogids as $row )
5949 if ( $row['bnumber'] != $iForcedBlogInclude )
5951 $aBlogIds[] = intval($row['bnumber']);
5955 if ( count($aBlogIds) == 0 )
5960 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5962 // 1. select blogs (we'll create optiongroups)
5963 // (only select those blogs that have the user on the team)
5964 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5965 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5966 $blogs = DB::getResult($queryBlogs);
5968 if ( $mode == 'category' )
5970 if ( $blogs->rowCount() > 1 )
5974 foreach ( $blogs as $rBlog )
5976 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5978 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5981 // show selection to create new category when allowed/wanted
5984 // check if allowed to do so
5985 if ( $member->blogAdminRights($rBlog['bnumber']) )
5987 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5991 // 2. for each category in that blog
5992 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5993 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5994 $categories = DB::getResult($catQuery);
5995 foreach ( $categories as $rCat )
5997 if ( $rCat['catid'] == $selected )
5999 $selectText = ' selected="selected" ';
6005 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
6008 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6016 foreach ( $blogs as $rBlog )
6018 echo '<option value="' . $rBlog['bnumber'] . '"';
6019 if ( $rBlog['bnumber'] == $selected )
6021 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
6025 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";