2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
12 /* NOTE: list of whole available action names for tags
21 'adminskineditallowedlist',
24 'adminskinselectoptions',
25 'adminspecialskinlist',
26 'admintemplateoverview',
27 'allowedadminskinactions',
49 'configsettingsyesno',
51 'createaccountsuccess',
52 'createaccountdisable',
55 'defaultadminskintypes',
65 'editadmintemplateinfo',
71 'editplugoptionslist',
91 'listplugplugoptionrow',
92 'localeselectoptions',
109 'selectlocaladminskinfiles',
110 'selectlocalskinfiles',
111 'skineditallowedlist',
128 * AdminActions::$default_actions
129 * list of whole action names with which this class can deal
131 static private $default_actions = array(
154 * AdminActions::$skin_type_friendly_names
155 * friendly name for wrapped page types
157 static private $default_skin_types = array(
158 'actionlog' => _ADM_SKPRT_ACTIONLOG,
159 'activate' => _ADM_SKPRT_ACTIVATE,
160 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
161 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
162 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
163 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
164 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
165 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
166 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
167 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
168 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
169 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
170 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
171 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
172 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
173 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
174 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
175 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
176 'banlist' => _ADM_SKPRT_BANLIST,
177 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
178 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
179 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
180 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
181 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
182 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
183 'batchitem' => _ADM_SKPRT_BATCHITEM,
184 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
185 'batchmove' => _ADM_SKPRT_BATCHMOVE,
186 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
187 'batchteam' => _ADM_SKPRT_BATCHTEAM,
188 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
189 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
190 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
191 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
192 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
193 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
194 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
195 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
196 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
197 'createitem' => _ADM_SKPRT_CREATEITEM,
198 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
199 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT, /* not yet */
200 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS, /* not yet */
201 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED, /* not yet */
202 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
203 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
204 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
205 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
206 'itemedit' => _ADM_SKPRT_ITEMEDIT,
207 'itemlist' => _ADM_SKPRT_ITEMLIST,
208 'itemmove' => _ADM_SKPRT_ITEMMOVE,
209 'login' => FALSE, //missing
210 'manage' => _ADM_SKPRT_MANAGE,
211 'manageteam' => _ADM_SKPRT_MANAGETEAM,
212 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
213 'memberedit' => FALSE, //missing
214 'overview' => _ADM_SKPRT_OVERVIEW,
215 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
216 'pagehead' => _ADM_SKPRT_PAGEHEAD,
217 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
218 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
219 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
220 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
221 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
222 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
223 'skindelete' => _ADM_SKPRT_SKINDELETE,
224 'skinedit' => _ADM_SKPRT_SKINEDIT,
225 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
226 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
227 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
228 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
229 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
230 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
231 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
232 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
233 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
234 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
235 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
236 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
240 * AdminActions::getAvailableSkinTypes()
244 * @return array list of friendly names for page actions
246 static public function getAvailableSkinTypes()
248 return self::$default_skin_types;
252 * AdminActions::getDefaultTypes()
256 * @return array list of friendly names for page actions
258 static public function getDefaultTypes()
260 return self::$default_skin_types;
264 * AdminActions::__construct()
265 * Constructor for a new Actions object
267 * @param string $type
270 public function __construct($type)
272 // call constructor of superclass first
273 parent::__construct();
274 $this->skintype = $type;
275 if ( !class_exists('Navlist') || !class_exists('Batch') )
278 include $DIR_LIBS . 'ENCAPSULATE.php';
284 * AdminActions::getAvailableActions()
287 * @return array allowed actions for the page type
289 public function getAvailableActions()
291 $extra_actions = array();
293 switch ( $this->skintype )
296 $extra_actions = array(
301 $extra_actions = array(
306 case 'activatesetpwd':
307 $extra_actions = array(
311 $extra_actions = array(
317 case 'adminerrorpage':
318 $extra_actions = array(
321 case 'adminskindelete':
322 $extra_actions = array(
326 case 'adminskinedit':
327 $extra_actions = array(
329 'defaultadminskintypes',
330 'adminspecialskinlist',
333 case 'adminskinedittype':
334 $extra_actions = array(
337 'allowedadminskinactions',
338 'adminskineditallowedlist',
341 case 'adminskiniedoimport':
342 $extra_actions = array(
346 case 'adminskinieimport':
347 $extra_actions = array(
351 case 'adminskinieoverview':
352 $extra_actions = array(
353 'selectlocaladminskinfiles',
357 case 'adminskinoverview':
358 $extra_actions = array(
362 case 'adminskinremovetype':
363 $extra_actions = array(
367 case 'admintemplatedelete':
368 $extra_actions = array(
369 'editadmintemplateinfo',
371 case 'admintemplateedit':
372 $extra_actions = array(
373 'editadmintemplateinfo',
376 case 'admntemplateoverview':
377 $extra_actions = array(
378 'admintemplateoverview',
381 case 'backupoverview':
382 $extra_actions = array(
385 case 'backuprestore':
386 $extra_actions = array(
390 $extra_actions = array(
396 case 'banlistdelete':
397 $extra_actions = array(
402 case 'banlistdeleteconfirm':
403 $extra_actions = array(
404 'banlistdeletedlist',
409 $extra_actions = array(
415 case 'batchcategory':
416 $extra_actions = array(
422 $extra_actions = array(
428 $extra_actions = array(
434 $extra_actions = array(
440 $extra_actions = array(
446 $extra_actions = array(
455 $extra_actions = array(
464 $extra_actions = array(
470 case 'blogcommentlist':
471 $extra_actions = array(
478 $extra_actions = array(
494 $extra_actions = array(
498 case 'browseowncomments':
499 $extra_actions = array(
503 case 'browseownitems':
504 $extra_actions = array(
508 case 'categorydelete':
509 $extra_actions = array(
515 $extra_actions = array(
522 case 'commentdelete':
523 $extra_actions = array(
528 $extra_actions = array(
532 case 'createaccountinput':
533 $extra_actions = array(
540 case 'createaccountsuccess':
541 $extra_actions = array(
\r
546 case 'createaccountdisable':
547 $extra_actions = array(
552 $extra_actions = array(
564 $extra_actions = array(
570 $extra_actions = array(
575 case 'editmembersettings':
576 $extra_actions = array(
577 'adminskinselectoptions',
579 'localeselectoptions',
583 case 'itemcommentlist':
584 $extra_actions = array(
590 $extra_actions = array(
597 $extra_actions = array(
609 $extra_actions = array(
616 $extra_actions = array(
622 $extra_actions = array(
626 $extra_actions = array(
635 $extra_actions = array(
640 $extra_actions = array(
645 $extra_actions = array(
650 $extra_actions = array(
656 $extra_actions = array(
661 case 'pluginoptions':
662 $extra_actions = array(
664 'editplugoptionslist',
668 $extra_actions = array(
671 'configsettingsedit',
672 'configsettingsyesno',
675 'localeselectoptions',
681 $extra_actions = array(
686 $extra_actions = array(
691 $extra_actions = array(
697 $extra_actions = array(
700 'allowedskinactions',
701 'skineditallowedlist',
702 'skineditallowedlist',
705 case 'skiniedoimport':
706 $extra_actions = array(
711 $extra_actions = array(
715 case 'skinieoverview':
716 $extra_actions = array(
717 'selectlocalskinfiles',
722 $extra_actions = array(
726 case 'skinremovetype':
727 $extra_actions = array(
731 case 'systemoverview':
732 $extra_actions = array(
737 $extra_actions = array(
743 case 'templatedelete':
744 $extra_actions = array(
749 $extra_actions = array(
753 case 'templateoverview':
754 $extra_actions = array(
758 case 'usermanagement':
759 $extra_actions = array(
765 $extra_actions = array(
775 'selectlocaladminskinfiles',
783 $defined_actions = array_merge(self::$default_actions, $extra_actions);
785 return array_merge($defined_actions, parent::getAvailableActions());
789 * AdminActions::parse_actionloglist()
790 * Parse skinvar actionloglist
792 * @param string $templateName name of template to use
795 public function parse_actionloglist($templateName = '')
797 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
798 $query = sprintf($query, sql_table('actionlog'));
800 $template['content'] = 'actionlist';
801 $amount = showlist($query, 'table', $template, $templateName);
807 * AdminActions::parse_activationmessage()
808 * Parse skinvar activationmessage
810 * @param string $type type of message
811 * @param string $templateName name of template to use
814 public function parse_activationmessage($type, $templateName = '')
816 global $CONF, $manager;
820 if ( !empty($templateName))
822 $template = Template::read($templateName);
825 $key = postVar('ackey');
828 Admin::error(_ERROR_ACTIVATE);
831 $info = MEMBER::getActivationInfo($key);
834 Admin::error(_ERROR_ACTIVATE);
837 $mem = MEMBER::createFromId($info->vmember);
840 Admin::error(_ERROR_ACTIVATE);
842 switch ( $info->vtype )
845 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
847 $title = $template['ACTIVATE_FORGOT_TITLE'];
851 $title = _ACTIVATE_FORGOT_TITLE;
853 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
855 $text = $template['ACTIVATE_FORGOT_TEXT'];
859 $text = _ACTIVATE_FORGOT_TEXT;
863 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
865 $title = $template['ACTIVATE_REGISTER_TITLE'];
869 $title = _ACTIVATE_REGISTER_TITLE;
871 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
873 $text = $template['ACTIVATE_REGISTER_TEXT'];
877 $text = _ACTIVATE_REGISTER_TEXT;
880 case 'addresschange':
881 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
883 $title = $template['ACTIVATE_CHANGE_TITLE'];
887 $title = _ACTIVATE_CHANGE_TITLE;
889 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
891 $text = $template['ACTIVATE_CHANGE_TEXT'];
895 $text = _ACTIVATE_CHANGE_TEXT;
900 'memberName' => Entity::hsc($mem->getDisplayName()),
901 'realName' => Entity::hsc($mem->getRealName()),
906 echo Template::fill($title, $aVars);
909 echo Template::fill($text, $aVars);
912 echo Entity::hsc($key);
919 * AdminActions::parse_addtickettourl()
920 * Parse skinvar addtickettourl
922 * @param string $url URI for ticket
925 public function parse_addtickettourl($url)
928 $url = $manager->addTicketToUrl($url);
929 echo Entity::hsc($url);
934 * AdminActions::parse_adminbanlist()
935 * Parse skinvar adminbanlist
937 * @param string $templateName name of template to use
940 public function parse_adminbanlist($templateName = '')
942 $blogid = intRequestVar('blogid');
944 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
945 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
947 $template['content'] = 'banlist';
949 $amount = Showlist($query, 'table', $template, $templateName);
959 * AdminActions::parse_adminbatchaction()
960 * Parse skinvar adminbatchaction
965 public function parse_adminbatchaction()
967 echo Entity::hsc(requestVar('batchaction'));
972 * AdminActions::parse_adminbatchlist()
973 * Parse skinvar adminbatchlist
975 * @param string $templateName name of template to use
978 public function parse_adminbatchlist($templateName = '')
981 $templates = array();
983 if ( !empty($templateName) )
985 $templates = Template::read($templateName);
988 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
990 $template = '<li><%text(_BATCH_EXECUTING)%> '
991 . '<b><%adminbatchaction%></b> '
992 . '<%batchlisttype%> '
993 . '<b><%batchid%></b>... '
994 . '<b><%batchlistmsg%></b>'
999 $template = $templates['ADMIN_BATCHLIST'];
1002 $selected = requestIntArray('batch');
1003 $action = requestVar('batchaction');
1005 switch ( $this->skintype )
1008 $batchlisttype = _BATCH_ONITEM;
1009 $deleteaction = 'deleteOneItem';
1010 $moveaction = 'moveOneItem';
1011 $destid = intRequestVar('destcatid');
1013 case 'batchcomment':
1014 $batchlisttype = _BATCH_ONCOMMENT;
1015 $deleteaction = 'deleteOneComment';
1018 $batchlisttype = _BATCH_ONMEMBER;
1019 $deleteaction = 'deleteOneMember';
1020 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1021 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1022 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1023 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1026 $blogid = intRequestVar('blogid');
1027 $batchlisttype = _BATCH_ONTEAM;
1028 $deleteaction = 'deleteOneTeamMember';
1029 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1030 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1031 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1032 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1034 case 'batchcategory':
1035 $batchlisttype = _BATCH_ONCATEGORY;
1036 $deleteaction = 'deleteOneCategory';
1037 $moveaction = 'moveOneCategory';
1038 $destid = intRequestVar('destblogid');
1042 // walk over all selectedids and perform action
1043 foreach ( $selected as $selectedid )
1046 $selectedid = intval($selectedid);
1050 if ( $this->skintype != 'batchteam' )
1052 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1056 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1060 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1064 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1068 // there should always remain at least one super-admin
1069 $r = DB::getResult($unsetchksql);
1070 if ( $r->rowCount() < 2 )
1072 $error = $unseterrmsg;
1076 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1080 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1084 'batchid' => $selectedid,
1085 'batchlisttype' => Entity::hsc($batchlisttype),
1086 'adminbatchaction' => Entity::hsc($action),
1087 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1090 $handler = new AdminActions('template');
1091 $parser = new Parser($handler);
1093 $output = Template::fill($template, $data);
1095 $parser->parse($output);
1096 $output = ob_get_contents();
1098 echo "{$output}<br />";
1104 * AdminActions::parse_adminbloglink()
1105 * Parse skinvar adminbloglink
1107 * @param string $templateName name of template to use
1110 public function parse_adminbloglink($templateName = '')
1113 $blogid = intRequestVar('blogid');
1114 $blog =& $manager->getBlog($blogid);
1115 $templates = array();
1117 if ( !empty($templateName) )
1119 $templates = Template::read($templateName);
1122 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1124 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1128 $template = $templates['ADMIN_BLOGLINK'];
1132 'url' => Entity::hsc($blog->getURL()),
1133 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1134 'blogname' => Entity::hsc($blog->getName())
1137 echo Template::fill($template, $data);
1142 * AdminActions::parse_adminerrormesg()
1143 * Parse skinvar adminerrormesg
1148 public function parse_adminerrormesg()
1153 if ( requestVar('errormessage') )
1155 $message = requestVar('errormessage');
1157 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1159 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1161 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1163 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1165 echo Entity::hsc($message);
1170 * AdminActions::parse_adminskineditallowedlist()
1171 * Parse skinvar adminskineditallowedlist
1173 * @param string $type template/blog
1174 * @param string $templateName name of template to use
1177 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1181 /* TODO: blog seems not to be used */
1183 $query = "SELECT bshortname, bname FROM %s";
1184 $query = sprintf($query, sql_table('blog'));
1186 'content' => 'shortblognames'
1188 Showlist($query, 'table', $show, $templateName);
1191 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1192 $query = sprintf($query, sql_table('template_desc'));
1194 'content' => 'shortnames'
1196 Showlist($query, 'table', $show, $templateName);
1203 * AdminActions::parse_adminskinielist()
1204 * Parse skinvar adminskinielist
1206 * @param string $type skin/template
1207 * @param string $templateName name of template to use
1210 public function parse_adminskinielist($type, $templateName = '')
1212 $templates = array();
1213 if ( $templateName )
1215 $templates = Template::read($templateName);
1218 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1221 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1222 . "<label for=\"<%expid%>\"><%expname%></label>"
1224 . "<td><%expdesc%></td>\n"
1230 $template = $templates['SKINIE_EXPORT_LIST'];
1236 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1237 $query = sprintf($query, sql_table('skin_desc'));
1238 $res = DB::getResult($query);
1240 foreach ( $res as $row )
1243 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1244 'expid' => 'skinexp' . $row['sdnumber'],
1245 'expname' => Entity::hsc($row['sdname']),
1246 'expdesc' => Entity::hsc($row['sddesc']),
1248 echo Template::fill($template, $data);
1252 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1253 $query = sprintf($query, sql_table('template_desc'));
1254 $res = DB::getResult($query);
1255 foreach ( $res as $row )
1258 'typeid' => 'template[' . $row['tdnumber'] . ']',
1259 'expid' => 'templateexp' . $row['tdnumber'],
1260 'expname' => Entity::hsc($row['tdname']),
1261 'expdesc' => Entity::hsc($row['tddesc']),
1263 echo Template::fill($template, $data);
1271 * AdminActions::parse_adminskinoverview()
1272 * Parse skinvar adminskinoverview
1274 * @param string $templateName name of template to use
1277 public function parse_adminskinoverview($templateName = '')
1279 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1280 $query = sprintf($query, sql_table('skin_desc'));
1282 $template['content'] = 'adminskinlist';
1283 $template['tabindex'] = 10;
1284 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1285 Showlist($query, 'table', $template, $templateName);
1290 * AdminActions::parse_adminskinselectoptions()
1291 * Parse skinvar adminskinselectoptions
1296 public function parse_adminskinselectoptions($templateName = '')
1299 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1300 $query = sprintf($query, sql_table('skin_desc'));
1302 $template['name'] = 'adminskin';
1303 $template['selected'] = $CONF['AdminSkin'];
1304 $template['tabindex'] = 110;
1305 Showlist($query, 'select', $template, $templateName);
1310 * AdminActions::parse_adminspecialskinlist()
1311 * Parse skinvar adminspecialskinlist
1313 * @param string $templateName name of template to use
1315 public function parse_adminspecialskinlist($templateName = '')
1317 $templates = array();
1318 if ( $templateName )
1320 $templates = Template::read($templateName);
1323 $nType = $this->parser->skin->getAvailableTypes();
1324 $skinid = intRequestVar('skinid');
1326 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1327 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1329 $res = DB::getResult($query);
1330 if ( $res && $res->rowCount() > 0 )
1332 /* NOTE: set templates for HEAD/BODY/FOOT */
1333 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1335 $template['head'] = "<ul>\n";
1339 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1341 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1343 $template['body'] = '<li>'
1344 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1347 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1354 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1356 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1358 $template['foot'] = "</ul>\n";
1362 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1369 echo $template['head'];
1370 foreach ( $res as $row )
1373 'tabindex' => $tabstart++,
1374 'skinid' => $skinid,
1375 'skintype' => Entity::hsc(strtolower($row['stype']))
1377 echo Template::fill($template['body'], $data);
1380 echo $template['foot'];
1386 * AdminActions::parse_admintemplateoverview()
1387 * Parse skinvar admintemplateoverview
1389 * @param string $templateName name of template to use
1392 public function parse_admintemplateoverview($templateName = '')
1394 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1395 $query = sprintf($query, sql_table('template_desc'));
1397 $template['content'] = 'admintemplatelist';
1398 $template['tabindex'] = 10;
1400 Showlist($query, 'table', $template, $templateName);
1405 * AdminActions::parse_allowedadminskinactions()
1406 * Parse skinvar allowedadminskinactions
1411 public function parse_allowedadminskinactions()
1413 global $DIR_ADMINSKINS;
1414 $skinType = strtolower(trim(requestVar('type')));
1415 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1418 while ( $current = array_shift($actions) )
1420 // TODO: remove this
1421 // skip deprecated vars
1422 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1427 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1429 if ( count($actions) != 0 )
1438 * AdminActions::parse_allowedskinactions()
1439 * Parse skinvar allowedskinactions
1444 public function parse_allowedskinactions()
1446 $skinType = strtolower(trim(requestVar('type')));
1447 $skinid = intRequestVar('skinid');
1449 $skin = new Skin($skinid);
1450 $actions = $skin->getAllowedActionsForType($skinType);
1453 while ( $current = array_shift($actions) )
1455 // TODO: remove this
1456 // skip deprecated vars
1457 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1462 /* TODO: alternative function should be used or not? */
1463 echo helplink("skinvar-{$current}") . "$current</a>\n";
1465 if ( count($actions) != 0 )
1474 * AdminActions::parse_banlistdeletedlist()
1475 * Parse skinvar banlistdeletedlist
1477 * @param string $templateName name of template to use
1480 public function parse_banlistdeletedlist($templateName = '')
1484 $templates = array();
1485 if ( $templateName )
1487 $templates = Template::read($templateName);
1490 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1492 $template = "<li><%blogname%></li>\n";
1496 $template = $templates['BANLIST_DELETED_LIST'];
1499 $deleted = requestArray('delblogs');
1500 foreach ( $deleted as $delblog )
1502 $blog =& $manager->getBlog($delblog);
1504 'blogname' => Entity::hsc($blog->getName())
1506 echo Template::fill($template, $data);
1513 * AdminActions::parse_batchdeletelist()
1514 * Parse skinvar batchdeletelist
1519 public function parse_batchdeletelist()
1521 $selected = requestIntArray('batch');
1524 foreach ( $selected as $select )
1526 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1528 // add hidden vars for team & comment
1529 if ( requestVar('action') == 'batchteam' )
1531 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1533 if ( requestVar('action') == 'batchcomment' )
1535 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1541 * AdminActions::parse_batchdeletetype()
1542 * Parse skinvar batchdeletetype
1547 public function parse_batchdeletetype()
1549 echo Entity::hsc(requestVar('action'));
1554 * AdminActions::parse_batchmovebtn()
1555 * Parse skinvar batchmovebtn
1560 public function parse_batchmovebtn()
1562 $actionType = requestVar('action');
1563 switch ( $actionType )
1568 case 'batchcategory':
1576 * AdminActions::parse_batchmovelist()
1577 * Parse skinvar batchmovelist
1582 public function parse_batchmovelist()
1584 $selected = requestIntArray('batch');
1586 foreach ( $selected as $select )
1588 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1595 * AdminActions::parse_batchmovetitle()
1596 * Parse skinvar batchmovetitle
1601 public function parse_batchmovetitle()
1603 $actionType = requestVar('action');
1604 switch ( $actionType )
1609 case 'batchcategory':
1610 echo _MOVECAT_TITLE;
1617 * AdminActions::parse_batchmovetype()
1618 * Parse skinvar batchmovetype
1623 public function parse_batchmovetype()
1625 echo Entity::hsc(requestVar('action'));
1630 * AdminActions::parse_blogcatlist()
1631 * Parse skinvar blogcatlist
1636 public function parse_blogcatlist($templateName = '')
1639 $blogid = intRequestVar('blogid');
1640 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1641 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1643 $template['content'] = 'categorylist';
1644 $template['tabindex'] = 200;
1646 $batch = new Batch('category');
1647 $batch->showlist($query, 'table', $template, $templateName);
1652 * AdminActions::parse_blogid()
1653 * Parse skinvar blogid
1658 public function parse_blogid()
1660 echo intRequestVar('blogid');
1665 * AdminActions::parse_blognotifysetting()
1666 * Parse skinvar blognotifysetting
1671 public function parse_blognotifysetting($type)
1674 $blogid = intRequestVar('blogid');
1675 $blog = $manager->getBlog($blogid);
1680 if ( !$blog->notifyOnComment() )
1686 if ( !$blog->notifyOnVote() )
1692 if ( !$blog->notifyOnNewItem() )
1698 echo ' checked="checked"';
1703 * AdminActions::parse_blogsetting()
1704 * Parse skinvar blogsetting
1706 * @param string $which name of weblog setting
1709 public function parse_blogsetting($which)
1711 echo $this->parse_getblogsetting($which);
1716 * AdminActions::parse_blogsettingyesno()
1717 * Parse skinvar blogsettingyesno
1719 * @param string $type type of weblog setting
1720 * @param string $templateName name of template to use
1723 public function parse_blogsettingyesno($type, $templateName = '')
1727 $blogid = intRequestVar('blogid');
1728 $blog = $manager->getBlog($blogid);
1732 case 'convertbreaks':
1733 $checkedval = $blog->convertBreaks();
1736 case 'allowpastposting':
1737 $checkedval = $blog->allowPastPosting();
1741 $checkedval = $blog->commentsEnabled();
1745 $checkedval = $blog->isPublic();
1749 $checkedval = $blog->emailRequired();
1753 $checkedval = $blog->getSearchable();
1757 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1762 * AdminActions::parse_blogteamlist()
1763 * Parse skinvar blogteamlist
1765 * @param string $templateName name of template to use
1768 public function parse_blogteamlist($templateName = '')
1771 $blogid = intRequestVar('blogid');
1772 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1774 . "WHERE tmember=mnumber AND tblog= %d";
1775 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1777 $template['content'] = 'teamlist';
1778 $template['tabindex'] = 10;
1780 $batch = new Batch('team');
1781 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1786 * AdminActions::parse_blogteammembers()
1787 * Parse skinvar blogteammembers
1792 public function parse_blogteammembers()
1794 $blogid = intRequestVar('blogid');
1795 $query = "SELECT mname, mrealname "
1797 . "WHERE mnumber=tmember AND tblog=%d;";
1798 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1799 $res = DB::getResult($query);
1800 $memberNames = array();
1801 foreach ( $res as $row )
1803 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1805 echo implode(',', $memberNames);
1809 * AdminActions::parse_blogtime()
1810 * Parse skinvar blogtime
1812 * @param string $type type of time
1813 * @param string $format format for time expression
1814 * @param integer $offset offset of time
1817 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1821 if ( $type != 'blogtime' )
1823 /* return server time */
1824 $timestamp = time() + $offset;
1828 $bid = intRequestVar('blogid');
1829 $b = $manager->getBlog($bid);
1830 $timestamp = $b->getCorrectTime() + $offset;
1833 echo i18n::formatted_datetime($format, $timestamp);
1838 * AdminActions::parse_bookmarkletadmin()
1839 * Parse skinvar bookmarkletadmin
1844 public function parse_bookmarkletadmin()
1848 $blogid = intRequestVar('blogid');
1850 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1855 * AdminActions::parse_categories()
1856 * Parse skinvar categories
1858 * create category dropdown box
1860 * @param string $type name of setting for category
1863 public function parse_categories($startidx = 0)
1868 $itemid = intRequestVar('itemid');
1869 $item = &$manager->getItem($itemid, 1, 1);
1874 $blogid = intRequestVar('blogid');
1878 $blogid = $item['blogid'];
1880 $blog = &$manager->getBlog($blogid);
1882 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1884 $item['body'] = removeBreaks($item['body']);
1885 $item['more'] = removeBreaks($item['more']);
1888 $contents = array();
1889 if ( requestVar('action') == 'itemedit' )
1894 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1897 $catid = $blog->getDefaultCategory();
1902 $catid = $contents['catid'];
1905 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1911 * AdminActions::parse_category()
1912 * Parse skinvar category
1914 * @param string $type name of setting for category
1917 public function parse_category($type = 'name')
1919 echo $this->parse_getcategory($type);
1924 * AdminActions::parse_categorysetting()
1925 * Parse skinvar categorysetting
1927 * @param string $type type in category setting
1930 public function parse_categorysetting($type)
1932 $catid = intRequestVar('catid');
1933 if ( $type == 'id' )
1938 $blogid = intRequestVar('blogid');
1939 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1940 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1941 $row = DB::getRow($query);
1943 if ( $type != 'name' )
1945 echo Entity::hsc($row['cdesc']);
1949 echo Entity::hsc($row['cname']);
1956 * AdminActions::parse_codename()
1957 * Parse templatevar codename
1963 public function parse_checkedonval($value, $name)
1968 $itemid = intRequestVar('itemid');
1969 $item =& $manager->getItem($itemid, 1, 1);
1971 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1973 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1975 $item['body'] = removeBreaks($item['body']);
1976 $item['more'] = removeBreaks($item['more']);
1979 $contents = array();
1980 if ( requestVar('action') == 'itemedit' )
1984 if ( !isset($contents[$name]) )
1986 $contents[$name] = '';
1988 if ($contents[$name] == $value)
1990 echo 'checked="checked"';
1996 * AdminActions::parse_codename()
1997 * Parse templatevar codename
2002 * TODO: is this need???
2004 public function parse_codename()
2007 echo $nucleus['codename'];
2012 * AdminActions::parse_commentnavlist()
2013 * Parse skinvar commentnavlist
2018 public function parse_commentnavlist()
2020 global $CONF, $manager, $member;
2023 if ( postVar('start') )
2025 $start = intPostVar('start');
2032 // amount of items to show
2033 if ( postVar('amount') )
2035 $amount = intPostVar('amount');
2039 $amount = (integer) $CONF['DefaultListSize'];
2045 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2047 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2049 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2051 if ( $this->skintype == 'itemcommentlist' )
2053 $itemid = intRequestVar('itemid');
2054 $query .= " citem={$itemid}";
2055 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2057 $nonComments = _NOCOMMENTS;
2059 elseif ( $this->skintype == 'browseowncomments' )
2062 $query .= ' cmember=' . $member->getID();
2063 $template['canAddBan'] = 0;
2065 $nonComments = _NOCOMMENTS_YOUR;
2067 elseif ( $this->skintype == 'blogcommentlist' )
2070 $query .= ' cblog=' . intRequestVar('blogid');
2071 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2072 $bid = intRequestVar('blogid');
2073 $nonComments = _NOCOMMENTS_BLOG;
2076 $search = postVar('search');
2077 if ( !empty($search) )
2079 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2082 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2084 $template['content'] = 'commentlist';
2086 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2087 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2092 * AdminActions::parse_configsettingsedit()
2093 * Parse skinvar configsettingsedit
2095 * @param string $type type of global configuration
2098 public function parse_configsettingsedit($type)
2103 case 'DefaultListSize':
2104 if ( !array_key_exists('DefaultListSize', $CONF) )
2106 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2107 $query = sprintf($query, sql_table('config'));
2108 DB::execute($query);
2109 $CONF['DefaultListSize'] = 10;
2111 elseif ( intval($CONF['DefaultListSize']) < 1 )
2113 $CONF['DefaultListSize'] = 10;
2115 echo intval($CONF['DefaultListSize']);
2117 case 'SessionCookie':
2118 $value = $CONF['SessionCookie'];
2119 $txt1 = _SETTINGS_COOKIESESSION;
2120 $txt2 = _SETTINGS_COOKIEMONTH;
2121 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2124 $value = $CONF['URLMode'];
2125 $txt1 = _SETTINGS_URLMODE_NORMAL;
2126 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2127 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2130 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2132 echo Entity::hsc($CONF[$type]);
2140 * AdminActions::parse_configsettingsyesno()
2141 * Parse skinvar configsettingsyesno
2143 * @param string $type type of global setting
2144 * @param integer $tabindex tabindex attribute of input element
2147 public function parse_configsettingsyesno($type, $tabindex)
2150 if ( array_key_exists($type, $CONF) )
2152 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2158 * AdminActions::parse_contents()
2159 * Parse skinvar contents
2161 * @param string $which part for item
2164 public function parse_contents($which)
2166 if ( !array_key_exists($which, Admin::$contents) )
2168 Admin::$contents[$which] = '';
2170 echo Entity::hsc(Admin::$contents[$which]);
2174 * AdminActions::parse_currenttime()
2175 * Parse skinvar currenttime
2177 * @param string $what
2180 public function parse_currenttime($what)
2182 $nu = getdate(Admin::$blog->getCorrectTime());
2187 * AdminActions::parse_customhelplink()
2188 * Parse skinvar customhelplink
2190 * @param string $topic name of topic
2191 * @param string $tplName name of template
2192 * @param string $url string as URI
2193 * @param string $iconURL string as URI for icon
2194 * @param string $alt alternative text for image element
2195 * @param string $title title for anchor element
2198 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2200 $this->customHelp($topic, $url, $iconURL);
2205 * AdminActions::parse_date()
2206 * Parse skinvar date
2208 public function parse_date($format = 'c')
2210 global $CONF, $manager;
2211 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2216 * AdminActions::parse_defaultadminskintypes()
2217 * Parse skinvar defaultadminskintypes
2219 * @param string $tabindex index number for tabindex attribute of input element
2220 * @param string $templateName name of template
2223 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2225 $templates = array();
2227 if ( $templateName )
2229 $templates = Template::read($templateName);
2232 $types = $this->parser->skin->getAvailableTypes();
2235 /* NOTE: set templates for HEAD/BODY/FOOT */
2236 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2238 $template['head'] = "<ul>\n";
2242 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2244 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2246 $template['body'] = "<li>"
2247 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2252 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2254 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2256 $template['foot'] = "</ul>\n";
2260 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2263 $handler = new AdminActions('template');
2264 $parser = new PARSER($handler);
2266 /* NOTE: do output */
2267 echo $template['head'];
2268 foreach ( $types as $type => $fName )
2270 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2272 'tabindex' => $tabindex,
2273 'skintype' => $type,
2275 'help' => $helplink,
2276 'skinid' => intrequestVar('skinid'),
2278 $parser->parse(Template::fill($template['body'], $data));
2281 echo $template['foot'];
2287 * AdminActions::parse_defblogselect()
2288 * Parse skinvar defblogselect
2290 * @param string $templateName name of template
2293 public function parse_defblogselect($templateName = '')
2297 $query = "SELECT bname as text, bnumber as value FROM %s;";
2298 $query = sprintf($query, sql_table('blog'));
2300 $template['name'] = 'DefaultBlog';
2301 $template['selected'] = $CONF['DefaultBlog'];
2302 $template['tabindex'] = 10;
2304 Showlist($query, 'select', $template, $templateName);
2310 * AdminActions::parse_defcatselect()
2311 * Parse skinvar defcatselect
2313 * @param string $templateName name of template
2316 public function parse_defcatselect($templateName = '')
2320 $blogid = intRequestVar('blogid');
2321 $blog = $manager->getBlog($blogid);
2323 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2324 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2326 $template['name'] = 'defcat';
2327 $template['selected'] = $blog->getDefaultCategory();
2328 $template['tabindex'] = 110;
2330 Showlist($query, 'select', $template, $templateName);
2336 * AdminActions::parse_defskinselect()
2337 * Parse skinvar defskinselect
2339 * @param string $type type of skin
2340 * @param string $templateName name of template
2343 public function parse_defskinselect($type = 'blog', $templateName = '')
2345 global $CONF, $manager;
2347 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2348 $query = sprintf($query, sql_table('skin_desc'));
2350 $blogid = intRequestVar('blogid');
2354 $template['selected'] = $CONF['BaseSkin'];
2358 $blog = $manager->getBlog($blogid);
2359 $template['selected'] = $blog->getDefaultSkin();
2362 if ( $type != 'blog' )
2364 $nname = 'BaseSkin';
2371 $template['name'] = $nname;
2372 $template['tabindex'] = 50;
2374 Showlist($query, 'select', $template, $templateName);
2380 * AdminActions::parse_deletecomment()
2381 * Parse skinvar deletecomment
2383 * @param string $type type of infomation for comment
2386 public function parse_deletecomment($type = 'id')
2388 $commentid = intRequestVar('commentid');
2389 $comment = COMMENT::getComment($commentid);
2394 echo intRequestVar('commentid');
2397 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2399 echo $comment['member'];
2403 echo $comment['user'];
2407 $body = strip_tags($comment['body']);
2408 echo Entity::hsc(shorten($body, 300, '...'));
2414 * AdminActions::parse_deleteitembody()
2415 * Parse skinvar deleteitembody
2420 public function parse_deleteitembody()
2424 $itemid = intRequestVar('itemid');
2425 $item =& $manager->getItem($itemid, 1, 1);
2427 $body = strip_tags($item['body']);
2429 echo Entity::hsc(shorten($body, 300, '...'));
2435 * AdminActions::parse_deleteitemid()
2436 * Parse skinvar deleteitemid
2441 public function parse_deleteitemid()
2443 echo (integer) intRequestVar('itemid');
2448 * AdminActions::parse_deleteitemtitle()
2449 * Parse skinvar deleteitemtitle
2454 public function parse_deleteitemtitle()
2458 $itemid = intRequestVar('itemid');
2459 $item =& $manager->getItem($itemid, 1, 1);
2461 echo Entity::hsc(strip_tags($item['title']));
2467 * AdminActions::parse_editadminskin()
2468 * Parse skinvar editadminskin
2470 * @param string $type type of skin setting
2473 public function parse_editadminskin($type = 'id')
2475 $skinid = intRequestVar('skinid');
2476 $skin = new Skin($skinid);
2480 echo intRequestVar('skinid');
2483 echo Entity::hsc($skin->getName());
2486 echo Entity::hsc($skin->getDescription());
2489 echo Entity::hsc($skin->getContentType());
2492 echo Entity::hsc($skin->getIncludePrefix());
2495 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2503 * AdminActions::parse_editadminskintype()
2504 * Parse skinvar editadminskintype
2506 * @param string $type name of skin type
2509 public function parse_editadminskintype($type = 'id')
2511 global $CONF, $manager, $member;
2513 $fNames = $this->parser->skin->getAvailableTypes();
2514 $sType = strtolower(trim(requestVar('type')));
2519 echo intRequestVar('skinid');
2522 echo Entity::hsc($this->parser->skin->getName());
2525 echo Entity::hsc($this->parser->skin->getDescription());
2528 echo Entity::hsc($this->parser->skin->getContentType());
2531 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2534 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2535 echo Entity::hsc($skinType);
2538 echo Entity::hsc($sType);
2541 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2544 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2545 echo Entity::hsc($incMode);
2554 * AdminActions::parse_editcomment()
2555 * Parse skinvar editcomment
2557 * @param string $type type of comment setting
2560 public function parse_editcomment($type = 'id')
2564 $commentid = intRequestVar('commentid');
2565 $comment = COMMENT::getComment($commentid);
2567 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2572 echo intRequestVar('commentid');
2575 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2577 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2581 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2585 echo date("Y-m-d @ H:i", $comment['timestamp']);
2588 $comment['body'] = str_replace('<br />', '', $comment['body']);
2589 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2590 echo $comment['body'];
2593 echo $comment['userid'];
2596 echo $comment['userid'];
2599 echo $comment[$type];
2606 * AdminActions::parse_editdesturl()
2607 * Parse skinvar editdesturl
2609 public function parse_editdesturl()
2611 if ( requestVar('desturl') )
2613 echo Entity::hsc(requestVar('desturl'));
2619 * AdminActions::parse_editmemberlist()
2620 * Parse skinvar editmemberlist
2622 * @param string $templateName name of template
2625 public function parse_editmemberlist($templateName = '')
2628 // show list of members with actions
2629 $query = 'SELECT * FROM '.sql_table('member');
2630 $template['content'] = 'memberlist';
2631 $template['tabindex'] = 10;
2633 $batch = new Batch('member');
2634 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2639 * AdminActions::parse_editmember()
2640 * Parse skinvar editmember
2642 * @param string $type type of information for member
2643 * @return string $tempateName name of template to use
2646 public function parse_editmember($type = 'id', $templateName = '')
2648 global $CONF, $manager, $member;
2650 $memberid = intRequestVar('memberid');
2651 $mem = MEMBER::createFromID($memberid);
2656 echo intRequestVar('memberid');
2659 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2661 echo Entity::hsc($mem->getDisplayName());
2665 $dispName = Entity::hsc($mem->getDisplayName());
2666 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2668 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2677 echo Entity::hsc($mem->getRealName());
2680 echo Entity::hsc($mem->getEmail());
2683 echo Entity::hsc($mem->getURL());
2686 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2689 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2692 echo Entity::hsc($mem->getNotes());
2695 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2704 * AdminActions::parse_editpluginfo()
2705 * Parse skinvar editpluginfo
2707 * @param string $type type of plugin info
2710 public function parse_editpluginfo($type)
2714 $pid = intRequestVar('plugid');
2721 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2728 * AdminActions::parse_editplugoptionslist()
2729 * Parse skinvar editplugoptionslist
2731 * @param string $templateName name of template
2734 public function parse_editplugoptionslist($templateName = '')
2738 $pid = intRequestVar('plugid');
2739 $aOptions = array();
2742 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2743 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2744 $resource = DB::getResult($query);
2746 foreach ( $resource as $row )
2748 array_push($aOIDs, $row['oid']);
2749 $aOptions[$row['oid']] = array(
2750 'oid' => $row['oid'],
2751 'value' => $row['odef'],
2752 'name' => $row['oname'],
2753 'description' => $row['odesc'],
2754 'type' => $row['otype'],
2755 'typeinfo' => $row['oextra'],
2760 // fill out actual values
2761 if ( count($aOIDs) > 0 )
2763 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2764 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2766 $result = DB::getResult($query);
2768 foreach ( $result as $row )
2770 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2776 'context' => 'global',
2778 'options' => &$aOptions
2780 $manager->notify('PrePluginOptionsEdit', $data);
2782 $template['content'] = 'plugoptionlist';
2784 $amount = Showlist($aOptions, 'table', $template, $templateName);
2788 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2794 * AdminActions::parse_editskin()
2795 * Parse skinvar editskin
2797 * @param string $type type of skin
2800 public function parse_editskin($type = 'id')
2802 $skinid = intRequestVar('skinid');
2803 $skin = new SKIN($skinid);
2807 echo intRequestVar('skinid');
2810 echo Entity::hsc($skin->getName());
2813 echo Entity::hsc($skin->getDescription());
2816 echo Entity::hsc($skin->getContentType());
2819 echo Entity::hsc($skin->getIncludePrefix());
2822 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2830 * AdminActions::parse_editskintype()
2831 * Parse skinvar editskintype
2833 * @param string $type name of type for skin type
2836 public function parse_editskintype($type = 'id')
2838 global $CONF, $manager, $member;
2839 $skinid = intRequestVar('skinid');
2840 $skin = new SKIN($skinid);
2841 $fNames = $skin->getAvailableTypes();
2842 $sType = strtolower(trim(requestVar('type')));
2847 echo intRequestVar('skinid');
2850 echo Entity::hsc($skin->getName());
2853 echo Entity::hsc($skin->getDescription());
2856 echo Entity::hsc($skin->getContentType());
2859 echo Entity::hsc($skin->getContentFromDB($sType));
2862 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2863 echo Entity::hsc($skinType);
2866 echo Entity::hsc($sType);
2869 echo Entity::hsc($skin->getIncludePrefix());
2872 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2873 echo Entity::hsc($incMode);
2882 * AdminActions::parse_adminurl()
2883 * Parse skinvar adminurl
2884 * (shortcut for admin url)
2889 public function parse_adminurl()
2891 $this->parse_sitevar('adminurl');
2896 * AdminActions::parse_edittemplateinfo()
2897 * Parse skinvar edittemplateinfo
2899 * @param string $type name of type for skin
2900 * @param string $description description for skin
2901 * @param string $name name of skin
2902 * @param string $help
2903 * @param string $tabindex index value for tabindex attribute of input element
2904 * @param string $big
2905 * @param string $tplt name of template
2908 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2912 $t_id = intRequestVar('templateid');
2913 $t_name = Template::getNameFromId($t_id);
2914 $t_desc = Template::getDesc($t_id);
2915 $template = &Template::read($t_name);
2923 echo Entity::hsc($t_name);
2926 echo Entity::hsc($t_desc);
2928 case 'extratemplate':
2930 $pluginfields = array();
2931 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2936 $tmplt = Template::read($desc);
2938 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2942 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2946 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2949 foreach ( $pluginfields as $pfkey => $pfvalue )
2951 $data = array('explugtplname' => Entity::hsc($pfkey));
2953 echo Template::fill($base, $data);
2955 foreach ( $pfvalue as $pffield => $pfdesc )
2957 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2962 $desc = defined($desc) ? constant($desc) : $desc;
2963 $name = defined($name) ? constant($name) : $name;
2964 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2972 * AdminActions::parse_editadmintemplateinfo()
2973 * Parse skinvar editadmintemplateinfo
2975 * @param string $type type of skin template
2976 * @param string $description description of template
2977 * @param string $name name of stemplate
2978 * @param string $tabindex index number for tabindex attribute of input element
2979 * @param string $big
2980 * @param string $tplt
2982 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2986 $t_id = intRequestVar('templateid');
2987 $t_name = Template::getNameFromId($t_id);
2988 $t_desc = Template::getDesc($t_id);
2989 $template = &Template::read($t_name);
2997 echo Entity::hsc($t_name);
3000 echo Entity::hsc($t_desc);
3002 case 'extratemplate':
3004 $pluginfields = array();
3005 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3010 $tmplt = Template::read($desc);
3012 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3016 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3020 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3023 foreach ( $pluginfields as $pfkey => $pfvalue )
3025 $data = array('explugtplname' => Entity::hsc($pfkey));
3027 echo Template::fill($base, $data);
3029 foreach ( $pfvalue as $pffield => $pfdesc )
3031 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3036 $desc = defined($desc) ? constant($desc) : $desc;
3037 $name = defined($name) ? constant($name) : $name;
3038 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3045 * AdminActions::parse_eventformextra()
3046 * Parse skinvar eventformextra
3048 * @param string $type name of type for event form extra
3051 public function parse_eventformextra($type = 'activation')
3060 $key = requestVar('ackey');
3063 Admin::error(_ERROR_ACTIVATE);
3065 $info = MEMBER::getActivationInfo($key);
3068 Admin::error(_ERROR_ACTIVATE);
3070 $mem = MEMBER::createFromId($info->vmember);
3073 Admin::error(_ERROR_ACTIVATE);
3076 'type' => 'activation',
3080 case 'membermailform-notloggedin':
3081 $data = array('type' => 'membermailform-notloggedin',);
3084 $manager->notify('FormExtra', $data);
3089 * AdminActions::parse_extrahead()
3090 * Parse skinvar extrahead
3092 public function parse_extrahead()
3096 $extrahead = Admin::getAdminextrahead();
3099 'extrahead' => &$extrahead,
3100 'action' => Admin::getAdminAction()
3103 $manager->notify('AdminPrePageHead', $data);
3109 * AdminActions::parse_member()
3110 * Parse skinvar member
3111 * (includes a member info thingie)
3113 * @param string $what which memberdata is needed
3116 public function parse_member($what)
3118 global $memberinfo, $member, $CONF;
3120 // 1. only allow the member-details-page specific variables on member pages
3121 if ( $this->skintype == 'member' )
3126 echo Entity::hsc($memberinfo->getDisplayName());
3129 echo Entity::hsc($memberinfo->getRealName());
3132 echo Entity::hsc($memberinfo->getNotes());
3135 echo Entity::hsc($memberinfo->getURL());
3138 echo Entity::hsc($memberinfo->getEmail());
3141 echo Entity::hsc($memberinfo->getID());
3146 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3147 if ( $member->isLoggedIn() )
3152 echo $member->getDisplayName();
3154 case 'yourrealname':
3155 echo $member->getRealName();
3158 echo $member->getNotes();
3161 echo $member->getURL();
3164 echo $member->getEmail();
3167 echo $member->getID();
3169 case 'yourprofileurl':
3170 if ( $CONF['URLMode'] == 'pathinfo' )
3172 echo Link::create_member_link($member->getID());
3176 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3185 * AdminActions::parse_version()
3186 * Parse skinvar version
3187 * (include nucleus versionnumber)
3192 public function parse_version()
3195 echo 'Nucleus CMS ' . $nucleus['version'];
3200 * AdminActions::parse_sitevar()
3201 * Parse skinvar sitevar
3202 * (include a sitevar)
3204 * @param string $which
3207 public function parse_sitevar($which)
3213 echo $CONF['IndexURL'];
3216 echo $CONF['SiteName'];
3219 echo $CONF['AdminEmail'];
3222 echo $CONF['AdminURL'];
3229 * AdminActions::parse_charset()
3230 * Parse skinvar charset
3235 public function parse_charset()
3237 echo i18n::get_current_charset();
3242 * AdminActions::parse_getblogsetting()
3243 * Parse skinvar getblogsetting
3245 public function parse_getblogsetting($which)
3247 global $blog, $manager;
3253 elseif ( $bid = intRequestVar('blogid') )
3255 $b = $manager->getBlog($bid);
3265 return Entity::hsc($b->getID());
3268 return Entity::hsc($b->getURL());
3271 return Entity::hsc($b->getName());
3274 return Entity::hsc($b->getDescription());
3277 return Entity::hsc($b->getShortName());
3279 case 'notifyaddress':
3280 return Entity::hsc($b->getNotifyAddress());
3283 return Entity::hsc($b->getMaxComments());
3286 return Entity::hsc($b->getUpdateFile());
3289 return Entity::hsc($b->getTimeOffset());
3296 * AdminActions::parse_geteditpluginfo()
3297 * Parse skinvar geteditpluginfo
3299 * @param string $type name of setting for edit plugin info
3302 public function parse_geteditpluginfo($type)
3305 $pid = intRequestVar('plugid');
3312 return Entity::hsc($manager->getPluginNameFromPid($pid));
3319 * AdminActions::parse_getmember()
3320 * Parse skinvar getmember
3321 * (includes a member info thingie)
3323 * @param string $what name of setting for member
3326 public function parse_getmember($what)
3328 global $memberinfo, $member;
3329 // 1. only allow the member-details-page specific variables on member pages
3330 if ( $this->skintype == 'member' )
3335 return Entity::hsc($memberinfo->getDisplayName());
3338 return Entity::hsc($memberinfo->getRealName());
3341 return Entity::hsc($memberinfo->getNotes());
3344 return Entity::hsc($memberinfo->getURL());
3347 return Entity::hsc($memberinfo->getEmail());
3350 return Entity::hsc($memberinfo->getID());
3354 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3355 if ( $member->isLoggedIn() )
3360 return $member->getDisplayName();
3362 case 'yourrealname':
3363 return $member->getRealName();
3366 return $member->getNotes();
3369 return $member->getURL();
3372 return $member->getEmail();
3375 return $member->getID();
3383 * AdminActions::parse_headmessage()
3384 * Parse skinvar headmessage
3389 public function parse_headmessage()
3391 if ( !empty(Admin::$headMess) )
3393 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3399 * AdminActions::parse_helplink()
3400 * Parse skinvar helplink
3402 * @param string $topic name of topic for help
3405 public function parse_helplink($topic = '')
3407 if ( !empty($topic) )
3415 * AdminActions::parse_helpplugname()
3416 * Parse skinvar helpplugname
3421 public function parse_helpplugname()
3423 $plugid = intGetVar('plugid');
3424 Entity::hsc($manager->getPluginNameFromPid($plugid));
3429 * AdminActions::parse_ilistaddnew()
3430 * Parse skinvar ilistaddnew
3435 public function parse_ilistaddnew()
3437 $blogid = intRequestVar('blogid');
3438 if ( intPostVar('start') == 0 )
3440 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3446 * AdminActions::parse_importskininfo()
3447 * Parse skinvar importskininfo
3449 * @param string $type name of information for imported skin
3452 public function parse_importskininfo($type)
3457 echo Entity::hsc(requestVar('skininfo'));
3460 $dataArr = requestArray('skinnames');
3461 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3464 $dataArr = requestArray('tpltnames');
3465 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3468 $dataArr = requestArray('skinclashes');
3469 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3472 $dataArr = requestArray('tpltclashes');
3473 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3476 echo Entity::hsc(requestVar('skinfile'));
3479 echo Entity::hsc(requestVar('mode'));
3486 * AdminActions::parse_inputyesno()
3487 * Parse skinvar inputyesno
3489 * some init stuff for all forms
3494 public function parse_init()
3499 if ( requestVar('action') == 'itemedit' )
3501 $authorid = Admin::$item['authorid'];
3504 Admin::$blog->insertJavaScriptInfo($authorid);
3509 * AdminActions::parse_inputyesno()
3510 * Parse skinvar inputyesno
3512 * @param string $name
3513 * @param string $checkedval
3514 * @param string $tabindex
3515 * @param string $value1
3516 * @param string $value2
3517 * @param string $yesval
3518 * @param string $noval
3519 * @param string $isAdmin
3520 * @param string $templateName
3523 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3525 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3530 * AdminActions::parse_insertpluginfo()
3531 * Parse templatevar insertpluginfo
3533 public function parse_insertpluginfo($type)
3535 $option = Admin::getAdminaOption();
3539 return $option['pid'];
3542 return Entity::hsc($option['pfile']);
3549 * AdminActions::parse_insplugoptcontent()
3550 * Parse skinvar insplugoptcontent
3555 public function parse_insplugoptcontent()
3557 $option = Admin::getAdminaOption();
3559 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3560 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3563 listplug_plugOptionRow($option);
3570 * AdminActions::parse_iprangeinput()
3571 * Parse skinvar iprangeinput
3576 public function parse_iprangeinput()
3578 if ( requestVar('ip') )
3580 $iprangeVal = Entity::hsc(requestVar('ip'));
3581 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3582 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3583 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3584 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3585 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3589 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3590 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3596 * AdminActions::parse_itemnavlist()
3597 * Parse skinvar itemnavlist
3602 public function parse_itemnavlist($templateName)
3604 global $CONF, $manager, $member;
3606 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3607 . " FROM %s, %s, %s, %s"
3608 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3610 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3612 if ( $this->skintype == 'itemlist' )
3615 if ( array_key_exists('blogid', $_REQUEST) )
3617 $blogid = intRequestVar('blogid');
3619 else if ( array_key_exists('itemid', $_REQUEST) )
3621 $itemid = intRequestVar('itemid');
3622 $item = &$manager->getItem($itemid, 1, 1);
3623 $blogid = (integer) $item['blogid'];
3625 $blog =& $manager->getBlog($blogid);
3627 $query .= " AND iblog={$blogid}";
3628 $template['now'] = $blog->getCorrectTime(time());
3630 // non-blog-admins can only edit/delete their own items
3631 if ( !$member->blogAdminRights($blogid) )
3633 $query .= ' AND iauthor = ' . $member->getID();
3636 elseif ( $this->skintype == 'browseownitems' )
3638 $query .= ' AND iauthor = ' . $member->getID();
3640 $template['now'] = time();
3643 // search through items
3644 $search = postVar('search');
3646 if ( !empty($search) )
3648 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3649 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3650 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3653 if ( postVar('start') )
3655 $start = intPostVar('start');
3662 // amount of items to show
3663 if ( postVar('amount') )
3665 $amount = intPostVar('amount');
3669 $amount = (integer) $CONF['DefaultListSize'];
3676 $query .= ' ORDER BY itime DESC'
3677 . " LIMIT {$start},{$amount}";
3679 $template['content'] = 'itemlist';
3681 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3682 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3687 * AdminActions::parse_itemtime()
3688 * date change on edit item
3690 * @param string $key key of PHP's getDate()
3693 public function parse_itemtime($key)
3698 $itemid = intRequestVar('itemid');
3699 $item =& $manager->getItem($itemid, 1, 1);
3701 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3703 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3705 $item['body'] = removeBreaks($item['body']);
3706 $item['more'] = removeBreaks($item['more']);
3709 $contents = array();
3710 if ( requestVar('action') == 'itemedit' )
3714 elseif ( requestVar('action') == 'createitem' )
3717 'contents' => &$contents,
3718 'blog' => &$this->blog
3720 $manager->notify('PreAddItemForm', $data);
3722 $itemtime = getdate($contents['timestamp']);
3723 echo $itemtime[$key];
3728 * AdminActions::parse_jstoolbaroptions()
3729 * Parse skinvar jstoolbaroptions
3734 public function parse_jstoolbaroptions()
3738 _SETTINGS_JSTOOLBAR_NONE,
3739 _SETTINGS_JSTOOLBAR_SIMPLE,
3740 _SETTINGS_JSTOOLBAR_FULL
3744 foreach ( $options as $option )
3746 $text = "<option value=\"%d\"%s>%s</option>\n";
3747 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3748 echo sprintf($text, $i, $extra, $option);
3754 * AdminActions::parse_localeselectoptions()
3755 * Parse skinvar localeselectoptions
3760 public function parse_localeselectoptions()
3762 $locales = i18n::get_available_locale_list();
3764 $memid = intRequestVar('memberid');
3767 $mem = MEMBER::createFromID($memid);
3768 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3770 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3774 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3779 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3781 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3785 echo "<option value=\"\">en_Latn_US</option>\n";
3788 foreach ( $locales as $locale )
3790 if ( $locale == 'en_Latn_US' )
3796 if ( $locale == $mem->getLocale() )
3798 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3802 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3807 if ( $locale == i18n::get_current_locale() )
3809 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3813 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3821 * AdminActions::parse_listplugplugoptionrow()
3822 * Parse templatevar listplugplugoptionrow
3824 * @param string $templateName name of template
3827 public function parse_listplugplugoptionrow($templateName = '')
3829 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3834 * AdminActions::parse_mediadirwarning()
3835 * Parse skinvar mediadirwarning
3840 public function parse_mediadirwarning()
3843 if ( !is_dir($DIR_MEDIA) )
3845 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3847 if ( !is_readable($DIR_MEDIA) )
3849 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3851 if ( !is_writeable($DIR_MEDIA) )
3853 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3859 * AdminActions::parse_movedistselect()
3860 * Parse skinvar movedistselect
3862 public function parse_movedistselect()
3864 $actionType = requestVar('action');
3865 switch ( $actionType )
3868 $this->selectBlog('destcatid', 'category');
3870 case 'batchcategory':
3871 $this->selectBlog('destblogid');
3874 if ( $this->skintype == 'itemmove' )
3876 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3877 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3878 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3879 $this->selectBlog('catid', 'category', $catid, 10, 1);
3887 * AdminActions::parse_moveitemid()
3888 * Parse skinvar moveitemid
3893 public function parse_moveitemid()
3895 echo intRequestVar('itemid');
3900 * AdminActions::parse_newestcompare()
3901 * Parse skinvar newestcompare
3906 public function parse_newestcompare()
3910 $newestVersion = getLatestVersion();
3911 $newestCompare = str_replace('/', '.', $newestVersion);
3912 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3914 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3916 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3917 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3923 * AdminActions::parse_newmemberselect()
3924 * Parse skinvar newmemberselect
3926 * @param string $templateName name of template to use
3929 public function parse_newmemberselect($templateName = '')
3931 $blogid = intRequestVar('blogid');
3933 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3934 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3935 $res = DB::getResult($query);
3938 foreach ( $res as $row )
3940 $tmem[] = intval($row['tmember']);
3943 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3944 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3947 'name' => 'memberid',
3948 'tabindex' => 10000,
3951 Showlist($query, 'select', $template, $templateName);
3956 * AdminActions::parse_newpluginlist()
3957 * Parse skinvar newpluginlist
3962 public function parse_newpluginlist()
3964 $candidates = $this->newPlugCandidates;
3965 foreach ( $candidates as $name )
3967 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3973 * AdminActions::parse_outputspecialdirs()
3974 * Parse skinvar outputspecialdirs
3976 * @param string $type type of setting for directory
3979 public function parse_outputspecialdirs($type)
3981 global $DIR_MEDIA, $DIR_NUCLEUS;
3986 echo Entity::hsc($DIR_NUCLEUS);
3989 echo Entity::hsc($DIR_MEDIA);
3996 * AdminActions::parse_passrequestvars()
3997 * Parse skinvar passrequestvars
4002 public function parse_passrequestvars()
4004 $passvar = Admin::getAdminpassvar();
4005 $oldaction = postVar('oldaction');
4007 if ( ($oldaction != 'logout')
4008 && ($oldaction != 'login')
4010 && !postVar('customaction') )
4018 * AdminActions::parse_pluginextras()
4019 * Parse skinvar pluginextras
4021 * @param string $type type of plugin context
4024 public function parse_pluginextras($type = 'global')
4030 $id = intRequestVar('memberid');
4031 $mem = MEMBER::createFromID($id);
4032 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4035 $id = intRequestVar('blogid');
4036 $blg = $manager->getBlog($id);
4037 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4039 case 'createaccount':
4041 'type' => 'createaccount.php',
4043 'postlabel' => '<br />',
4045 'postfield' => '<br /><br />'
4047 $manager->notify('RegistrationFormExtraFields', $data);
4050 $manager->notify('GeneralSettingsFormExtras', array());
4057 * AdminActions::parse_pluginhelp()
4058 * Parse skinvar pluginhelp
4063 public function parse_pluginhelp()
4065 global $manager, $DIR_PLUGINS;
4067 $plugid = intGetVar('plugid');
4068 $plugName = $manager->getPluginNameFromPid($plugid);
4069 $plug =& $manager->getPlugin($plugName);
4071 if ( $plug->supportsFeature('HelpPage') > 0 )
4073 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4074 if ( @file_exists($helpfile . 'php') )
4076 @include($helpfile . 'php');
4079 elseif ( @file_exists($helpfile . 'html') )
4081 @include($helpfile . 'html');
4085 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4086 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4091 * AdminActions::parse_pluginlistlist()
4092 * Parse skinvar pluginlistlist
4094 * @param string $templateName name of template to use
4097 public function parse_pluginlistlist($templateName = '')
4099 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4100 $query = sprintf($query, sql_table('plugin'));
4102 $template['content'] = 'pluginlist';
4103 $template['tabindex'] = 10;
4105 Showlist($query, 'table', $template, $templateName);
4111 * AdminActions::parse_pluginoptions()
4112 * Parse skinvar pluginoptions
4114 * @param string $type type of plugin option
4117 public function parse_pluginoptions($context='global', $templateName='')
4119 global $itemid, $manager;
4124 $contextid = intRequestVar('memberid');
4127 $contextid = intRequestVar('blogid');
4130 $contextid = intRequestVar('catid');
4133 $contextid = $itemid;
4137 /* Actually registererd plugin options */
4138 $aIdToValue = array();
4139 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4140 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4141 $res = DB::getResult($query);
4142 foreach ( $res as $row )
4144 $aIdToValue[$row['oid']] = $row['ovalue'];
4147 /* Currently available plugin options */
4148 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4149 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4150 $res = DB::getResult($query);
4153 foreach ($res as $row )
4155 if ( !array_key_exists($row['oid'], $aIdToValue) )
4157 $value = $row['odef'];
4161 $value = $aIdToValue[$row['oid']];
4165 'pid' => $row['pid'],
4166 'pfile' => $row['pfile'],
4167 'oid' => $row['oid'],
4169 'name' => $row['oname'],
4170 'description' => $row['odesc'],
4171 'type' => $row['otype'],
4172 'typeinfo' => $row['oextra'],
4173 'contextid' => $contextid,
4179 'context' => $context,
4180 'contextid' => $contextid,
4181 'options' => &$options
4183 $manager->notify('PrePluginOptionsEdit', $data);
4185 $template = array();
4186 if ( $templateName )
4188 $templates = Template::read($templateName);
4189 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4191 $template['title'] = "<tr>"
4192 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4197 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4200 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4202 $template['body'] = "<tr>"
4203 . "<%listplugplugoptionrow%>"
4208 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4214 include_libs('ACTIONS.php');
4215 $handler = new Actions($this->skintype);
4216 $parser = new PARSER($handler);
4218 foreach ( $options as $option )
4221 if ( $prevPid != $option['pid'] )
4223 $prevPid = $option['pid'];
4224 $parser->parse($template['title']);
4227 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4229 if ( @$meta['access'] != 'hidden' )
4231 $parsed = $parser->parse($template['body']);
4239 * AdminActions::parse_qmenuaddselect()
4240 * Parse skinvar qmanuaddselect
4242 * @param string $templateName name of template to use
4245 public function parse_qmenuaddselect($templateName = '')
4248 $showAll = requestVar('showall');
4249 if ( $member->isAdmin() && ($showAll == 'yes') )
4251 // Super-Admins have access to all blogs! (no add item support though)
4252 $query = 'SELECT bnumber as value, bname as text'
4253 . ' FROM ' . sql_table('blog')
4254 . ' ORDER BY bname';
4258 $query = 'SELECT bnumber as value, bname as text'
4259 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4260 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4261 . ' ORDER BY bname';
4264 $template['name'] = 'blogid';
4265 $template['tabindex'] = 15000;
4266 $template['extra'] = _QMENU_ADD_SELECT;
4267 $template['selected'] = -1;
4268 $template['shorten'] = 10;
4269 $template['shortenel'] = '';
4270 $template['javascript'] = 'onchange="return form.submit()"';
4272 Showlist($query, 'select', $template, $templateName);
4278 * AdminActions::parse_quickmenu()
4279 * Parse skinvar quickmenu
4281 * @param string $templateName name of template to use
4284 public function parse_quickmenu($templateName = '')
4287 $templates = array();
4288 $template = array();
4289 if ( !empty($templateName) )
4291 $templates = Template::read($templateName);
4293 $pluginExtras = array();
4297 'options' => &$pluginExtras
4300 if ( count($pluginExtras) > 0 )
4302 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4304 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4308 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4310 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4312 $template['head'] = "<ul>\n";
4316 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4318 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4320 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4324 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4326 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4328 $template['foot'] = "</ul>\n";
4332 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4335 $handler = new Actions($this->skintype);
4336 $parser = new PARSER($handler);
4338 $parser->parse($template['title']);
4339 echo $template['head'];
4340 foreach ( $pluginExtras as $aInfo )
4343 'plugadminurl' => Entity::hsc($aInfo['url']),
4344 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4345 'plugadmintitle' => Entity::hsc($aInfo['title']),
4347 echo Template::fill($template['body'], $data);
4349 echo $template['foot'];
4355 * AdminActions::parse_requestblogid()
4356 * Parse skinvar requestblogid
4361 public function parse_requestblogid()
4363 echo intRequestVar('blogid');
4368 * AdminActions::parse_requestiprange()
4369 * Parse skinvar requestiprange
4374 public function parse_requestiprange()
4376 if ( requestVar('iprange') )
4378 echo Entity::hsc(requestVar('iprange'));
4380 elseif ( requestVar('ip') )
4382 echo Entity::hsc(requestVar('ip'));
4388 * AdminActions::parse_selectlocaladminskinfiles()
4389 * Parse skinvar selectlocaladminskinfiles
4394 public function parse_selectlocaladminskinfiles()
4396 global $DIR_SKINS, $manager;
4398 $adminskindir = $DIR_SKINS . 'admin/';
4399 $candidates = SkinImport::searchForCandidates($adminskindir);
4401 foreach ( $candidates as $skinname => $skinfile )
4403 $html = Entity::hsc($skinfile);
4404 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4411 * AdminActions::parse_selectlocalskinfiles()
4412 * Parse skinvar selectlocalskinfiles
4417 public function parse_selectlocalskinfiles()
4421 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4423 foreach ( $candidates as $skinname => $skinfile )
4425 $html = Entity::hsc($skinfile);
4426 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4433 * AdminActions::parse_skineditallowedlist()
4434 * Parse skinvar skineditallowedlist
4436 * @param string $type type of skin
4437 * @param string $templateName name of template
4440 public function parse_skineditallowedlist($type, $templateName = '')
4445 $query = "SELECT bshortname, bname FROM %s;";
4447 'content' => 'shortblognames'
4449 $query = sprintf($query, sql_table('blog'));
4450 Showlist($query, 'table', $show, $templateName);
4453 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4455 'content' => 'shortnames'
4457 $query = sprintf($query, sql_table('template_desc'));
4458 Showlist($query, 'table', $show, $templateName);
4465 * AdminActions::parse_skinielist()
4466 * Parse skinvar skinielist
4468 * @param string $type type of skin
4469 * @param string $templateName name of template to use
4472 public function parse_skinielist($type, $templateName = '')
4474 $templates = array();
4475 if ( $templateName )
4477 $templates = Template::read($templateName);
4479 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4481 $template = $templates['SKINIE_EXPORT_LIST'];
4486 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4487 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4489 . "<td><%expdesc%></td>\n"
4496 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4497 foreach ( $res as $row )
4500 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4501 'expid' => 'skinexp' . $row['sdnumber'],
4502 'expname' => Entity::hsc($row['sdname']),
4503 'expdesc' => Entity::hsc($row['sddesc'])
4505 echo Template::fill($template, $data);
4509 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4510 foreach ( $res as $row )
4513 'typeid' => 'template[' . $row['tdnumber'] . ']',
4514 'expid' => 'templateexp' . $row['tdnumber'],
4515 'expname' => Entity::hsc($row['tdname']),
4516 'expdesc' => Entity::hsc($row['tddesc'])
4518 echo Template::fill($template, $data);
4526 * AdminActions::parse_skinoverview()
4527 * Parse skinvar skinoverview
4529 * @param string $templateName name of template to use
4532 public function parse_skinoverview($templateName = '')
4535 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4536 $query = sprintf($query, sql_table('skin_desc'));
4538 $template['content'] = 'skinlist';
4539 $template['tabindex'] = 10;
4541 Showlist($query, 'table', $template, $templateName);
4546 * AdminActions::parse_skintypehelp()
4547 * Check editing skintypehelp
4552 public function parse_skintypehelp()
4554 $nowSkinType = strtolower(trim(requestVar('type')));
4556 /* TODO: use Skin class */
4557 $regularType = array(
4568 if ( in_array($nowSkinType, $regularType) )
4570 help('skinpart' . $nowSkinType);
4574 help('skinpartspecial');
4580 * AdminActions::parse_specialskinlist()
4581 * Parse skinvar specialskinlist
4583 * @param string $templateName name of template to use
4586 public function parse_specialskinlist($templateName = '')
4588 $templates = array();
4589 if ( $templateName )
4591 $templates = Template::read($templateName);
4594 /* TODO: use Skin class */
4605 $skinid = intRequestVar('skinid');
4606 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4607 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4609 $res = DB::getResult($query);
4610 if ( $res && $res->rowCount() > 0 )
4613 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4615 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4619 $template['head'] = "<ul>\n";
4621 echo Template::fill($template['head'], $data);
4622 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4624 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4625 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4626 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4630 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4634 foreach ( $res as $row )
4637 'tabindex' => $tabstart++,
4638 'skinid' => $skinid,
4639 'skintype' => Entity::hsc(strtolower($row['stype']))
4641 echo Template::fill($template['body'], $data);
4644 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4646 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4650 $template['foot'] = "</ul>\n";
4652 echo Template::fill($template['foot'], $data);
4658 * AdminActions::parse_sprinttext()
4661 * @param string $which
4662 * @param string $val
4665 public function parse_sprinttext($which, $val)
4667 if ( !defined($which) )
4673 $base = constant($which);
4676 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4678 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4680 $met = 'parse_' . $matchies[0];
4684 $arg = trim($args[0], '()');
4685 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4688 if ( method_exists($this, $met) )
4690 $value = call_user_func(array(&$this, $met), $arg);
4694 if ( !isset($value) || empty($value) )
4698 echo sprintf($base, $value);
4703 * AdminActions::parse_systemsettings()
4704 * Parse skinvar systemsettings
4706 * @param string $type type of settings for system
4707 * @param string $templateName name of template to use
4710 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4712 global $member, $CONF, $nucleus;
4714 $member->isAdmin() or Admin::disallow();
4716 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4717 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4724 case 'sqlserverinfo':
4725 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4727 case 'sqlclientinfo':
4728 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4730 case 'magicquotesgpc':
4731 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4733 case 'magicquotesruntime':
4734 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4736 case 'registerglobals':
4737 echo ini_get('register_globals') ? 'On' : 'Off';
4740 $templates = array();
4741 if ( $templateName )
4743 $templates = Template::read($templateName);
4745 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4747 $template = "<tr>\n"
4748 . "<td><%key%></td>\n"
4749 . "<td><%value%></td>\n"
4754 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4757 $gdinfo = gd_info();
4759 foreach ( $gdinfo as $key => $value )
4761 if ( is_bool($value) )
4763 $value = $value ? $enable : $disable;
4767 $value = Entity::hsc($value);
4773 echo Template::fill($template, $data);
4778 phpinfo(INFO_MODULES);
4779 $im = ob_get_contents();
4781 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4783 case 'nucleusversion':
4784 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4786 case 'nucleuspatchlevel':
4787 echo getNucleusPatchLevel();
4793 echo $CONF['ItemURL'];
4795 case 'alertonheaderssent':
4796 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4798 case 'nucleuscodename':
4799 if ( $nucleus['codename'] != '' )
4801 echo ' "' . $nucleus['codename'] . '"';
4804 case 'versioncheckurl':
4805 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4812 * AdminActions::parse_templateoverview()
4813 * Parse skinvar templateoverview
4815 * @param string $templateName name of template to use
4818 public function parse_templateoverview($templateName = '')
4820 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4821 $query = sprintf($query, sql_table('template_desc'));
4823 $template['content'] = 'templatelist';
4824 $template['tabindex'] = 10;
4826 Showlist($query, 'table', $template, $templateName);
4832 * AdminActions::parse_ticket()
4838 public function parse_ticket()
4841 $manager->addTicketHidden();
4846 * AdminActions::parse_versioncheckurl()
4847 * Parse skinvar versioncheckurl
4852 public function parse_versioncheckurl()
4854 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4859 * AdminActions::parse_yrbloglist()
4860 * Parse skinvar yrbloglist
4862 * @param string $templateName name of template to use
4865 public function parse_yrbloglist($templateName = '')
4868 $showAll = requestVar('showall');
4870 if ( $member->isAdmin() && ($showAll == 'yes') )
4872 // Super-Admins have access to all blogs! (no add item support though)
4873 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4875 . " ORDER BY bnumber;";
4876 $query = sprintf($query, sql_table('blog'));
4880 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4882 . " WHERE tblog=bnumber and tmember=%d"
4883 . " ORDER BY bnumber;";
4884 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4887 $template['content'] = 'bloglist';
4888 $template['superadmin'] = $member->isAdmin();
4890 $amount = Showlist($query, 'table', $template, $templateName);
4892 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4894 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4896 $total = DB::getValue($query);
4897 if ( $total > $amount )
4899 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4905 echo _OVERVIEW_NOBLOGS;
4907 elseif( $amount != 0 )
4909 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4911 $query = "SELECT ititle, inumber, bshortname"
4913 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4914 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4916 $template['content'] = 'draftlist';
4918 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4919 if ( $amountdrafts == 0 )
4921 echo _OVERVIEW_NODRAFTS;
4928 * AdminActions::checkCondition()
4929 * Checks conditions for if statements
4931 * @param string $field type of <%if%>
4932 * @param string $name property of field
4933 * @param string $value value of property
4934 * @return boolean condition
4936 protected function checkCondition($field, $name='', $value = '')
4938 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4948 $blog =& $manager->getBlog($blogid);
4952 $blogid = getBlogIDFromCatID($catid);
4953 $blog =& $manager->getBlog($blogid);
4955 elseif ( intRequestVar('catid') )
4957 $catid = intRequestVar('catid');
4958 $blogid = getBlogIDFromCatID($catid);
4959 $blog =& $manager->getBlog($blogid);
4966 $condition = ($blog && $this->ifCategory($name, $value));
4969 $condition = $member->isLoggedIn();
4972 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4975 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4978 $condition = $member->isLoggedIn() && $member->isAdmin();
4980 case 'allowloginedit':
4981 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4984 $condition = ($itemidnext != '');
4987 $condition = ($itemidprev != '');
4989 case 'archiveprevexists':
4990 $condition = ($archiveprevexists == true);
4992 case 'archivenextexists':
4993 $condition = ($archivenextexists == true);
4996 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4999 $condition = $this->ifHasPlugin($name, $value);
5002 $condition = (Admin::getAdminAction() == $name);
5004 case 'adminoldaction':
5005 $condition = (Admin::getAdminAction() == $name);
5007 case 'addresschange':
5008 $condition = ($this->ifAddresscange());
5010 case 'bechangepass':
5011 $condition = ($this->beChangePassword());
5013 case 'skincandidates':
5014 $condition = ($this->ifSkincandidates());
5017 $condition = requestVar('nameclashes');
5019 case 'existsnewplugin':
5020 $condition = ($this->existsNewPlugin());
5027 $condition = (boolean) ($member->getAutosave() == $value);
5034 $condition = (Admin::$blog->getSetting($name) == $value);
5036 case 'itemproperty':
5041 if ( array_key_exists($name, Admin::$item) )
5043 $condition = (boolean) (Admin::$item[$name] == $value);
5047 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5054 * AdminActions::_ifHasPlugin()
5055 * hasplugin,PlugName
5056 * -> checks if plugin exists
5057 * hasplugin,PlugName,OptionName
5058 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5059 * hasplugin,PlugName,OptionName=value
5060 * -> checks if the option OptionName from plugin PlugName is set to value
5062 * @param string $name name of plugin
5063 * @param string $value
5066 private function ifHasPlugin($name, $value)
5070 // (pluginInstalled method won't write a message in the actionlog on failure)
5071 if ( $manager->pluginInstalled("NP_{$name}") )
5073 $plugin =& $manager->getPlugin("NP_{$name}");
5074 if ( $plugin != NULL )
5082 list($name2, $value2) = preg_split('#=#', $value, 2);
5083 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5087 else if ( $plugin->getOption($name2) == $value2 )
5098 * AdminActions::beChangePassword()
5103 private function beChangePassword()
5105 return intRequestVar('bNeedsPasswordChange');
5109 * AdminActions::ifSkincandidates()
5110 * Checks if a plugin exists and call its doIf function
5116 private function ifSkincandidates()
5119 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5120 return (count($candidates) > 0);
5124 * AdminActions::ifPlugin()
5125 * Checks if a plugin exists and call its doIf function
5127 * @param string $name name of plugin
5128 * @param string $key
5129 * @param string $value
5132 private function ifPlugin($name, $key = '', $value = '')
5136 $plugin =& $manager->getPlugin("NP_{$name}");
5142 $params = func_get_args();
5143 array_shift($params);
5145 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5149 * AdminActions::ifCategory()
5150 * Different checks for a category
5152 * @param string $key key for information of category
5153 * @param string $value value for information of category
5156 private function ifCategory($key = '', $value='')
5158 global $blog, $catid;
5160 // when no parameter is defined, just check if a category is selected
5161 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5163 return $blog->isValidCategory($catid);
5166 // check category name
5167 if ( $key == 'catname' )
5169 $value = $blog->getCategoryIdFromName($value);
5170 if ($value == $catid)
5172 return $blog->isValidCategory($catid);
5176 // check category id
5177 if (($key == 'catid') && ($value == $catid))
5179 return $blog->isValidCategory($catid);
5186 * AdminActions::ifOnTeam()
5187 * Checks if a member is on the team of a blog and return his rights
5189 * @param string $blogName name of weblog
5192 private function ifOnTeam($blogName = '')
5194 global $blog, $member, $manager;
5196 // when no blog found
5197 if ( ($blogName == '') && !is_object($blog) )
5202 // explicit blog selection
5203 if ($blogName != '')
5205 $blogid = getBlogIDFromName($blogName);
5208 if (($blogName == '') || !$manager->existsBlogID($blogid))
5211 $blogid = $blog->getID();
5213 return $member->teamRights($blogid);
5217 * AdminActions::ifAdmin()
5218 * Checks if a member is admin of a blog
5220 * @param string $blogName name of weblog
5223 private function ifAdmin($blogName = '')
5225 global $blog, $member, $manager;
5227 // when no blog found
5228 if (($blogName == '') && (!is_object($blog)))
5233 // explicit blog selection
5234 if ($blogName != '')
5236 $blogid = getBlogIDFromName($blogName);
5239 if (($blogName == '') || !$manager->existsBlogID($blogid))
5242 $blogid = $blog->getID();
5245 return $member->isBlogAdmin($blogid);
5249 * AdminActions::ifAddresscange()
5250 * Check e-Mail address is changed
5255 private function ifAddresscange()
5257 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5262 $info = MEMBER::getActivationInfo($key);
5267 $mem = MEMBER::createFromId($info->vmember);
5272 if ( $info->vtype == 'addresschange' )
5280 * AdminActions::templateEditRow()
5283 * @param array $template
5284 * @param string $desc
5285 * @param string $name
5286 * @param string $help
5287 * @param integer $tabindex
5288 * @param boolean $big
5289 * @param array $tmplt
5292 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5296 if ( !array_key_exists($name, $template) )
5298 $template[$name] = '';
5306 $tmplt = skinableTEMPLATE::read($tplt);
5310 'description' => $desc,
5311 'help' => empty($help) ? '' : helpHtml('template' . $help),
5314 'tabindex' => $tabindex,
5315 'rows' => $big ? 10 : 5,
5318 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5320 $base['head'] = "</tr>"
5322 . "<td><%description%><%help%></td>\n"
5323 . "<td id=\"td<%count%>\">\n"
5324 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5328 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5331 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5333 $base['tail'] = "</textarea>\n"
5338 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5341 echo TEMPLATE::fill($base['head'], $data);
5342 echo ENTITY::hsc($template[$name]);
5343 echo TEMPLATE::fill($base['tail'], $data);
5351 * AdminActions::customHelp()
5352 * shows a link to custom help file
5355 * @param string $tplName
5356 * @param string $url
5357 * @param string $iconURL
5358 * @param string $alt
5359 * @param string $title
5363 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5365 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5369 * AdminActions::customHelp()
5370 * shows a link to custom help file
5373 * @param string $tplName
5374 * @param string $url
5375 * @param string $iconURL
5376 * @param string $alt
5377 * @param string $title
5381 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5385 $templates = array();
5389 $templates = Template::read($tplName);
5392 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5394 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5398 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5403 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5406 if ( empty($onclick) )
5408 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5410 elseif ( preg_match('#^onclick#', $onclick) )
5412 $onclick = $onclick;
5416 $onclick = 'onclick="' . $onclick . '"';
5421 'helptarget' => $id,
5422 'onclick' => $onclick,
5423 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5425 return Template::fill($template, $data);
5429 * AdminActions::customHelpHtml()
5432 * @param string $tplName
5433 * @param string $url
5434 * @param string $iconURL
5435 * @param string $alt
5436 * @param string $title
5437 * @param string $onclick
5438 * @return string anchor element with help uri
5440 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5444 $templates = array();
5448 $templates = Template::read($tplName);
5450 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5452 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5456 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5459 if ( empty($iconURL) )
5461 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5464 if ( function_exists('getimagesize') )
5466 $size = getimagesize($iconURL);
5467 $width = 'width="' . $size[0] . '" ';
5468 $height = 'height="' . $size[1] . '" ';
5472 'iconurl' => $iconURL,
5474 'height' => $height,
5475 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5476 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5479 $icon = Template::fill($template, $data);
5480 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5482 return $help . $icon;
5486 * AdminActions::input_yesno
5489 * @param $checkedval
5496 * @param $templateName
5499 public function input_yesno($name,
5510 $templates = array();
5511 if ( $templateName )
5513 $templates = Template::read($templateName);
5516 if ( $name == 'admin' )
5518 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5520 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5521 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5522 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5523 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5527 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5532 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5534 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5538 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5540 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5543 if ( !isset($template) )
5545 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5546 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5547 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5548 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5553 $id = Entity::hsc($name);
5554 $id = str_replace('[', '-', $id);
5555 $id = str_replace(']', '-', $id);
5556 $id1 = $id . Entity::hsc($value1);
5557 $id2 = $id . Entity::hsc($value2);
5559 'name' => Entity::hsc($name),
5560 'yesval' => Entity::hsc($value1),
5561 'noval' => Entity::hsc($value2),
5564 'yesvaltext' => $yesval,
5565 'novaltext' => $noval,
5566 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5567 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5568 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5573 return Template::fill($template, $dat);
5577 echo Template::fill($template, $dat);
5583 * AdminActions::existsNewPlugin()
5584 * Check exists new plugin
5587 * @return boolean exists or not
5589 private function existsNewPlugin()
5591 global $DIR_PLUGINS;
5593 $query = "SELECT * FROM %s;";
5594 $query = sprintf($query, sql_table('plugin'));
5595 $res = DB::getResult($query);
5597 $installed = array();
5598 foreach( $res as $row )
5600 $installed[] = $row['pfile'];
5603 $files = scandir($DIR_PLUGINS);
5605 $candidates = array();
5606 foreach ( $files as $file )
5608 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5610 if ( !in_array($matches[1], $installed) )
5612 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5616 $this->newPlugCandidates = $candidates;
5617 return (count($candidates) > 0);
5621 * AdminActions::pagehead()
5622 * Output admin page head
5627 public function parse_pagehead()
5629 global $member, $nucleus, $CONF, $manager;
5631 $extrahead = Admin::getAdminextrahead();
5633 'extrahead' => &$extrahead,
5634 'action' => Admin::getAdminAction()
5636 $manager->notify('AdminPrePageHead', $data);
5638 $content = $this->parser->skin->getContentFromDB('pagehead');
5641 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5645 if ( !array_key_exists('AdminCSS', $CONF) )
5647 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5648 $CONF['AdminCSS'] = 'original';
5652 /* HTTP 1.1 application for no caching */
5653 header("Cache-Control: no-cache, must-revalidate");
5654 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5656 $root_element = 'html';
5657 $charset = i18n::get_current_charset();
5658 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5659 $xml_version_info = self::$xml_version_info;
5660 $formal_public_identifier = self::$formal_public_identifier;
5661 $system_identifier = self::$system_identifier;
5662 $xhtml_namespace = self::$xhtml_namespace;
5664 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5665 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5666 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5668 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5671 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5673 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5674 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5675 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5676 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5677 echo "{$extrahead}\n";
5680 echo "<div id=\"adminwrapper\">\n";
5681 echo "<div class=\"header\">\n";
5682 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5684 echo "<div id=\"container\">\n";
5685 echo "<div id=\"content\">\n";
5686 echo "<div class=\"loginname\">\n";
5688 if ( !$member->isLoggedIn() )
5690 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5694 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5695 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5698 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5701 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5703 $codenamestring = '';
5707 $codenamestring = ' "' . $nucleus['codename'].'"';
5710 if ( $member->isLoggedIn() && $member->isAdmin() )
5712 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5713 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5715 $newestVersion = getLatestVersion();
5716 $newestCompare = str_replace('/', '.', $newestVersion);
5717 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5719 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5722 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5723 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5729 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5736 $this->parser->parse($content);
5743 * AdminActionss::pagefoot()
5744 * Output admin page foot include quickmenu
5749 public function parse_pagefoot()
5751 global $action, $member, $manager;
5754 'action' => Admin::getAdminAction()
5756 $manager->notify('AdminPrePageFoot', $data);
5758 $content = $this->parser->skin->getContentFromDB('pagefoot');
5761 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5763 echo '<h2>' . _LOGOUT . "</h2>\n";
5765 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5766 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5770 echo "<div class=\"foot\">\n";
5771 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5773 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5776 echo "<div id=\"quickmenu\">\n";
5778 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5781 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5784 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5785 echo "<form method=\"get\" action=\"index.php\">\n";
5787 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5789 $showAll = requestVar('showall');
5791 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5793 // Super-Admins have access to all blogs! (no add item support though)
5794 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5795 $query = sprintf($query, sql_table('blog'));
5799 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5800 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5802 $template['name'] = 'blogid';
5803 $template['tabindex'] = 15000;
5804 $template['extra'] = _QMENU_ADD_SELECT;
5805 $template['selected'] = -1;
5806 $template['shorten'] = 10;
5807 $template['shortenel'] = '';
5808 $template['javascript'] = 'onchange="return form.submit()"';
5809 showlist($query, 'select', $template);
5814 echo "<h2>{$member->getDisplayName()}</h2>\n";
5816 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5817 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5818 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5821 if ( $member->isAdmin() )
5823 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5825 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5826 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5827 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5828 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5829 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5830 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5831 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5834 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5836 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5837 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5838 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5842 $data = array('options' => array());
5844 $manager->notify('QuickMenu', $data);
5846 if ( count($data['options']) > 0 )
5848 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5850 foreach ( $data['options'] as $option )
5852 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5857 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5860 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5864 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5867 echo "<!-- quickmenu -->\n";
5870 echo "<!-- content -->\n";
5873 echo "<!-- container -->\n";
5876 echo "<!-- adminwrapper -->\n";
5884 $this->parser->skin->parse('pagefoot');
5891 * AdminActions::selectBlog()
5892 * Inserts a HTML select element with choices for all blogs to which the user has access
5893 * mode = 'blog' => shows blognames and values are blogids
5894 * mode = 'category' => show category names and values are catids
5896 * @param string $name
5897 * @param string $mode
5898 * @param integer $selected
5899 * @param integer $tabindex
5900 * @param integer $showNewCat
5901 * @param integer $iForcedBlogInclude ID for weblog always included
5902 * @param $iForcedBlogInclude
5903 * ID of a blog that always needs to be included, without checking if the
5904 * member is on the blog team (-1 = none)
5907 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5909 global $member, $CONF;
5911 // 0. get IDs of blogs to which member can post items (+ forced blog)
5912 $aBlogIds = array();
5913 if ( $iForcedBlogInclude != -1 )
5915 $aBlogIds[] = intval($iForcedBlogInclude);
5918 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5920 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5921 $query = sprintf($query, sql_table('blog'));
5925 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5926 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5929 $rblogids = DB::getResult($query);
5930 foreach ( $rblogids as $row )
5932 if ( $row['bnumber'] != $iForcedBlogInclude )
5934 $aBlogIds[] = intval($row['bnumber']);
5938 if ( count($aBlogIds) == 0 )
5943 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5945 // 1. select blogs (we'll create optiongroups)
5946 // (only select those blogs that have the user on the team)
5947 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5948 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5949 $blogs = DB::getResult($queryBlogs);
5951 if ( $mode == 'category' )
5953 if ( $blogs->rowCount() > 1 )
5957 foreach ( $blogs as $rBlog )
5959 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5961 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5964 // show selection to create new category when allowed/wanted
5967 // check if allowed to do so
5968 if ( $member->blogAdminRights($rBlog['bnumber']) )
5970 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5974 // 2. for each category in that blog
5975 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5976 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5977 $categories = DB::getResult($catQuery);
5978 foreach ( $categories as $rCat )
5980 if ( $rCat['catid'] == $selected )
5982 $selectText = ' selected="selected" ';
5988 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5991 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5999 foreach ( $blogs as $rBlog )
6001 echo '<option value="' . $rBlog['bnumber'] . '"';
6002 if ( $rBlog['bnumber'] == $selected )
6004 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
6008 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";