2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
12 /* NOTE: list of whole available action names for tags
21 'adminskineditallowedlist',
24 'adminskinselectoptions',
25 'adminspecialskinlist',
26 'admintemplateoverview',
27 'allowedadminskinactions',
50 'configsettingsyesno',
53 'defaultadminskintypes',
63 'editadmintemplateinfo',
69 'editplugoptionslist',
85 'insertpluginoptions',
90 'listplugplugoptionrow',
91 'localeselectoptions',
108 'selectlocaladminskinfiles',
109 'selectlocalskinfiles',
110 'skineditallowedlist',
127 * AdminActions::$default_actions
128 * list of whole action names with which this class can deal
130 static private $default_actions = array(
153 * AdminActions::$skin_type_friendly_names
154 * friendly name for wrapped page types
156 static private $default_skin_types = array(
157 'actionlog' => _ADM_SKPRT_ACTIONLOG,
158 'activate' => _ADM_SKPRT_ACTIVATE,
159 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
160 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
161 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
162 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
163 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
164 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
165 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
166 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
167 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
168 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
169 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
170 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
171 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
172 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
173 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
174 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
175 'banlist' => _ADM_SKPRT_BANLIST,
176 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
177 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
178 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
179 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
180 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
181 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
182 'batchitem' => _ADM_SKPRT_BATCHITEM,
183 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
184 'batchmove' => _ADM_SKPRT_BATCHMOVE,
185 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
186 'batchteam' => _ADM_SKPRT_BATCHTEAM,
187 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
188 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
189 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
190 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
191 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
192 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
193 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
194 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
195 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
196 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
197 'createitem' => _ADM_SKPRT_CREATEITEM,
198 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
199 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
200 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
201 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
202 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
203 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
204 'itemedit' => _ADM_SKPRT_ITEMEDIT,
205 'itemlist' => _ADM_SKPRT_ITEMLIST,
206 'itemmove' => _ADM_SKPRT_ITEMMOVE,
207 'login' => FALSE, //missing
208 'manage' => _ADM_SKPRT_MANAGE,
209 'manageteam' => _ADM_SKPRT_MANAGETEAM,
210 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
211 'memberedit' => FALSE, //missing
212 'overview' => _ADM_SKPRT_OVERVIEW,
213 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
214 'pagehead' => _ADM_SKPRT_PAGEHEAD,
215 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
216 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
217 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
218 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
219 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
220 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
221 'skindelete' => _ADM_SKPRT_SKINDELETE,
222 'skinedit' => _ADM_SKPRT_SKINEDIT,
223 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
224 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
225 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
226 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
227 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
228 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
229 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
230 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
231 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
232 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
233 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
234 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
238 * AdminActions::getAvailableSkinTypes()
242 * @return array list of friendly names for page actions
244 static public function getAvailableSkinTypes()
246 return self::$default_skin_types;
250 * AdminActions::getDefaultTypes()
254 * @return array list of friendly names for page actions
256 static public function getDefaultTypes()
258 return self::$default_skin_types;
262 * AdminActions::__construct()
263 * Constructor for a new Actions object
265 * @param string $type
268 public function __construct($type)
270 // call constructor of superclass first
271 parent::__construct();
272 $this->skintype = $type;
273 if ( !class_exists('Navlist') || !class_exists('Batch') )
276 include $DIR_LIBS . 'ENCAPSULATE.php';
282 * AdminActions::getAvailableActions()
285 * @return array allowed actions for the page type
287 public function getAvailableActions()
289 $extra_actions = array();
291 switch ( $this->skintype )
294 $extra_actions = array(
299 $extra_actions = array(
304 case 'activatesetpwd':
305 $extra_actions = array(
309 $extra_actions = array(
315 case 'adminerrorpage':
316 $extra_actions = array(
319 case 'adminskindelete':
320 $extra_actions = array(
324 case 'adminskinedit':
325 $extra_actions = array(
327 'defaultadminskintypes',
328 'adminspecialskinlist',
331 case 'adminskinedittype':
332 $extra_actions = array(
335 'allowedadminskinactions',
336 'adminskineditallowedlist',
339 case 'adminskiniedoimport':
340 $extra_actions = array(
344 case 'adminskinieimport':
345 $extra_actions = array(
349 case 'adminskinieoverview':
350 $extra_actions = array(
351 'selectlocaladminskinfiles',
355 case 'adminskinoverview':
356 $extra_actions = array(
360 case 'adminskinremovetype':
361 $extra_actions = array(
365 case 'admintemplatedelete':
366 $extra_actions = array(
367 'editadmintemplateinfo',
369 case 'admintemplateedit':
370 $extra_actions = array(
371 'editadmintemplateinfo',
374 case 'admntemplateoverview':
375 $extra_actions = array(
376 'admintemplateoverview',
379 case 'backupoverview':
380 $extra_actions = array(
383 case 'backuprestore':
384 $extra_actions = array(
388 $extra_actions = array(
394 case 'banlistdelete':
395 $extra_actions = array(
400 case 'banlistdeleteconfirm':
401 $extra_actions = array(
402 'banlistdeletedlist',
407 $extra_actions = array(
413 case 'batchcategory':
414 $extra_actions = array(
420 $extra_actions = array(
426 $extra_actions = array(
432 $extra_actions = array(
438 $extra_actions = array(
444 $extra_actions = array(
453 $extra_actions = array(
462 $extra_actions = array(
468 case 'blogcommentlist':
469 $extra_actions = array(
475 case 'blogselectbox':
476 $extra_actions = array(
481 $extra_actions = array(
497 $extra_actions = array(
501 case 'browseowncomments':
502 $extra_actions = array(
506 case 'browseownitems':
507 $extra_actions = array(
511 case 'categorydelete':
512 $extra_actions = array(
518 $extra_actions = array(
525 case 'commentdelete':
526 $extra_actions = array(
531 $extra_actions = array(
536 $extra_actions = array(
548 $extra_actions = array(
554 $extra_actions = array(
559 case 'editmembersettings':
560 $extra_actions = array(
561 'adminskinselectoptions',
563 'localeselectoptions',
567 case 'insertpluginoptions':
568 $extra_actions = array(
569 'insertpluginoptions',
572 case 'itemcommentlist':
573 $extra_actions = array(
579 $extra_actions = array(
586 $extra_actions = array(
598 $extra_actions = array(
605 $extra_actions = array(
611 $extra_actions = array(
615 $extra_actions = array(
624 $extra_actions = array(
629 $extra_actions = array(
634 $extra_actions = array(
639 $extra_actions = array(
645 $extra_actions = array(
650 case 'pluginoptions':
651 $extra_actions = array(
653 'editplugoptionslist',
657 $extra_actions = array(
660 'configsettingsedit',
661 'configsettingsyesno',
664 'localeselectoptions',
670 $extra_actions = array(
675 $extra_actions = array(
680 $extra_actions = array(
686 $extra_actions = array(
689 'allowedskinactions',
690 'skineditallowedlist',
691 'skineditallowedlist',
694 case 'skiniedoimport':
695 $extra_actions = array(
700 $extra_actions = array(
704 case 'skinieoverview':
705 $extra_actions = array(
706 'selectlocalskinfiles',
711 $extra_actions = array(
715 case 'skinremovetype':
716 $extra_actions = array(
720 case 'systemoverview':
721 $extra_actions = array(
726 $extra_actions = array(
732 case 'templatedelete':
733 $extra_actions = array(
738 $extra_actions = array(
742 case 'templateoverview':
743 $extra_actions = array(
747 case 'usermanagement':
748 $extra_actions = array(
754 $extra_actions = array(
764 'selectlocaladminskinfiles',
772 $defined_actions = array_merge(self::$default_actions, $extra_actions);
774 return array_merge($defined_actions, parent::getAvailableActions());
778 * AdminActions::parse_actionloglist()
779 * Parse skinvar actionloglist
781 * @param string $templateName name of template to use
784 public function parse_actionloglist($templateName = '')
786 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
787 $query = sprintf($query, sql_table('actionlog'));
789 $template['content'] = 'actionlist';
790 $amount = showlist($query, 'table', $template, $templateName);
796 * AdminActions::parse_activationmessage()
797 * Parse skinvar activationmessage
799 * @param string $type type of message
800 * @param string $templateName name of template to use
803 public function parse_activationmessage($type, $templateName = '')
805 global $CONF, $manager;
809 if ( !empty($templateName))
811 $template = Template::read($templateName);
814 $key = postVar('ackey');
817 Admin::error(_ERROR_ACTIVATE);
820 $info = MEMBER::getActivationInfo($key);
823 Admin::error(_ERROR_ACTIVATE);
826 $mem = MEMBER::createFromId($info->vmember);
829 Admin::error(_ERROR_ACTIVATE);
831 switch ( $info->vtype )
834 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
836 $title = $template['ACTIVATE_FORGOT_TITLE'];
840 $title = _ACTIVATE_FORGOT_TITLE;
842 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
844 $text = $template['ACTIVATE_FORGOT_TEXT'];
848 $text = _ACTIVATE_FORGOT_TEXT;
852 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
854 $title = $template['ACTIVATE_REGISTER_TITLE'];
858 $title = _ACTIVATE_REGISTER_TITLE;
860 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
862 $text = $template['ACTIVATE_REGISTER_TEXT'];
866 $text = _ACTIVATE_REGISTER_TEXT;
869 case 'addresschange':
870 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
872 $title = $template['ACTIVATE_CHANGE_TITLE'];
876 $title = _ACTIVATE_CHANGE_TITLE;
878 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
880 $text = $template['ACTIVATE_CHANGE_TEXT'];
884 $text = _ACTIVATE_CHANGE_TEXT;
889 'memberName' => Entity::hsc($mem->getDisplayName()),
890 'realName' => Entity::hsc($mem->getRealName()),
895 echo Template::fill($title, $aVars);
898 echo Template::fill($text, $aVars);
901 echo Entity::hsc($key);
908 * AdminActions::parse_addtickettourl()
909 * Parse skinvar addtickettourl
911 * @param string $url URI for ticket
914 public function parse_addtickettourl($url)
917 $url = $manager->addTicketToUrl($url);
918 echo Entity::hsc($url);
923 * AdminActions::parse_adminbanlist()
924 * Parse skinvar adminbanlist
926 * @param string $templateName name of template to use
929 public function parse_adminbanlist($templateName = '')
931 $blogid = intRequestVar('blogid');
933 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
934 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
936 $template['content'] = 'banlist';
938 $amount = Showlist($query, 'table', $template, $templateName);
948 * AdminActions::parse_adminbatchaction()
949 * Parse skinvar adminbatchaction
954 public function parse_adminbatchaction()
956 echo Entity::hsc(requestVar('batchaction'));
961 * AdminActions::parse_adminbatchlist()
962 * Parse skinvar adminbatchlist
964 * @param string $templateName name of template to use
967 public function parse_adminbatchlist($templateName = '')
970 $templates = array();
972 if ( !empty($templateName) )
974 $templates = Template::read($templateName);
977 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
979 $template = '<li><%text(_BATCH_EXECUTING)%>'
980 . '<b><%adminbatchaction%></b>'
981 . '<%batchlisttype%>'
982 . '<b><%batchid%></b>...'
983 . '<b><%batchlistmsg%></b>'
988 $template = $templates['ADMIN_BATCHLIST'];
991 $selected = requestIntArray('batch');
992 $action = requestVar('batchaction');
994 switch ( $this->skintype )
997 $batchlisttype = _BATCH_ONITEM;
998 $deleteaction = 'deleteOneItem';
999 $moveaction = 'moveOneItem';
1000 $destid = intRequestVar('destcatid');
1002 case 'batchcomment':
1003 $batchlisttype = _BATCH_ONCOMMENT;
1004 $deleteaction = 'deleteOneComment';
1007 $batchlisttype = _BATCH_ONMEMBER;
1008 $deleteaction = 'deleteOneMember';
1009 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1010 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1011 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1012 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1015 $blogid = intRequestVar('blogid');
1016 $batchlisttype = _BATCH_ONTEAM;
1017 $deleteaction = 'deleteOneTeamMember';
1018 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1019 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1020 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1021 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1023 case 'batchcategory':
1024 $batchlisttype = _BATCH_ONCATEGORY;
1025 $deleteaction = 'deleteOneCategory';
1026 $moveaction = 'moveOneCategory';
1027 $destid = intRequestVar('destblogid');
1031 // walk over all selectedids and perform action
1032 foreach ( $selected as $selectedid )
1035 $selectedid = intval($selectedid);
1039 if ( $this->skintype != 'batchteam' )
1041 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1045 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1049 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1053 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1057 // there should always remain at least one super-admin
1058 $r = DB::getResult($unsetchksql);
1059 if ( $r->rowCount() < 2 )
1061 $error = $unseterrmsg;
1065 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1069 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1073 'batchid' => $selectedid,
1074 'batchlisttype' => Entity::hsc($batchlisttype),
1075 'adminbatchaction' => Entity::hsc($action),
1076 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1079 $handler = new AdminActions('template');
1080 $parser = new Parser($handler);
1083 $parser->parse($template);
1084 $template = ob_get_contents();
1086 echo Template::fill($template, $data);
1092 * AdminActions::parse_adminbloglink()
1093 * Parse skinvar adminbloglink
1095 * @param string $templateName name of template to use
1098 public function parse_adminbloglink($templateName = '')
1101 $blogid = intRequestVar('blogid');
1102 $blog =& $manager->getBlog($blogid);
1103 $templates = array();
1105 if ( !empty($templateName) )
1107 $templates = Template::read($templateName);
1110 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1112 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1116 $template = $templates['ADMIN_BLOGLINK'];
1120 'url' => Entity::hsc($blog->getURL()),
1121 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1122 'blogname' => Entity::hsc($blog->getName())
1125 echo Template::fill($template, $data);
1130 * AdminActions::parse_adminerrormesg()
1131 * Parse skinvar adminerrormesg
1136 public function parse_adminerrormesg()
1141 if ( requestVar('errormessage') )
1143 $message = requestVar('errormessage');
1145 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1147 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1149 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1151 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1153 echo Entity::hsc($message);
1158 * AdminActions::parse_adminskineditallowedlist()
1159 * Parse skinvar adminskineditallowedlist
1161 * @param string $type template/blog
1162 * @param string $templateName name of template to use
1165 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1169 /* TODO: blog seems not to be used */
1171 $query = "SELECT bshortname, bname FROM %s";
1172 $query = sprintf($query, sql_table('blog'));
1174 'content' => 'shortblognames'
1176 Showlist($query, 'table', $show, $templateName);
1179 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1180 $query = sprintf($query, sql_table('template_desc'));
1182 'content' => 'shortnames'
1184 Showlist($query, 'table', $show, $templateName);
1191 * AdminActions::parse_adminskinielist()
1192 * Parse skinvar adminskinielist
1194 * @param string $type skin/template
1195 * @param string $templateName name of template to use
1198 public function parse_adminskinielist($type, $templateName = '')
1200 $templates = array();
1201 if ( $templateName )
1203 $templates = Template::read($templateName);
1206 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1209 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1210 . "<label for=\"<%expid%>\"><%expname%></label>"
1212 . "<td><%expdesc%></td>\n"
1218 $template = $templates['SKINIE_EXPORT_LIST'];
1224 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1225 $query = sprintf($query, sql_table('skin_desc'));
1226 $res = DB::getResult($query);
1228 foreach ( $res as $row )
1231 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1232 'expid' => 'skinexp' . $row['sdnumber'],
1233 'expname' => Entity::hsc($row['sdname']),
1234 'expdesc' => Entity::hsc($row['sddesc']),
1236 echo Template::fill($template, $data);
1240 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1241 $query = sprintf($query, sql_table('template_desc'));
1242 $res = DB::getResult($query);
1243 foreach ( $res as $row )
1246 'typeid' => 'template[' . $row['tdnumber'] . ']',
1247 'expid' => 'templateexp' . $row['tdnumber'],
1248 'expname' => Entity::hsc($row['tdname']),
1249 'expdesc' => Entity::hsc($row['tddesc']),
1251 echo Template::fill($template, $data);
1259 * AdminActions::parse_adminskinoverview()
1260 * Parse skinvar adminskinoverview
1262 * @param string $templateName name of template to use
1265 public function parse_adminskinoverview($templateName = '')
1267 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1268 $query = sprintf($query, sql_table('skin_desc'));
1270 $template['content'] = 'adminskinlist';
1271 $template['tabindex'] = 10;
1272 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1273 Showlist($query, 'table', $template, $templateName);
1278 * AdminActions::parse_adminskinselectoptions()
1279 * Parse skinvar adminskinselectoptions
1284 public function parse_adminskinselectoptions()
1287 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1288 $query = sprintf($query, sql_table('skin_desc'));
1290 $template['name'] = 'adminskin';
1291 $template['selected'] = $CONF['AdminSkin'];
1292 $template['tabindex'] = 110;
1293 Showlist($query, 'select', $template, '');
1298 * AdminActions::parse_adminspecialskinlist()
1299 * Parse skinvar adminspecialskinlist
1301 * @param string $templateName name of template to use
1303 public function parse_adminspecialskinlist($templateName = '')
1305 $templates = array();
1306 if ( $templateName )
1308 $templates = Template::read($templateName);
1311 $nType = $this->parser->skin->getAvailableTypes();
1312 $skinid = intRequestVar('skinid');
1314 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1315 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1317 $res = DB::getResult($query);
1318 if ( $res && $res->rowCount() > 0 )
1320 /* NOTE: set templates for HEAD/BODY/FOOT */
1321 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1323 $template['head'] = "<ul>\n";
1327 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1329 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1331 $template['body'] = '<li>'
1332 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1335 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1342 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1344 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1346 $template['foot'] = "</ul>\n";
1350 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1357 echo $template['head'];
1358 foreach ( $res as $row )
1361 'tabindex' => $tabstart++,
1362 'skinid' => $skinid,
1363 'skintype' => Entity::hsc(strtolower($row['stype']))
1365 echo Template::fill($template['body'], $data);
1368 echo $template['foot'];
1374 * AdminActions::parse_admintemplateoverview()
1375 * Parse skinvar admintemplateoverview
1377 * @param string $templateName name of template to use
1380 public function parse_admintemplateoverview($templateName = '')
1382 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1383 $query = sprintf($query, sql_table('template_desc'));
1385 $template['content'] = 'admintemplatelist';
1386 $template['tabindex'] = 10;
1388 Showlist($query, 'table', $template, $templateName);
1393 * AdminActions::parse_allowedadminskinactions()
1394 * Parse skinvar allowedadminskinactions
1399 public function parse_allowedadminskinactions()
1401 global $DIR_ADMINSKINS;
1402 $skinType = strtolower(trim(requestVar('type')));
1403 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1406 while ( $current = array_shift($actions) )
1408 // TODO: remove this
1409 // skip deprecated vars
1410 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1415 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1417 if ( count($actions) != 0 )
1426 * AdminActions::parse_allowedskinactions()
1427 * Parse skinvar allowedskinactions
1432 public function parse_allowedskinactions()
1434 $skinType = strtolower(trim(requestVar('type')));
1435 $skinid = intRequestVar('skinid');
1437 $skin = new Skin($skinid);
1438 $actions = $skin->getAllowedActionsForType($skinType);
1441 while ( $current = array_shift($actions) )
1443 // TODO: remove this
1444 // skip deprecated vars
1445 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1450 /* TODO: alternative function should be used or not? */
1451 echo helplink("skinvar-{$current}") . "$current</a>\n";
1453 if ( count($actions) != 0 )
1462 * AdminActions::parse_banlistdeletedlist()
1463 * Parse skinvar banlistdeletedlist
1465 * @param string $templateName name of template to use
1468 public function parse_banlistdeletedlist($templateName = '')
1472 $templates = array();
1473 if ( $templateName )
1475 $templates = Template::read($templateName);
1478 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1480 $template = "<li><%blogname%></li>\n";
1484 $template = $templates['BANLIST_DELETED_LIST'];
1487 $deleted = requestArray('delblogs');
1488 foreach ( $deleted as $delblog )
1490 $blog =& $manager->getBlog($delblog);
1492 'blogname' => Entity::hsc($blog->getName())
1494 echo Template::fill($template, $data);
1501 * AdminActions::parse_batchdeletelist()
1502 * Parse skinvar batchdeletelist
1507 public function parse_batchdeletelist()
1509 $selected = requestIntArray('batch');
1512 foreach ( $selected as $select )
1514 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1516 // add hidden vars for team & comment
1517 if ( requestVar('action') == 'batchteam' )
1519 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1521 if ( requestVar('action') == 'batchcomment' )
1523 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1529 * AdminActions::parse_batchdeletetype()
1530 * Parse skinvar batchdeletetype
1535 public function parse_batchdeletetype()
1537 echo Entity::hsc(requestVar('action'));
1542 * AdminActions::parse_batchmovebtn()
1543 * Parse skinvar batchmovebtn
1548 public function parse_batchmovebtn()
1550 $actionType = requestVar('action');
1551 switch ( $actionType )
1556 case 'batchcategory':
1564 * AdminActions::parse_batchmovelist()
1565 * Parse skinvar batchmovelist
1570 public function parse_batchmovelist()
1572 $selected = requestIntArray('batch');
1574 foreach ( $selected as $select )
1576 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1583 * AdminActions::parse_batchmovetitle()
1584 * Parse skinvar batchmovetitle
1589 public function parse_batchmovetitle()
1591 $actionType = requestVar('action');
1592 switch ( $actionType )
1597 case 'batchcategory':
1598 echo _MOVECAT_TITLE;
1605 * AdminActions::parse_batchmovetype()
1606 * Parse skinvar batchmovetype
1611 public function parse_batchmovetype()
1613 echo Entity::hsc(requestVar('action'));
1618 * AdminActions::parse_blogcatlist()
1619 * Parse skinvar blogcatlist
1624 public function parse_blogcatlist($templateName = '')
1627 $blogid = intRequestVar('blogid');
1628 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1629 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1631 $template['content'] = 'categorylist';
1632 $template['tabindex'] = 200;
1634 $batch = new Batch('category');
1635 $batch->showlist($query, 'table', $template, $templateName);
1640 * AdminActions::parse_blogid()
1641 * Parse skinvar blogid
1646 public function parse_blogid()
1648 echo intRequestVar('blogid');
1653 * AdminActions::parse_blognotifysetting()
1654 * Parse skinvar blognotifysetting
1659 public function parse_blognotifysetting($type)
1662 $blogid = intRequestVar('blogid');
1663 $blog = $manager->getBlog($blogid);
1668 if ( !$blog->notifyOnComment() )
1674 if ( !$blog->notifyOnVote() )
1680 if ( !$blog->notifyOnNewItem() )
1686 echo ' checked="checked"';
1691 * AdminActions::parse_blogselectbox()
1692 * Parse skinvar blogselectbox
1697 public function parse_blogselectbox()
1701 $selectData = requestVar('selectData');
1702 $mode = $selectData['mode'];
1703 $name = Entity::hsc($selectData['name']);
1704 $tabindex = Entity::hsc($selectData['tabindex']);
1705 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1706 $showNewCat = intval($selectData['showNewCat']);
1707 $selected = intval($selectData['selected']);
1709 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1711 // 1. select blogs (we'll create optiongroups)
1712 // (only select those blogs that have the user on the team)
1713 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1714 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1715 $blogs = DB::getResult($queryBlogs);
1717 if ( $mode == 'category' )
1719 if ( $blogs->rowCount() > 1 )
1723 foreach ( $blogs as $rBlog )
1725 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1727 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
1730 // show selection to create new category when allowed/wanted
1733 // check if allowed to do so
1734 if ( $member->blogAdminRights($rBlog['bnumber']) )
1736 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
1740 // 2. for each category in that blog
1741 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1742 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
1743 $categories = DB::getResult($catQuery);
1744 foreach ( $categories as $rCat )
1746 if ( $rCat['catid'] == $selected )
1748 $selectText = ' selected="selected" ';
1754 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
1757 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1766 foreach ( $blogs as $rBlog )
1768 echo '<option value="' . $rBlog['bnumber'] . '"';
1769 if ( $rBlog['bnumber'] == $selected )
1771 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1775 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1784 * AdminActions::parse_blogsetting()
1785 * Parse skinvar blogsetting
1787 * @param string $which name of weblog setting
1790 public function parse_blogsetting($which)
1792 echo $this->parse_getblogsetting($which);
1797 * AdminActions::parse_blogsettingyesno()
1798 * Parse skinvar blogsettingyesno
1800 * @param string $type type of weblog setting
1801 * @param string $templateName name of template to use
1804 public function parse_blogsettingyesno($type, $templateName = '')
1808 $blogid = intRequestVar('blogid');
1809 $blog = $manager->getBlog($blogid);
1813 case 'convertbreaks':
1814 $checkedval = $blog->convertBreaks();
1817 case 'allowpastposting':
1818 $checkedval = $blog->allowPastPosting();
1822 $checkedval = $blog->commentsEnabled();
1826 $checkedval = $blog->isPublic();
1830 $checkedval = $blog->emailRequired();
1834 $checkedval = $blog->getSearchable();
1838 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1843 * AdminActions::parse_blogteamlist()
1844 * Parse skinvar blogteamlist
1846 * @param string $templateName name of template to use
1849 public function parse_blogteamlist($templateName = '')
1852 $blogid = intRequestVar('blogid');
1853 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1855 . "WHERE tmember=mnumber AND tblog= %d";
1856 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1858 $template['content'] = 'teamlist';
1859 $template['tabindex'] = 10;
1861 $batch = new Batch('team');
1862 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1867 * AdminActions::parse_blogteammembers()
1868 * Parse skinvar blogteammembers
1873 public function parse_blogteammembers()
1875 $blogid = intRequestVar('blogid');
1876 $query = "SELECT mname, mrealname "
1878 . "WHERE mnumber=tmember AND tblog=%d;";
1879 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1880 $res = DB::getResult($query);
1881 $memberNames = array();
1882 foreach ( $res as $row )
1884 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1886 echo implode(',', $memberNames);
1890 * AdminActions::parse_blogtime()
1891 * Parse skinvar blogtime
1893 * @param string $type type of time
1894 * @param string $format format for time expression
1895 * @param integer $offset offset of time
1898 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1902 if ( $type != 'blogtime' )
1904 /* return server time */
1905 $timestamp = time() + $offset;
1909 $bid = intRequestVar('blogid');
1910 $b = $manager->getBlog($bid);
1911 $timestamp = $b->getCorrectTime() + $offset;
1914 echo i18n::formatted_datetime($format, $timestamp);
1919 * AdminActions::parse_bookmarkletadmin()
1920 * Parse skinvar bookmarkletadmin
1925 public function parse_bookmarkletadmin()
1929 $blogid = intRequestVar('blogid');
1931 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1936 * AdminActions::parse_categories()
1937 * Parse skinvar categories
1939 * create category dropdown box
1941 * @param string $type name of setting for category
1944 public function parse_categories($startidx = 0)
1949 $itemid = intRequestVar('itemid');
1950 $item = &$manager->getItem($itemid, 1, 1);
1955 $blogid = intRequestVar('blogid');
1959 $blogid = $item['blogid'];
1961 $blog = &$manager->getBlog($blogid);
1963 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1965 $item['body'] = removeBreaks($item['body']);
1966 $item['more'] = removeBreaks($item['more']);
1969 $contents = array();
1970 if ( requestVar('action') == 'itemedit' )
1975 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1978 $catid = $blog->getDefaultCategory();
1983 $catid = $contents['catid'];
1986 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1992 * AdminActions::parse_category()
1993 * Parse skinvar category
1995 * @param string $type name of setting for category
1998 public function parse_category($type = 'name')
2000 echo $this->parse_getcategory($type);
2005 * AdminActions::parse_categorysetting()
2006 * Parse skinvar categorysetting
2008 * @param string $type type in category setting
2011 public function parse_categorysetting($type)
2013 $catid = intRequestVar('catid');
2014 if ( $type == 'id' )
2019 $blogid = intRequestVar('blogid');
2020 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2021 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2022 $row = DB::getRow($query);
2024 if ( $type != 'name' )
2026 echo Entity::hsc($row['cdesc']);
2030 echo Entity::hsc($row['cname']);
2037 * AdminActions::parse_codename()
2038 * Parse templatevar codename
2044 public function parse_checkedonval($value, $name)
2049 $itemid = intRequestVar('itemid');
2050 $item =& $manager->getItem($itemid, 1, 1);
2052 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2054 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
2056 $item['body'] = removeBreaks($item['body']);
2057 $item['more'] = removeBreaks($item['more']);
2060 $contents = array();
2061 if ( requestVar('action') == 'itemedit' )
2065 if ( !isset($contents[$name]) )
2067 $contents[$name] = '';
2069 if ($contents[$name] == $value)
2071 echo 'checked="checked"';
2077 * AdminActions::parse_codename()
2078 * Parse templatevar codename
2083 * TODO: is this need???
2085 public function parse_codename()
2088 echo $nucleus['codename'];
2093 * AdminActions::parse_commentnavlist()
2094 * Parse skinvar commentnavlist
2099 public function parse_commentnavlist()
2101 global $CONF, $manager, $member;
2104 if ( postVar('start') )
2106 $start = intPostVar('start');
2113 // amount of items to show
2114 if ( postVar('amount') )
2116 $amount = intPostVar('amount');
2120 $amount = (integer) $CONF['DefaultListSize'];
2126 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2128 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2130 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2132 if ( $this->skintype == 'itemcommentlist' )
2134 $itemid = intRequestVar('itemid');
2135 $query .= " citem={$itemid}";
2136 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2138 $nonComments = _NOCOMMENTS;
2140 elseif ( $this->skintype == 'browseowncomments' )
2143 $query .= ' cmember=' . $member->getID();
2144 $template['canAddBan'] = 0;
2146 $nonComments = _NOCOMMENTS_YOUR;
2148 elseif ( $this->skintype == 'blogcommentlist' )
2151 $query .= ' cblog=' . intRequestVar('blogid');
2152 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2153 $bid = intRequestVar('blogid');
2154 $nonComments = _NOCOMMENTS_BLOG;
2157 $search = postVar('search');
2158 if ( !empty($search) )
2160 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2163 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2165 $template['content'] = 'commentlist';
2167 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2168 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2173 * AdminActions::parse_configsettingsedit()
2174 * Parse skinvar configsettingsedit
2176 * @param string $type type of global configuration
2179 public function parse_configsettingsedit($type)
2184 case 'DefaultListSize':
2185 if ( !array_key_exists('DefaultListSize', $CONF) )
2187 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2188 $query = sprintf($query, sql_table('config'));
2189 DB::execute($query);
2190 $CONF['DefaultListSize'] = 10;
2192 elseif ( intval($CONF['DefaultListSize']) < 1 )
2194 $CONF['DefaultListSize'] = 10;
2196 echo intval($CONF['DefaultListSize']);
2198 case 'SessionCookie':
2199 $value = $CONF['SessionCookie'];
2200 $txt1 = _SETTINGS_COOKIESESSION;
2201 $txt2 = _SETTINGS_COOKIEMONTH;
2202 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2205 $value = $CONF['URLMode'];
2206 $txt1 = _SETTINGS_URLMODE_NORMAL;
2207 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2208 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2211 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2213 echo Entity::hsc($CONF[$type]);
2221 * AdminActions::parse_configsettingsyesno()
2222 * Parse skinvar configsettingsyesno
2224 * @param string $type type of global setting
2225 * @param integer $tabindex tabindex attribute of input element
2228 public function parse_configsettingsyesno($type, $tabindex)
2231 if ( array_key_exists($type, $CONF) )
2233 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2239 * AdminActions::parse_contents()
2240 * Parse skinvar contents
2242 * @param string $which part for item
2245 public function parse_contents($which)
2250 $contents = array();
2252 if ( requestVar('action') == 'itemedit' )
2254 $itemid = intRequestVar('itemid');
2255 $item =& $manager->getItem($itemid, 1, 1);
2257 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2259 if ( $item && $blog->convertBreaks() )
2261 $item['body'] = removeBreaks($item['body']);
2262 $item['more'] = removeBreaks($item['more']);
2266 elseif ( requestVar('action') == 'createitem' )
2268 $blogid = intRequestVar('blogid');
2269 $blog =& $manager->getBlog($blogid);
2273 'contents' => &$contents,
2279 if ( !array_key_exists($which, $contents) )
2281 $contents[$which] = '';
2283 echo Entity::hsc($contents[$which],ENT_QUOTES);
2287 * AdminActions::parse_currenttime()
2288 * Parse skinvar currenttime
2290 * @param string $what
2293 public function parse_currenttime($what)
2296 if ( requestVar('action') == 'itemedit' )
2298 $itemid = intRequestVar('itemid');
2299 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2301 elseif ( requestVar('action') == 'createitem' )
2303 $blog =& $manager->getBlog(intRequestVar('blogid'));
2305 $nu = getdate($blog->getCorrectTime());
2310 * AdminActions::parse_customhelplink()
2311 * Parse skinvar customhelplink
2313 * @param string $topic name of topic
2314 * @param string $tplName name of template
2315 * @param string $url string as URI
2316 * @param string $iconURL string as URI for icon
2317 * @param string $alt alternative text for image element
2318 * @param string $title title for anchor element
2321 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2323 $this->customHelp($topic, $url, $iconURL);
2328 * AdminActions::parse_date()
2329 * Parse skinvar date
2331 public function parse_date($format = 'c')
2333 global $CONF, $manager;
2334 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2339 * AdminActions::parse_defaultadminskintypes()
2340 * Parse skinvar defaultadminskintypes
2342 * @param string $tabindex index number for tabindex attribute of input element
2343 * @param string $templateName name of template
2346 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2348 $templates = array();
2350 if ( $templateName )
2352 $templates = Template::read($templateName);
2355 $types = $this->parser->skin->getAvailableTypes();
2358 /* NOTE: set templates for HEAD/BODY/FOOT */
2359 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2361 $template['head'] = "<ul>\n";
2365 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2367 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2369 $template['body'] = "<li>"
2370 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2375 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2377 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2379 $template['foot'] = "</ul>\n";
2383 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2386 $handler = new AdminActions('template');
2387 $parser = new PARSER($handler);
2389 /* NOTE: do output */
2390 echo $template['head'];
2391 foreach ( $types as $type => $fName )
2393 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2395 'tabindex' => $tabindex,
2396 'skintype' => $type,
2398 'help' => $helplink,
2399 'skinid' => intrequestVar('skinid'),
2401 $parser->parse(Template::fill($template['body'], $data));
2404 echo $template['foot'];
2410 * AdminActions::parse_defblogselect()
2411 * Parse skinvar defblogselect
2413 * @param string $templateName name of template
2416 public function parse_defblogselect($templateName = '')
2420 $query = "SELECT bname as text, bnumber as value FROM %s;";
2421 $query = sprintf($query, sql_table('blog'));
2423 $template['name'] = 'DefaultBlog';
2424 $template['selected'] = $CONF['DefaultBlog'];
2425 $template['tabindex'] = 10;
2427 Showlist($query, 'select', $template, $templateName);
2433 * AdminActions::parse_defcatselect()
2434 * Parse skinvar defcatselect
2436 * @param string $templateName name of template
2439 public function parse_defcatselect($templateName = '')
2443 $blogid = intRequestVar('blogid');
2444 $blog = $manager->getBlog($blogid);
2446 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2447 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2449 $template['name'] = 'defcat';
2450 $template['selected'] = $blog->getDefaultCategory();
2451 $template['tabindex'] = 110;
2453 Showlist($query, 'select', $template, $templateName);
2459 * AdminActions::parse_defskinselect()
2460 * Parse skinvar defskinselect
2462 * @param string $type type of skin
2463 * @param string $templateName name of template
2466 public function parse_defskinselect($type = 'blog', $templateName = '')
2468 global $CONF, $manager;
2470 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2471 $query = sprintf($query, sql_table('skin_desc'));
2473 $blogid = intRequestVar('blogid');
2477 $template['selected'] = $CONF['BaseSkin'];
2481 $blog = $manager->getBlog($blogid);
2482 $template['selected'] = $blog->getDefaultSkin();
2485 if ( $type != 'blog' )
2487 $nname = 'BaseSkin';
2494 $template['name'] = $nname;
2495 $template['tabindex'] = 50;
2497 Showlist($query, 'select', $template, $templateName);
2503 * AdminActions::parse_deletecomment()
2504 * Parse skinvar deletecomment
2506 * @param string $type type of infomation for comment
2509 public function parse_deletecomment($type = 'id')
2511 $commentid = intRequestVar('commentid');
2512 $comment = COMMENT::getComment($commentid);
2517 echo intRequestVar('commentid');
2520 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2522 echo $comment['member'];
2526 echo $comment['user'];
2530 $body = strip_tags($comment['body']);
2531 echo Entity::hsc(shorten($body, 300, '...'));
2537 * AdminActions::parse_deleteitembody()
2538 * Parse skinvar deleteitembody
2543 public function parse_deleteitembody()
2547 $itemid = intRequestVar('itemid');
2548 $item =& $manager->getItem($itemid, 1, 1);
2550 $body = strip_tags($item['body']);
2552 echo Entity::hsc(shorten($body, 300, '...'));
2558 * AdminActions::parse_deleteitemid()
2559 * Parse skinvar deleteitemid
2564 public function parse_deleteitemid()
2566 echo (integer) intRequestVar('itemid');
2571 * AdminActions::parse_deleteitemtitle()
2572 * Parse skinvar deleteitemtitle
2577 public function parse_deleteitemtitle()
2581 $itemid = intRequestVar('itemid');
2582 $item =& $manager->getItem($itemid, 1, 1);
2584 echo Entity::hsc(strip_tags($item['title']));
2590 * AdminActions::parse_editadminskin()
2591 * Parse skinvar editadminskin
2593 * @param string $type type of skin setting
2596 public function parse_editadminskin($type = 'id')
2598 $skinid = intRequestVar('skinid');
2599 $skin = new Skin($skinid);
2603 echo intRequestVar('skinid');
2606 echo Entity::hsc($skin->getName());
2609 echo Entity::hsc($skin->getDescription());
2612 echo Entity::hsc($skin->getContentType());
2615 echo Entity::hsc($skin->getIncludePrefix());
2618 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2626 * AdminActions::parse_editadminskintype()
2627 * Parse skinvar editadminskintype
2629 * @param string $type name of skin type
2632 public function parse_editadminskintype($type = 'id')
2634 global $CONF, $manager, $member;
2636 $fNames = $this->parser->skin->getAvailableTypes();
2637 $sType = strtolower(trim(requestVar('type')));
2642 echo intRequestVar('skinid');
2645 echo Entity::hsc($this->parser->skin->getName());
2648 echo Entity::hsc($this->parser->skin->getDescription());
2651 echo Entity::hsc($this->parser->skin->getContentType());
2654 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2657 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2658 echo Entity::hsc($skinType);
2661 echo Entity::hsc($sType);
2664 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2667 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2668 echo Entity::hsc($incMode);
2677 * AdminActions::parse_editcomment()
2678 * Parse skinvar editcomment
2680 * @param string $type type of comment setting
2683 public function parse_editcomment($type = 'id')
2687 $commentid = intRequestVar('commentid');
2688 $comment = COMMENT::getComment($commentid);
2690 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2695 echo intRequestVar('commentid');
2698 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2700 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2704 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2708 echo date("Y-m-d @ H:i", $comment['timestamp']);
2711 $comment['body'] = str_replace('<br />', '', $comment['body']);
2712 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2713 echo $comment['body'];
2716 echo $comment['userid'];
2719 echo $comment['userid'];
2722 echo $comment[$type];
2729 * AdminActions::parse_editdesturl()
2730 * Parse skinvar editdesturl
2732 public function parse_editdesturl()
2734 if ( requestVar('desturl') )
2736 echo Entity::hsc(requestVar('desturl'));
2742 * AdminActions::parse_editmemberlist()
2743 * Parse skinvar editmemberlist
2745 * @param string $templateName name of template
2748 public function parse_editmemberlist($templateName = '')
2751 // show list of members with actions
2752 $query = 'SELECT * FROM '.sql_table('member');
2753 $template['content'] = 'memberlist';
2754 $template['tabindex'] = 10;
2756 $batch = new Batch('member');
2757 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2762 * AdminActions::parse_editmember()
2763 * Parse skinvar editmember
2765 * @param string $type type of information for member
2766 * @return string $tempateName name of template to use
2769 public function parse_editmember($type = 'id', $templateName = '')
2771 global $CONF, $manager, $member;
2773 $memberid = intRequestVar('memberid');
2774 $mem = MEMBER::createFromID($memberid);
2779 echo intRequestVar('memberid');
2782 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2784 echo Entity::hsc($mem->getDisplayName());
2788 $dispName = Entity::hsc($mem->getDisplayName());
2789 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2791 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2800 echo Entity::hsc($mem->getRealName());
2803 echo Entity::hsc($mem->getEmail());
2806 echo Entity::hsc($mem->getURL());
2809 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2812 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2815 echo Entity::hsc($mem->getNotes());
2818 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2827 * AdminActions::parse_editpluginfo()
2828 * Parse skinvar editpluginfo
2830 * @param string $type type of plugin info
2833 public function parse_editpluginfo($type)
2835 $pid = intRequestVar('plugid');
2842 echo Entity::hsc(getPluginNameFromPid($pid));
2849 * AdminActions::parse_editplugoptionslist()
2850 * Parse skinvar editplugoptionslist
2852 * @param string $templateName name of template
2855 public function parse_editplugoptionslist($templateName = '')
2859 $pid = intRequestVar('plugid');
2860 $aOptions = array();
2863 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2864 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2865 $resource = DB::getResult($query);
2867 foreach ( $resource as $row )
2869 array_push($aOIDs, $row['oid']);
2870 $aOptions[$row['oid']] = array(
2871 'oid' => $row['oid'],
2872 'value' => $row['odef'],
2873 'name' => $row['oname'],
2874 'description' => $row['odesc'],
2875 'type' => $row['otype'],
2876 'typeinfo' => $row['oextra'],
2881 // fill out actual values
2882 if ( count($aOIDs) > 0 )
2884 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2885 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2887 $result = DB::getResult($query);
2889 foreach ( $result as $row )
2891 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2897 'context' => 'global',
2899 'options' => &$aOptions
2901 $manager->notify('PrePluginOptionsEdit', $data);
2903 $template['content'] = 'plugoptionlist';
2905 $amount = Showlist($aOptions, 'table', $template, $templateName);
2909 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2915 * AdminActions::parse_editskin()
2916 * Parse skinvar editskin
2918 * @param string $type type of skin
2921 public function parse_editskin($type = 'id')
2923 $skinid = intRequestVar('skinid');
2924 $skin = new SKIN($skinid);
2928 echo intRequestVar('skinid');
2931 echo Entity::hsc($skin->getName());
2934 echo Entity::hsc($skin->getDescription());
2937 echo Entity::hsc($skin->getContentType());
2940 echo Entity::hsc($skin->getIncludePrefix());
2943 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2951 * AdminActions::parse_editskintype()
2952 * Parse skinvar editskintype
2954 * @param string $type name of type for skin type
2957 public function parse_editskintype($type = 'id')
2959 global $CONF, $manager, $member;
2960 $skinid = intRequestVar('skinid');
2961 $skin = new SKIN($skinid);
2962 $fNames = $skin->getAvailableTypes();
2963 $sType = strtolower(trim(requestVar('type')));
2968 echo intRequestVar('skinid');
2971 echo Entity::hsc($skin->getName());
2974 echo Entity::hsc($skin->getDescription());
2977 echo Entity::hsc($skin->getContentType());
2980 echo Entity::hsc($skin->getContentFromDB($sType));
2983 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2984 echo Entity::hsc($skinType);
2987 echo Entity::hsc($sType);
2990 echo Entity::hsc($skin->getIncludePrefix());
2993 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2994 echo Entity::hsc($incMode);
3003 * AdminActions::parse_adminurl()
3004 * Parse skinvar adminurl
3005 * (shortcut for admin url)
3010 public function parse_adminurl()
3012 $this->parse_sitevar('adminurl');
3017 * AdminActions::parse_edittemplateinfo()
3018 * Parse skinvar edittemplateinfo
3020 * @param string $type name of type for skin
3021 * @param string $description description for skin
3022 * @param string $name name of skin
3023 * @param string $help
3024 * @param string $tabindex index value for tabindex attribute of input element
3025 * @param string $big
3026 * @param string $tplt name of template
3029 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3033 $t_id = intRequestVar('templateid');
3034 $t_name = Template::getNameFromId($t_id);
3035 $t_desc = Template::getDesc($t_id);
3036 $template = &Template::read($t_name);
3044 echo Entity::hsc($t_name);
3047 echo Entity::hsc($t_desc);
3049 case 'extratemplate':
3051 $pluginfields = array();
3052 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
3057 $tmplt = Template::read($desc);
3059 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3063 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3067 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3070 foreach ( $pluginfields as $pfkey => $pfvalue )
3072 $data = array('explugtplname' => Entity::hsc($pfkey));
3074 echo Template::fill($base, $data);
3076 foreach ( $pfvalue as $pffield => $pfdesc )
3078 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3083 $desc = defined($desc) ? constant($desc) : $desc;
3084 $name = defined($name) ? constant($name) : $name;
3085 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3093 * AdminActions::parse_editadmintemplateinfo()
3094 * Parse skinvar editadmintemplateinfo
3096 * @param string $type type of skin template
3097 * @param string $description description of template
3098 * @param string $name name of stemplate
3099 * @param string $tabindex index number for tabindex attribute of input element
3100 * @param string $big
3101 * @param string $tplt
3103 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3107 $t_id = intRequestVar('templateid');
3108 $t_name = Template::getNameFromId($t_id);
3109 $t_desc = Template::getDesc($t_id);
3110 $template = &Template::read($t_name);
3118 echo Entity::hsc($t_name);
3121 echo Entity::hsc($t_desc);
3123 case 'extratemplate':
3125 $pluginfields = array();
3126 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3131 $tmplt = Template::read($desc);
3133 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3137 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3141 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3144 foreach ( $pluginfields as $pfkey => $pfvalue )
3146 $data = array('explugtplname' => Entity::hsc($pfkey));
3148 echo Template::fill($base, $data);
3150 foreach ( $pfvalue as $pffield => $pfdesc )
3152 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3157 $desc = defined($desc) ? constant($desc) : $desc;
3158 $name = defined($name) ? constant($name) : $name;
3159 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3166 * AdminActions::parse_eventformextra()
3167 * Parse skinvar eventformextra
3169 * @param string $type name of type for event form extra
3172 public function parse_eventformextra($type = 'activation')
3181 $key = requestVar('ackey');
3184 Admin::error(_ERROR_ACTIVATE);
3186 $info = MEMBER::getActivationInfo($key);
3189 Admin::error(_ERROR_ACTIVATE);
3191 $mem = MEMBER::createFromId($info->vmember);
3194 Admin::error(_ERROR_ACTIVATE);
3197 'type' => 'activation',
3201 case 'membermailform-notloggedin':
3202 $data = array('type' => 'membermailform-notloggedin',);
3205 $manager->notify('FormExtra', $data);
3210 * AdminActions::parse_extrahead()
3211 * Parse skinvar extrahead
3213 public function parse_extrahead()
3217 $extrahead = Admin::getAdminextrahead();
3220 'extrahead' => &$extrahead,
3221 'action' => Admin::getAdminAction()
3224 $manager->notify('AdminPrePageHead', $data);
3230 * AdminActions::parse_member()
3231 * Parse skinvar member
3232 * (includes a member info thingie)
3234 * @param string $what which memberdata is needed
3237 public function parse_member($what)
3239 global $memberinfo, $member, $CONF;
3241 // 1. only allow the member-details-page specific variables on member pages
3242 if ( $this->skintype == 'member' )
3247 echo Entity::hsc($memberinfo->getDisplayName());
3250 echo Entity::hsc($memberinfo->getRealName());
3253 echo Entity::hsc($memberinfo->getNotes());
3256 echo Entity::hsc($memberinfo->getURL());
3259 echo Entity::hsc($memberinfo->getEmail());
3262 echo Entity::hsc($memberinfo->getID());
3267 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3268 if ( $member->isLoggedIn() )
3273 echo $member->getDisplayName();
3275 case 'yourrealname':
3276 echo $member->getRealName();
3279 echo $member->getNotes();
3282 echo $member->getURL();
3285 echo $member->getEmail();
3288 echo $member->getID();
3290 case 'yourprofileurl':
3291 if ( $CONF['URLMode'] == 'pathinfo' )
3293 echo Link::create_member_link($member->getID());
3297 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3306 * AdminActions::parse_version()
3307 * Parse skinvar version
3308 * (include nucleus versionnumber)
3313 public function parse_version()
3316 echo 'Nucleus CMS ' . $nucleus['version'];
3321 * AdminActions::parse_sitevar()
3322 * Parse skinvar sitevar
3323 * (include a sitevar)
3325 * @param string $which
3328 public function parse_sitevar($which)
3334 echo $CONF['IndexURL'];
3337 echo $CONF['SiteName'];
3340 echo $CONF['AdminEmail'];
3343 echo $CONF['AdminURL'];
3349 * AdminActions::parse_charset()
3350 * Parse skinvar charset
3355 public function parse_charset()
3357 echo i18n::get_current_charset();
3362 * AdminActions::parse_getblogsetting()
3363 * Parse skinvar getblogsetting
3365 public function parse_getblogsetting($which)
3367 global $blog, $manager;
3373 elseif ( $bid = intRequestVar('blogid') )
3375 $b = $manager->getBlog($bid);
3385 return Entity::hsc($b->getID());
3388 return Entity::hsc($b->getURL());
3391 return Entity::hsc($b->getName());
3394 return Entity::hsc($b->getDescription());
3397 return Entity::hsc($b->getShortName());
3399 case 'notifyaddress':
3400 return Entity::hsc($b->getNotifyAddress());
3403 return Entity::hsc($b->getMaxComments());
3406 return Entity::hsc($b->getUpdateFile());
3409 return Entity::hsc($b->getTimeOffset());
3416 * AdminActions::parse_geteditpluginfo()
3417 * Parse skinvar geteditpluginfo
3419 * @param string $type name of setting for edit plugin info
3422 public function parse_geteditpluginfo($type)
3424 $pid = intRequestVar('plugid');
3431 return Entity::hsc(getPluginNameFromPid($pid));
3438 * AdminActions::parse_getmember()
3439 * Parse skinvar getmember
3440 * (includes a member info thingie)
3442 * @param string $what name of setting for member
3445 public function parse_getmember($what)
3447 global $memberinfo, $member;
3448 // 1. only allow the member-details-page specific variables on member pages
3449 if ( $this->skintype == 'member' )
3454 return Entity::hsc($memberinfo->getDisplayName());
3457 return Entity::hsc($memberinfo->getRealName());
3460 return Entity::hsc($memberinfo->getNotes());
3463 return Entity::hsc($memberinfo->getURL());
3466 return Entity::hsc($memberinfo->getEmail());
3469 return Entity::hsc($memberinfo->getID());
3473 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3474 if ( $member->isLoggedIn() )
3479 return $member->getDisplayName();
3481 case 'yourrealname':
3482 return $member->getRealName();
3485 return $member->getNotes();
3488 return $member->getURL();
3491 return $member->getEmail();
3494 return $member->getID();
3502 * AdminActions::parse_headmessage()
3503 * Parse skinvar headmessage
3508 public function parse_headmessage()
3510 if ( !empty(Admin::$headMess) )
3512 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3518 * AdminActions::parse_helplink()
3519 * Parse skinvar helplink
3521 * @param string $topic name of topic for help
3524 public function parse_helplink($topic = '')
3526 if ( !empty($topic) )
3534 * AdminActions::parse_helpplugname()
3535 * Parse skinvar helpplugname
3540 public function parse_helpplugname()
3542 $plugid = intGetVar('plugid');
3543 Entity::hsc(getPluginNameFromPid($plugid));
3548 * AdminActions::parse_ilistaddnew()
3549 * Parse skinvar ilistaddnew
3554 public function parse_ilistaddnew()
3556 $blogid = intRequestVar('blogid');
3557 if ( intPostVar('start') == 0 )
3559 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3565 * AdminActions::parse_importskininfo()
3566 * Parse skinvar importskininfo
3568 * @param string $type name of information for imported skin
3571 public function parse_importskininfo($type)
3576 echo Entity::hsc(requestVar('skininfo'));
3579 $dataArr = requestArray('skinnames');
3580 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3583 $dataArr = requestArray('tpltnames');
3584 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3587 $dataArr = requestArray('skinclashes');
3588 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3591 $dataArr = requestArray('tpltclashes');
3592 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3595 echo Entity::hsc(requestVar('skinfile'));
3598 echo Entity::hsc(requestVar('mode'));
3605 * AdminActions::parse_inputyesno()
3606 * Parse skinvar inputyesno
3608 * some init stuff for all forms
3613 public function parse_init()
3618 if ( requestVar('action') == 'itemedit' )
3620 $itemid = intRequestVar('itemid');
3621 $item =& $manager->getItem($itemid, 1, 1);
3623 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3624 if ( $item && $blog->convertBreaks() )
3626 $item['body'] = removeBreaks($item['body']);
3627 $item['more'] = removeBreaks($item['more']);
3630 $authorid = $contents['authorid'];
3632 elseif ( requestVar('action') == 'createitem' )
3634 $blogid = intRequestVar('blogid');
3635 $blog =& $manager->getBlog($blogid);
3638 $blog->insertJavaScriptInfo($authorid);
3643 * AdminActions::parse_inputyesno()
3644 * Parse skinvar inputyesno
3646 * @param string $name
3647 * @param string $checkedval
3648 * @param string $tabindex
3649 * @param string $value1
3650 * @param string $value2
3651 * @param string $yesval
3652 * @param string $noval
3653 * @param string $isAdmin
3654 * @param string $templateName
3657 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3659 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3664 * AdminActions::parse_insertpluginfo()
3665 * Parse templatevar insertpluginfo
3667 public function parse_insertpluginfo($type)
3669 $option = Admin::getAdminaOption();
3673 return $option['pid'];
3676 return Entity::hsc($option['pfile']);
3683 * AdminActions::parse_insertpluginoptions()
3684 * Parse skinvar insertpluginoptions
3686 * @param string $templateName name of template
3689 public function parse_insertpluginoptions($templateName = '')
3691 $options = Admin::getAdminaOption();
3692 $template = array();
3693 $templats = array();
3695 if ( $templateName )
3697 $templates = Template::read($templateName);
3700 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3702 $template['title'] = "<tr>"
3703 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3708 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3711 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3713 $template['body'] = "<tr>"
3714 . "<%listplugplugoptionrow%>"
3719 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3724 include_libs('ACTIONS.php');
3725 $handler = new Actions($this->skintype);
3726 $parser = new PARSER($handler);
3728 foreach ( $options as $option )
3732 if ( $prevPid != $option['pid'] )
3734 $prevPid = $option['pid'];
3735 $parser->parse($template['title']);
3738 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3740 if ( @$meta['access'] != 'hidden' )
3742 $parsed = $parser->parse($template['body']);
3749 * AdminActions::parse_insplugoptcontent()
3750 * Parse skinvar insplugoptcontent
3755 public function parse_insplugoptcontent()
3757 $option = Admin::getAdminaOption();
3759 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3760 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3763 listplug_plugOptionRow($option);
3770 * AdminActions::parse_iprangeinput()
3771 * Parse skinvar iprangeinput
3776 public function parse_iprangeinput()
3778 if ( requestVar('ip') )
3780 $iprangeVal = Entity::hsc(requestVar('ip'));
3781 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3782 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3783 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3784 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3785 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3789 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3790 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3796 * AdminActions::parse_itemnavlist()
3797 * Parse skinvar itemnavlist
3802 public function parse_itemnavlist($templateName)
3804 global $CONF, $manager, $member;
3806 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3807 . " FROM %s, %s, %s, %s"
3808 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3810 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3812 if ( $this->skintype == 'itemlist' )
3815 if ( array_key_exists('blogid', $_REQUEST) )
3817 $blogid = intRequestVar('blogid');
3819 else if ( array_key_exists('itemid', $_REQUEST) )
3821 $itemid = intRequestVar('itemid');
3822 $item = &$manager->getItem($itemid, 1, 1);
3823 $blogid = (integer) $item['blogid'];
3825 $blog =& $manager->getBlog($blogid);
3827 $query .= " AND iblog={$blogid}";
3828 $template['now'] = $blog->getCorrectTime(time());
3830 // non-blog-admins can only edit/delete their own items
3831 if ( !$member->blogAdminRights($blogid) )
3833 $query .= ' AND iauthor = ' . $member->getID();
3836 elseif ( $this->skintype == 'browseownitems' )
3838 $query .= ' AND iauthor = ' . $member->getID();
3840 $template['now'] = time();
3843 // search through items
3844 $search = postVar('search');
3846 if ( !empty($search) )
3848 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3849 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3850 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3853 if ( postVar('start') )
3855 $start = intPostVar('start');
3862 // amount of items to show
3863 if ( postVar('amount') )
3865 $amount = intPostVar('amount');
3869 $amount = (integer) $CONF['DefaultListSize'];
3876 $query .= ' ORDER BY itime DESC'
3877 . " LIMIT {$start},{$amount}";
3879 $template['content'] = 'itemlist';
3881 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3882 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3887 * AdminActions::parse_itemtime()
3888 * date change on edit item
3890 * @param string $key key of PHP's getDate()
3893 public function parse_itemtime($key)
3898 $itemid = intRequestVar('itemid');
3899 $item =& $manager->getItem($itemid, 1, 1);
3901 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3903 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3905 $item['body'] = removeBreaks($item['body']);
3906 $item['more'] = removeBreaks($item['more']);
3909 $contents = array();
3910 if ( requestVar('action') == 'itemedit' )
3914 elseif ( requestVar('action') == 'createitem' )
3917 'contents' => &$contents,
3918 'blog' => &$this->blog
3920 $manager->notify('PreAddItemForm', $data);
3922 $itemtime = getdate($contents['timestamp']);
3923 echo $itemtime[$key];
3928 * AdminActions::parse_jstoolbaroptions()
3929 * Parse skinvar jstoolbaroptions
3934 public function parse_jstoolbaroptions()
3938 _SETTINGS_JSTOOLBAR_NONE,
3939 _SETTINGS_JSTOOLBAR_SIMPLE,
3940 _SETTINGS_JSTOOLBAR_FULL
3944 foreach ( $options as $option )
3946 $text = "<option value=\"%d\"%s>%s</option>\n";
3947 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3948 echo sprintf($text, $i, $extra, $option);
3954 * AdminActions::parse_localeselectoptions()
3955 * Parse skinvar localeselectoptions
3960 public function parse_localeselectoptions()
3962 $locales = i18n::get_available_locale_list();
3964 $memid = intRequestVar('memberid');
3967 $mem = MEMBER::createFromID($memid);
3968 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3970 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3974 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3979 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3981 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3985 echo "<option value=\"\">en_Latn_US</option>\n";
3988 foreach ( $locales as $locale )
3990 if ( $locale == 'en_Latn_US' )
3996 if ( $locale == $mem->getLocale() )
3998 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4002 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4007 if ( $locale == i18n::get_current_locale() )
4009 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4013 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4021 * AdminActions::parse_listplugplugoptionrow()
4022 * Parse templatevar listplugplugoptionrow
4024 * @param string $templateName name of template
4027 public function parse_listplugplugoptionrow($templateName = '')
4029 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
4034 * AdminActions::parse_mediadirwarning()
4035 * Parse skinvar mediadirwarning
4040 public function parse_mediadirwarning()
4043 if ( !is_dir($DIR_MEDIA) )
4045 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4047 if ( !is_readable($DIR_MEDIA) )
4049 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4051 if ( !is_writeable($DIR_MEDIA) )
4053 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4059 * AdminActions::parse_movedistselect()
4060 * Parse skinvar movedistselect
4062 public function parse_movedistselect()
4064 $actionType = requestVar('action');
4065 switch ( $actionType )
4068 Admin::selectBlogCategory('destcatid');
4070 case 'batchcategory':
4071 Admin::selectBlog('destblogid');
4074 if ( $this->skintype == 'itemmove' )
4076 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4077 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
4078 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
4079 Admin::selectBlogCategory('catid', $catid, 10, 1);
4087 * AdminActions::parse_moveitemid()
4088 * Parse skinvar moveitemid
4093 public function parse_moveitemid()
4095 echo intRequestVar('itemid');
4100 * AdminActions::parse_newestcompare()
4101 * Parse skinvar newestcompare
4106 public function parse_newestcompare()
4110 $newestVersion = getLatestVersion();
4111 $newestCompare = str_replace('/', '.', $newestVersion);
4112 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4114 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4116 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4117 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4123 * AdminActions::parse_newmemberselect()
4124 * Parse skinvar newmemberselect
4126 * @param string $templateName name of template to use
4129 public function parse_newmemberselect($templateName = '')
4131 $blogid = intRequestVar('blogid');
4133 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4134 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4135 $res = DB::getResult($query);
4138 foreach ( $res as $row )
4140 $tmem[] = intval($row['tmember']);
4143 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4144 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4147 'name' => 'memberid',
4148 'tabindex' => 10000,
4151 Showlist($query, 'select', $template, $templateName);
4156 * AdminActions::parse_newpluginlist()
4157 * Parse skinvar newpluginlist
4162 public function parse_newpluginlist()
4164 $candidates = $this->newPlugCandidates;
4165 foreach ( $candidates as $name )
4167 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4173 * AdminActions::parse_outputspecialdirs()
4174 * Parse skinvar outputspecialdirs
4176 * @param string $type type of setting for directory
4179 public function parse_outputspecialdirs($type)
4181 global $DIR_MEDIA, $DIR_NUCLEUS;
4186 echo Entity::hsc($DIR_NUCLEUS);
4189 echo Entity::hsc($DIR_MEDIA);
4196 * AdminActions::parse_passrequestvars()
4197 * Parse skinvar passrequestvars
4202 public function parse_passrequestvars()
4204 $passvar = Admin::getAdminpassvar();
4205 $oldaction = postVar('oldaction');
4207 if ( ($oldaction != 'logout')
4208 && ($oldaction != 'login')
4210 && !postVar('customaction') )
4218 * AdminActions::parse_pluginextras()
4219 * Parse skinvar pluginextras
4221 * @param string $type type of plugin context
4224 public function parse_pluginextras($type = 'global')
4230 $id = intRequestVar('memberid');
4231 $mem = MEMBER::createFromID($id);
4232 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4235 $id = intRequestVar('blogid');
4236 $blg = $manager->getBlog($id);
4237 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4241 'GeneralSettingsFormExtras',
4251 * AdminActions::parse_pluginhelp()
4252 * Parse skinvar pluginhelp
4257 public function parse_pluginhelp()
4259 global $manager, $DIR_PLUGINS;
4261 $plugid = intGetVar('plugid');
4262 $plugName = getPluginNameFromPid($plugid);
4263 $plug =& $manager->getPlugin($plugName);
4265 if ( $plug->supportsFeature('HelpPage') > 0 )
4267 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4268 if ( @file_exists($helpfile . 'php') )
4270 @include($helpfile . 'php');
4273 elseif ( @file_exists($helpfile . 'html') )
4275 @include($helpfile . 'html');
4279 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4280 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4285 * AdminActions::parse_pluginlistlist()
4286 * Parse skinvar pluginlistlist
4288 * @param string $templateName name of template to use
4291 public function parse_pluginlistlist($templateName = '')
4293 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4294 $query = sprintf($query, sql_table('plugin'));
4296 $template['content'] = 'pluginlist';
4297 $template['tabindex'] = 10;
4299 Showlist($query, 'table', $template, $templateName);
4305 * AdminActions::parse_pluginoptions()
4306 * Parse skinvar pluginoptions
4308 * @param string $type type of plugin option
4311 public function parse_pluginoptions($context='global')
4313 global $itemid, $manager;
4318 $contextid = intRequestVar('memberid');
4321 $contextid = intRequestVar('blogid');
4324 $contextid = intRequestVar('catid');
4327 $contextid = $itemid;
4331 /* Actually registererd plugin options */
4332 $aIdToValue = array();
4333 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4334 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4335 $res = DB::getResult($query);
4336 foreach ( $res as $row )
4338 $aIdToValue[$row['oid']] = $row['ovalue'];
4341 /* Currently available plugin options */
4342 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4343 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4344 $res = DB::getResult($query);
4347 foreach ($res as $row )
4349 if ( !array_key_exists($row['oid'], $aIdToValue) )
4351 $value = $row['odef'];
4355 $value = $aIdToValue[$row['oid']];
4359 'pid' => $row['pid'],
4360 'pfile' => $row['pfile'],
4361 'oid' => $row['oid'],
4363 'name' => $row['oname'],
4364 'description' => $row['odesc'],
4365 'type' => $row['otype'],
4366 'typeinfo' => $row['oextra'],
4367 'contextid' => $contextid,
4373 'context' => $context,
4374 'contextid' => $contextid,
4375 'options' => &$opt4ions
4377 $manager->notify('PrePluginOptionsEdit', $data);
4379 $content = $this->parser->skin->getContentFromDB('insertpluginoptions');
4380 $this->parser->parse($content);
4386 * AdminActions::parse_qmenuaddselect()
4387 * Parse skinvar qmanuaddselect
4389 * @param string $templateName name of template to use
4392 public function parse_qmenuaddselect($templateName = '')
4395 $showAll = requestVar('showall');
4396 if ( $member->isAdmin() && ($showAll == 'yes') )
4398 // Super-Admins have access to all blogs! (no add item support though)
4399 $query = 'SELECT bnumber as value, bname as text'
4400 . ' FROM ' . sql_table('blog')
4401 . ' ORDER BY bname';
4405 $query = 'SELECT bnumber as value, bname as text'
4406 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4407 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4408 . ' ORDER BY bname';
4411 $template['name'] = 'blogid';
4412 $template['tabindex'] = 15000;
4413 $template['extra'] = _QMENU_ADD_SELECT;
4414 $template['selected'] = -1;
4415 $template['shorten'] = 10;
4416 $template['shortenel'] = '';
4417 $template['javascript'] = 'onchange="return form.submit()"';
4419 Showlist($query, 'select', $template, $templateName);
4425 * AdminActions::parse_quickmenu()
4426 * Parse skinvar quickmenu
4428 * @param string $templateName name of template to use
4431 public function parse_quickmenu($templateName = '')
4434 $templates = array();
4435 $template = array();
4436 if ( !empty($templateName) )
4438 $templates = Template::read($templateName);
4440 $pluginExtras = array();
4444 'options' => &$pluginExtras
4447 if ( count($pluginExtras) > 0 )
4449 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4451 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4455 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4457 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4459 $template['head'] = "<ul>\n";
4463 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4465 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4467 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4471 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4473 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4475 $template['foot'] = "</ul>\n";
4479 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4482 $handler = new Actions($this->skintype);
4483 $parser = new PARSER($handler);
4485 $parser->parse($template['title']);
4486 echo $template['head'];
4487 foreach ( $pluginExtras as $aInfo )
4490 'plugadminurl' => Entity::hsc($aInfo['url']),
4491 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4492 'plugadmintitle' => Entity::hsc($aInfo['title']),
4494 echo Template::fill($template['body'], $data);
4496 echo $template['foot'];
4502 * AdminActions::parse_requestblogid()
4503 * Parse skinvar requestblogid
4508 public function parse_requestblogid()
4510 echo intRequestVar('blogid');
4515 * AdminActions::parse_requestiprange()
4516 * Parse skinvar requestiprange
4521 public function parse_requestiprange()
4523 if ( requestVar('iprange') )
4525 echo Entity::hsc(requestVar('iprange'));
4527 elseif ( requestVar('ip') )
4529 echo Entity::hsc(requestVar('ip'));
4535 * AdminActions::parse_selectlocaladminskinfiles()
4536 * Parse skinvar selectlocaladminskinfiles
4541 public function parse_selectlocaladminskinfiles()
4543 global $DIR_SKINS, $manager;
4545 $adminskindir = $DIR_SKINS . 'admin/';
4546 $candidates = SkinImport::searchForCandidates($adminskindir);
4548 foreach ( $candidates as $skinname => $skinfile )
4550 $html = Entity::hsc($skinfile);
4551 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4558 * AdminActions::parse_selectlocalskinfiles()
4559 * Parse skinvar selectlocalskinfiles
4564 public function parse_selectlocalskinfiles()
4568 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4570 foreach ( $candidates as $skinname => $skinfile )
4572 $html = Entity::hsc($skinfile);
4573 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4580 * AdminActions::parse_skineditallowedlist()
4581 * Parse skinvar skineditallowedlist
4583 * @param string $type type of skin
4584 * @param string $templateName name of template
4587 public function parse_skineditallowedlist($type, $templateName = '')
4592 $query = "SELECT bshortname, bname FROM %s;";
4594 'content' => 'shortblognames'
4596 $query = sprintf($query, sql_table('blog'));
4597 Showlist($query, 'table', $show, $templateName);
4600 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4602 'content' => 'shortnames'
4604 $query = sprintf($query, sql_table('template_desc'));
4605 Showlist($query, 'table', $show, $templateName);
4612 * AdminActions::parse_skinielist()
4613 * Parse skinvar skinielist
4615 * @param string $type type of skin
4616 * @param string $templateName name of template to use
4619 public function parse_skinielist($type, $templateName = '')
4621 $templates = array();
4622 if ( $templateName )
4624 $templates = Template::read($templateName);
4626 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4628 $template = $templates['SKINIE_EXPORT_LIST'];
4633 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4634 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4636 . "<td><%expdesc%></td>\n"
4643 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'));
4644 foreach ( $res as $row )
4647 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4648 'expid' => 'skinexp' . $row['sdnumber'],
4649 'expname' => Entity::hsc($row['sdname']),
4650 'expdesc' => Entity::hsc($row['sddesc'])
4652 echo Template::fill($template, $data);
4656 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4657 foreach ( $res as $row )
4660 'typeid' => 'template[' . $row['tdnumber'] . ']',
4661 'expid' => 'templateexp' . $row['tdnumber'],
4662 'expname' => Entity::hsc($row['tdname']),
4663 'expdesc' => Entity::hsc($row['tddesc'])
4665 echo Template::fill($template, $data);
4673 * AdminActions::parse_skinoverview()
4674 * Parse skinvar skinoverview
4676 * @param string $templateName name of template to use
4679 public function parse_skinoverview($templateName = '')
4682 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4683 $query = sprintf($query, sql_table('skin_desc'));
4685 $template['content'] = 'skinlist';
4686 $template['tabindex'] = 10;
4688 Showlist($query, 'table', $template, $templateName);
4693 * AdminActions::parse_skintypehelp()
4694 * Check editing skintypehelp
4699 public function parse_skintypehelp()
4701 $nowSkinType = strtolower(trim(requestVar('type')));
4703 /* TODO: use Skin class */
4704 $regularType = array(
4715 if ( in_array($nowSkinType, $regularType) )
4717 help('skinpart' . $nowSkinType);
4721 help('skinpartspecial');
4727 * AdminActions::parse_specialskinlist()
4728 * Parse skinvar specialskinlist
4730 * @param string $templateName name of template to use
4733 public function parse_specialskinlist($templateName = '')
4735 $templates = array();
4736 if ( $templateName )
4738 $templates = Template::read($templateName);
4741 /* TODO: use Skin class */
4752 $skinid = intRequestVar('skinid');
4753 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4754 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4756 $res = DB::getResult($query);
4757 if ( $res && $res->rowCount() > 0 )
4760 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4762 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4766 $template['head'] = "<ul>\n";
4768 echo Template::fill($template['head'], $data);
4769 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4771 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4772 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4773 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4777 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4781 foreach ( $res as $row )
4784 'tabindex' => $tabstart++,
4785 'skinid' => $skinid,
4786 'skintype' => Entity::hsc(strtolower($row['stype']))
4788 echo Template::fill($template['body'], $data);
4791 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4793 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4797 $template['foot'] = "</ul>\n";
4799 echo Template::fill($template['foot'], $data);
4805 * AdminActions::parse_sprinttext()
4808 * @param string $which
4809 * @param string $val
4812 public function parse_sprinttext($which, $val)
4814 if ( !defined($which) )
4820 $base = constant($which);
4823 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4825 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4827 $met = 'parse_' . $matchies[0];
4831 $arg = trim($args[0], '()');
4832 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4835 if ( method_exists($this, $met) )
4837 $value = call_user_func(array(&$this, $met), $arg);
4841 if ( !isset($value) || empty($value) )
4845 echo sprintf($base, $value);
4850 * AdminActions::parse_systemsettings()
4851 * Parse skinvar systemsettings
4853 * @param string $type type of settings for system
4854 * @param string $templateName name of template to use
4857 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4859 global $member, $CONF, $nucleus;
4861 $member->isAdmin() or Admin::disallow();
4863 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4864 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4871 case 'sqlserverinfo':
4872 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4874 case 'sqlclientinfo':
4875 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4877 case 'magicquotesgpc':
4878 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4880 case 'magicquotesruntime':
4881 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4883 case 'registerglobals':
4884 echo ini_get('register_globals') ? 'On' : 'Off';
4887 $templates = array();
4888 if ( $templateName )
4890 $templates = Template::read($templateName);
4892 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4894 $template = "<tr>\n"
4895 . "<td><%key%></td>\n"
4896 . "<td><%value%></td>\n"
4901 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4904 $gdinfo = gd_info();
4906 foreach ( $gdinfo as $key => $value )
4908 if ( is_bool($value) )
4910 $value = $value ? $enable : $disable;
4914 $value = Entity::hsc($value);
4920 echo Template::fill($template, $data);
4925 phpinfo(INFO_MODULES);
4926 $im = ob_get_contents();
4928 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4930 case 'nucleusversion':
4931 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4933 case 'nucleuspatchlevel':
4934 echo getNucleusPatchLevel();
4940 echo $CONF['ItemURL'];
4942 case 'alertonheaderssent':
4943 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4945 case 'nucleuscodename':
4946 if ( $nucleus['codename'] != '' )
4948 echo ' "' . $nucleus['codename'] . '"';
4951 case 'versioncheckurl':
4952 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4959 * AdminActions::parse_templateoverview()
4960 * Parse skinvar templateoverview
4962 * @param string $templateName name of template to use
4965 public function parse_templateoverview($templateName = '')
4967 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4968 $query = sprintf($query, sql_table('template_desc'));
4970 $template['content'] = 'templatelist';
4971 $template['tabindex'] = 10;
4973 Showlist($query, 'table', $template, $templateName);
4979 * AdminActions::parse_ticket()
4985 public function parse_ticket()
4988 $manager->addTicketHidden();
4993 * AdminActions::parse_versioncheckurl()
4994 * Parse skinvar versioncheckurl
4999 public function parse_versioncheckurl()
5001 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5006 * AdminActions::parse_yrbloglist()
5007 * Parse skinvar yrbloglist
5009 * @param string $templateName name of template to use
5012 public function parse_yrbloglist($templateName = '')
5015 $showAll = requestVar('showall');
5017 if ( $member->isAdmin() && ($showAll == 'yes') )
5019 // Super-Admins have access to all blogs! (no add item support though)
5020 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
5022 . " ORDER BY bnumber;";
5023 $query = sprintf($query, sql_table('blog'));
5027 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
5029 . " WHERE tblog=bnumber and tmember=%d"
5030 . " ORDER BY bnumber;";
5031 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5034 $template['content'] = 'bloglist';
5035 $template['superadmin'] = $member->isAdmin();
5037 $amount = Showlist($query, 'table', $template, $templateName);
5039 if ( ($showAll != 'yes') && ($member->isAdmin()) )
5041 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
5043 $total = DB::getValue($query);
5044 if ( $total > $amount )
5046 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
5052 echo _OVERVIEW_NOBLOGS;
5054 elseif( $amount != 0 )
5056 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
5058 $query = "SELECT ititle, inumber, bshortname"
5060 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
5061 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
5063 $template['content'] = 'draftlist';
5065 $amountdrafts = Showlist($query, 'table', $template, $templateName);
5066 if ( $amountdrafts == 0 )
5068 echo _OVERVIEW_NODRAFTS;
5075 * AdminActions::checkCondition()
5076 * Checks conditions for if statements
5078 * @param string $field type of <%if%>
5079 * @param string $name property of field
5080 * @param string $value value of property
5081 * @return boolean condition
5083 protected function checkCondition($field, $name='', $value = '')
5085 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5096 $blog =& $manager->getBlog($blogid);
5100 $blogid = getBlogIDFromCatID($catid);
5102 $blog =& $manager->getBlog($blogid);
5104 elseif ( intRequestVar('catid') )
5106 $catid = intRequestVar('catid');
5107 $blogid = getBlogIDFromCatID($catid);
5109 $blog =& $manager->getBlog($blogid);
5116 $condition = ($blog && $this->ifCategory($name, $value));
5119 $condition = ($blog && ($blog->getSetting($name) == $value));
5122 $condition = $member->isLoggedIn();
5125 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5128 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5131 $condition = $member->isLoggedIn() && $member->isAdmin();
5133 case 'allowloginedit':
5134 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5137 $condition = ($itemidnext != '');
5140 $condition = ($itemidprev != '');
5142 case 'archiveprevexists':
5143 $condition = ($archiveprevexists == true);
5145 case 'archivenextexists':
5146 $condition = ($archivenextexists == true);
5149 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5152 $condition = $this->ifHasPlugin($name, $value);
5155 $condition = (Admin::getAdminAction() == $name);
5157 case 'adminoldaction':
5158 $condition = (Admin::getAdminAction() == $name);
5160 case 'addresschange':
5161 $condition = ($this->ifAddresscange());
5163 case 'bechangepass':
5164 $condition = ($this->beChangePassword());
5166 case 'skincandidates':
5167 $condition = ($this->ifSkincandidates());
5170 $condition = requestVar('nameclashes');
5172 case 'existsnewplugin':
5173 $condition = ($this->existsNewPlugin());
5176 $condition = (boolean) ($member->getAutosave() == $value);
5179 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5186 * Actions::_ifHasPlugin()
5187 * hasplugin,PlugName
5188 * -> checks if plugin exists
5189 * hasplugin,PlugName,OptionName
5190 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5191 * hasplugin,PlugName,OptionName=value
5192 * -> checks if the option OptionName from plugin PlugName is set to value
5194 * @param string $name name of plugin
5195 * @param string $value
5198 private function ifHasPlugin($name, $value)
5202 // (pluginInstalled method won't write a message in the actionlog on failure)
5203 if ( $manager->pluginInstalled("NP_{$name}") )
5205 $plugin =& $manager->getPlugin("NP_{$name}");
5206 if ( $plugin != NULL )
5214 list($name2, $value2) = preg_split('#=#', $value, 2);
5215 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5219 else if ( $plugin->getOption($name2) == $value2 )
5230 * Actions::beChangePassword()
5235 private function beChangePassword()
5237 return intRequestVar('bNeedsPasswordChange');
5241 * Actions::ifSkincandidates()
5242 * Checks if a plugin exists and call its doIf function
5248 private function ifSkincandidates()
5251 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5252 return (count($candidates) > 0);
5256 * Actions::ifPlugin()
5257 * Checks if a plugin exists and call its doIf function
5259 * @param string $name name of plugin
5260 * @param string $key
5261 * @param string $value
5264 private function ifPlugin($name, $key = '', $value = '')
5268 $plugin =& $manager->getPlugin("NP_{$name}");
5274 $params = func_get_args();
5275 array_shift($params);
5277 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5281 * AdminActions::ifCategory()
5282 * Different checks for a category
5284 * @param string $key key for information of category
5285 * @param string $value value for information of category
5288 private function ifCategory($key = '', $value='')
5290 global $blog, $catid;
5292 // when no parameter is defined, just check if a category is selected
5293 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5295 return $blog->isValidCategory($catid);
5298 // check category name
5299 if ( $key == 'catname' )
5301 $value = $blog->getCategoryIdFromName($value);
5302 if ($value == $catid)
5304 return $blog->isValidCategory($catid);
5308 // check category id
5309 if (($key == 'catid') && ($value == $catid))
5311 return $blog->isValidCategory($catid);
5318 * AdminActions::ifOnTeam()
5319 * Checks if a member is on the team of a blog and return his rights
5321 * @param string $blogName name of weblog
5324 private function ifOnTeam($blogName = '')
5326 global $blog, $member, $manager;
5328 // when no blog found
5329 if ( ($blogName == '') && !is_object($blog) )
5334 // explicit blog selection
5335 if ($blogName != '')
5337 $blogid = getBlogIDFromName($blogName);
5340 if (($blogName == '') || !$manager->existsBlogID($blogid))
5343 $blogid = $blog->getID();
5345 return $member->teamRights($blogid);
5349 * AdminActions::ifAdmin()
5350 * Checks if a member is admin of a blog
5352 * @param string $blogName name of weblog
5355 private function ifAdmin($blogName = '')
5357 global $blog, $member, $manager;
5359 // when no blog found
5360 if (($blogName == '') && (!is_object($blog)))
5365 // explicit blog selection
5366 if ($blogName != '')
5368 $blogid = getBlogIDFromName($blogName);
5371 if (($blogName == '') || !$manager->existsBlogID($blogid))
5374 $blogid = $blog->getID();
5377 return $member->isBlogAdmin($blogid);
5381 * AdminActions::ifAddresscange()
5382 * Check e-Mail address is changed
5387 private function ifAddresscange()
5389 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5394 $info = MEMBER::getActivationInfo($key);
5399 $mem = MEMBER::createFromId($info->vmember);
5404 if ( $info->vtype == 'addresschange' )
5412 * AdminActions::templateEditRow()
5415 * @param array $template
5416 * @param string $desc
5417 * @param string $name
5418 * @param string $help
5419 * @param integer $tabindex
5420 * @param boolean $big
5421 * @param array $tmplt
5424 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5428 if ( !array_key_exists($name, $template) )
5430 $template[$name] = '';
5438 $tmplt = skinableTEMPLATE::read($tplt);
5442 'description' => $desc,
5443 'help' => empty($help) ? '' : helpHtml('template' . $help),
5446 'tabindex' => $tabindex,
5447 'rows' => $big ? 10 : 5,
5450 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5452 $base['head'] = "</tr>"
5454 . "<td><%description%><%help%></td>\n"
5455 . "<td id=\"td<%count%>\">\n"
5456 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5460 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5463 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5465 $base['tail'] = "</textarea>\n"
5470 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5473 echo TEMPLATE::fill($base['head'], $data);
5474 echo ENTITY::hsc($template[$name]);
5475 echo TEMPLATE::fill($base['tail'], $data);
5483 * AdminActions::customHelp()
5484 * shows a link to custom help file
5487 * @param string $tplName
5488 * @param string $url
5489 * @param string $iconURL
5490 * @param string $alt
5491 * @param string $title
5495 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5497 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5501 * AdminActions::customHelp()
5502 * shows a link to custom help file
5505 * @param string $tplName
5506 * @param string $url
5507 * @param string $iconURL
5508 * @param string $alt
5509 * @param string $title
5513 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5517 $templates = array();
5521 $templates = Template::read($tplName);
5524 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5526 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5530 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5535 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5538 if ( empty($onclick) )
5540 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5542 elseif ( preg_match('#^onclick#', $onclick) )
5544 $onclick = $onclick;
5548 $onclick = 'onclick="' . $onclick . '"';
5553 'helptarget' => $id,
5554 'onclick' => $onclick,
5555 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5557 return Template::fill($template, $data);
5561 * AdminActions::customHelpHtml()
5564 * @param string $tplName
5565 * @param string $url
5566 * @param string $iconURL
5567 * @param string $alt
5568 * @param string $title
5569 * @param string $onclick
5570 * @return string anchor element with help uri
5572 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5576 $templates = array();
5580 $templates = Template::read($tplName);
5582 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5584 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5588 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5591 if ( empty($iconURL) )
5593 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5596 if ( function_exists('getimagesize') )
5598 $size = getimagesize($iconURL);
5599 $width = 'width="' . $size[0] . '" ';
5600 $height = 'height="' . $size[1] . '" ';
5604 'iconurl' => $iconURL,
5606 'height' => $height,
5607 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5608 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5611 $icon = Template::fill($template, $data);
5612 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5614 return $help . $icon;
5618 * AdminActions::input_yesno
5621 * @param $checkedval
5628 * @param $templateName
5631 public function input_yesno($name,
5642 $templates = array();
5643 if ( $templateName )
5645 $templates = Template::read($templateName);
5648 if ( $name == 'admin' )
5650 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5652 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5653 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5654 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5655 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5659 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5664 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5666 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5670 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5672 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5675 if ( !isset($template) )
5677 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5678 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5679 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5680 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5685 $id = Entity::hsc($name);
5686 $id = str_replace('[', '-', $id);
5687 $id = str_replace(']', '-', $id);
5688 $id1 = $id . Entity::hsc($value1);
5689 $id2 = $id . Entity::hsc($value2);
5691 'name' => Entity::hsc($name),
5692 'yesval' => Entity::hsc($value1),
5693 'noval' => Entity::hsc($value2),
5696 'yesvaltext' => $yesval,
5697 'novaltext' => $noval,
5698 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5699 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5700 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5705 return Template::fill($template, $dat);
5709 echo Template::fill($template, $dat);
5715 * AdminActions::existsNewPlugin()
5716 * Check exists new plugin
5719 * @return boolean exists or not
5721 private function existsNewPlugin()
5723 global $DIR_PLUGINS;
5725 $candidates = array();
5726 $files = scandir($DIR_PLUGINS);
5728 foreach ( $files as $file )
5730 if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
5732 $name = $matches[1];
5733 $query = "SELECT * FROM %s WHERE pfile=%s;";
5734 $query = sprintf($query, sql_table('plugin'), DB::quoteValue("{NP_{$name}"));
5735 $res = DB::getResult($query);
5737 if ( $res->rowCount() == 0 )
5739 $candidates[] = $name;
5744 $this->newPlugCandidates = $candidates;
5745 return (count($candidates) > 0);
5749 * AdminActions::pagehead()
5750 * Output admin page head
5755 public function parse_pagehead()
5757 global $member, $nucleus, $CONF, $manager;
5759 $content = $this->parser->skin->getContentFromDB('pagehead');
5762 $extrahead = Admin::$extrahead;
5764 'extrahead' => &$extrahead,
5765 'action' => Admin::$action
5767 $manager->notify('AdminPrePageHead', $data);
5769 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5773 if ( !array_key_exists('AdminCSS', $CONF) )
5775 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5776 $CONF['AdminCSS'] = 'original';
5780 /* HTTP 1.1 application for no caching */
5781 header("Cache-Control: no-cache, must-revalidate");
5782 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5784 $root_element = 'html';
5785 $charset = i18n::get_current_charset();
5786 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5787 $xml_version_info = self::$xml_version_info;
5788 $formal_public_identifier = self::$formal_public_identifier;
5789 $system_identifier = self::$system_identifier;
5790 $xhtml_namespace = self::$xhtml_namespace;
5792 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5793 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5794 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5796 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5799 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5801 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5802 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5803 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5804 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5805 echo "{$extrahead}\n";
5808 echo "<div id=\"adminwrapper\">\n";
5809 echo "<div class=\"header\">\n";
5810 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5812 echo "<div id=\"container\">\n";
5813 echo "<div id=\"content\">\n";
5814 echo "<div class=\"loginname\">\n";
5816 if ( !$member->isLoggedIn() )
5818 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5822 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5823 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5826 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5829 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5831 $codenamestring = '';
5835 $codenamestring = ' "' . $nucleus['codename'].'"';
5838 if ( $member->isLoggedIn() && $member->isAdmin() )
5840 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5841 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5843 $newestVersion = getLatestVersion();
5844 $newestCompare = str_replace('/', '.', $newestVersion);
5845 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5847 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5850 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5851 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5857 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5864 $this->parser->parse($content);
5871 * AdminActionss::pagefoot()
5872 * Output admin page foot include quickmenu
5877 public function parse_pagefoot()
5879 global $action, $member, $manager;
5881 $content = $this->parser->skin->getContentFromDB('pagefoot');
5885 'action' => self::$action
5887 $manager->notify('AdminPrePageFoot', $data);
5889 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5891 echo '<h2>' . _LOGOUT . "</h2>\n";
5893 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5894 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5898 echo "<div class=\"foot\">\n";
5899 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5901 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5904 echo "<div id=\"quickmenu\">\n";
5906 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5909 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5912 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5913 echo "<form method=\"get\" action=\"index.php\">\n";
5915 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5917 $showAll = requestVar('showall');
5919 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5921 // Super-Admins have access to all blogs! (no add item support though)
5922 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5923 $query = sprintf($query, sql_table('blog'));
5927 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5928 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5930 $template['name'] = 'blogid';
5931 $template['tabindex'] = 15000;
5932 $template['extra'] = _QMENU_ADD_SELECT;
5933 $template['selected'] = -1;
5934 $template['shorten'] = 10;
5935 $template['shortenel'] = '';
5936 $template['javascript'] = 'onchange="return form.submit()"';
5937 showlist($query, 'select', $template);
5942 echo "<h2>{$member->getDisplayName()}</h2>\n";
5944 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5945 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5946 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5949 if ( $member->isAdmin() )
5951 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5953 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5954 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5955 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5956 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5957 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5958 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5959 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5962 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5964 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5965 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5966 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5970 $data = array('options' => array());
5972 $manager->notify('QuickMenu', $data);
5974 if ( count($data['options']) > 0 )
5976 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5978 foreach ( $data['options'] as $option )
5980 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5985 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5988 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5992 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5995 echo "<!-- quickmenu -->\n";
5998 echo "<!-- content -->\n";
6001 echo "<!-- container -->\n";
6004 echo "<!-- adminwrapper -->\n";
6012 $this->parser->skin->parse('pagefoot');