$split_same_checked = ''; $mybb->input['deleteposts'] = '0'; $mybb->input['mergeposts'] = '0'; $mybb->input['approveposts'] = ''; $mybb->input['splitposts'] = '-1'; $mybb->input['splitpostsclose'] = '0'; $mybb->input['splitpostsstick'] = '0'; $mybb->input['splitpostsunapprove'] = '0'; $mybb->input['splitpostsnewsubject'] = '{subject}'; $mybb->input['splitpostsaddreply'] = ''; $mybb->input['splitpostsreplysubject'] = '{subject}'; } $form_container = new FormContainer($lang->general_options); $form_container->output_row($lang->name . " <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); $form_container->output_row($lang->short_description . " <em>*</em>", '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description'); $actions = "<script type=\"text/javascript\">\n function checkAction(id)\n {\n var checked = '';\n \n \$\$('.'+id+'s_check').each(function(e)\n {\n if(e.checked == true)\n {\n checked = e.value;\n }\n });\n \$\$('.'+id+'s').each(function(e)\n {\n \tElement.hide(e);\n });\n if(\$(id+'_'+checked))\n {\n Element.show(id+'_'+checked);\n }\n } \n</script>\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td valign=\"top\"><small>{$lang->forums_colon}</small></td>\n\t\t\t\t\t<td>" . $form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5)) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t</dl>\n\t<script type=\"text/javascript\">\n\tcheckAction('forum');\n\t</script>"; $form_container->output_row($lang->available_in_forums . " <em>*</em>", '', $actions); $form_container->end(); $approve_unapprove = array('' => $lang->no_change, 'approve' => $lang->approve, 'unapprove' => $lang->unapprove, 'toggle' => $lang->toggle); $form_container = new FormContainer($lang->inline_post_moderation); $form_container->output_row($lang->delete_posts . " <em>*</em>", '', $form->generate_yes_no_radio('deleteposts', $mybb->input['deleteposts'])); $form_container->output_row($lang->merge_posts . " <em>*</em>", $lang->merge_posts_desc, $form->generate_yes_no_radio('mergeposts', $mybb->input['mergeposts'])); $form_container->output_row($lang->approve_unapprove_posts . " <em>*</em>", '', $form->generate_select_box('approveposts', $approve_unapprove, $mybb->input['approveposts'], array('id' => 'approveposts')), 'approveposts'); $form_container->end(); $selectoptions = "<option value=\"-1\"{$do_not_split_checked}>{$lang->do_not_split}</option>\n"; $selectoptions .= "<option value=\"-2\"{$split_same_checked} style=\"border-bottom: 1px solid #000;\">{$lang->split_to_same_forum}</option>\n"; $form_container = new FormContainer($lang->split_posts); $form_container->output_row($lang->split_posts2 . " <em>*</em>", '', $form->generate_forum_select('splitposts', $mybb->input['splitposts'])); $form_container->output_row($lang->close_split_thread . " <em>*</em>", '', $form->generate_yes_no_radio('splitpostsclose', $mybb->input['splitpostsclose'])); $form_container->output_row($lang->stick_split_thread . " <em>*</em>", '', $form->generate_yes_no_radio('splitpostsstick', $mybb->input['splitpostsstick'])); $form_container->output_row($lang->unapprove_split_thread . " <em>*</em>", '', $form->generate_yes_no_radio('splitpostsunapprove', $mybb->input['splitpostsunapprove']));
// Do we need to construct the pagination? if ($rescount > $perpage) { echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools/modlog&perpage={$perpage}&uid={$mybb->input['uid']}&fid={$mybb->input['fid']}&sortby={$mybb->input['sortby']}&order={$order}") . "<br />"; } // Fetch filter options $sortbysel[$mybb->input['sortby']] = "selected=\"selected\""; $ordersel[$mybb->input['order']] = "selected=\"selected\""; $user_options[''] = $lang->all_moderators; $user_options['0'] = '----------'; $query = $db->query("\n\t\tSELECT DISTINCT l.uid, u.username\n\t\tFROM " . TABLE_PREFIX . "moderatorlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (l.uid=u.uid)\n\t\tORDER BY u.username ASC\n\t"); while ($user = $db->fetch_array($query)) { $selected = ''; if ($mybb->input['uid'] == $user['uid']) { $selected = "selected=\"selected\""; } $user_options[$user['uid']] = $user['username']; } $sort_by = array('dateline' => $lang->date, 'username' => $lang->username, 'forum' => $lang->forum_name, 'thread' => $lang->thread_subject); $order_array = array('asc' => $lang->asc, 'desc' => $lang->desc); $form = new Form("index.php?module=tools/modlog", "post"); $form_container = new FormContainer($lang->filter_moderator_logs); $form_container->output_row($lang->forum, "", $form->generate_forum_select('fid', $mybb->input['fid'], array('id' => 'fid', 'main_option' => $lang->all_forums)), 'fid'); $form_container->output_row($lang->forum_moderator, "", $form->generate_select_box('uid', $user_options, $mybb->input['uid'], array('id' => 'uid')), 'uid'); $form_container->output_row($lang->sort_by, "", $form->generate_select_box('sortby', $sort_by, $mybb->input['sortby'], array('id' => 'sortby')) . " {$lang->in} " . $form->generate_select_box('order', $order_array, $order, array('id' => 'order')) . " {$lang->order}", 'order'); $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $perpage, array('id' => 'perpage')), 'perpage'); $form_container->end(); $buttons[] = $form->generate_submit_button($lang->filter_moderator_logs); $form->output_submit_wrapper($buttons); $form->end(); $page->output_footer(); }
$startdatemonth .= "<option value=\"11\" {$startmonthsel['11']}>{$lang->november}</option>\n"; $enddatemonth .= "<option value=\"11\" {$endmonthsel['11']}>{$lang->november}</option>\n"; $startdatemonth .= "<option value=\"12\" {$startmonthsel['12']}>{$lang->december}</option>\n"; $enddatemonth .= "<option value=\"12\" {$endmonthsel['12']}>{$lang->december}</option>\n"; if (isset($preview)) { $form_container = new FormContainer($lang->announcement_preview); $form_container->output_row($preview['subject'], "", $preview['message'], 'preview'); $form_container->end(); } $form_container = new FormContainer($lang->add_an_announcement); $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); $form_container->output_row($lang->start_date . " <em>*</em>", $lang->start_date_desc, "<select name=\"starttime_day\">\n{$startdateday}</select>\n \n<select name=\"starttime_month\">\n{$startdatemonth}</select>\n \n<input type=\"text\" name=\"starttime_year\" value=\"{$startdateyear}\" size=\"4\" maxlength=\"4\" class=\"text_input\" />\n - {$lang->time} " . $form->generate_text_box('starttime_time', $mybb->input['starttime_time'], array('id' => 'starttime_time', 'style' => 'width: 50px;'))); $actions = "<script type=\"text/javascript\">\n\tfunction checkAction(id)\n\t{\n\t\tvar checked = '';\n\n\t\t\$('.'+id+'s_check').each(function(e, val)\n\t\t{\n\t\t\tif(\$(this).prop('checked') == true)\n\t\t\t{\n\t\t\t\tchecked = \$(this).val();\n\t\t\t}\n\t\t});\n\t\t\$('.'+id+'s').each(function(e)\n\t\t{\n\t\t\t\$(this).hide();\n\t\t});\n\t\tif(\$('#'+id+'_'+checked))\n\t\t{\n\t\t\t\$('#'+id+'_'+checked).show();\n\t\t}\n\t}\n</script>\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"1\" {$endtime_checked[1]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->set_time}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"endtime_1\" class=\"endtimes\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td><select name=\"endtime_day\">\n{$enddateday}</select>\n \n<select name=\"endtime_month\">\n{$enddatemonth}</select>\n \n<input type=\"text\" name=\"endtime_year\" value=\"{$enddateyear}\" size=\"4\" maxlength=\"4\" />\n - {$lang->time} " . $form->generate_text_box('endtime_time', $mybb->input['endtime_time'], array('id' => 'endtime_time', 'style' => 'width: 50px;')) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"2\" {$endtime_checked[2]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->never}</strong></label></dt>\n\t</dl>\n\t<script type=\"text/javascript\">\n\tcheckAction('endtime');\n\t</script>"; $form_container->output_row($lang->end_date . " <em>*</em>", $lang->end_date_desc, $actions); $form_container->output_row($lang->message . " <em>*</em>", "", $form->generate_text_area('message', $mybb->input['message'], array('id' => 'message')), 'message'); $form_container->output_row($lang->forums_to_appear_in . " <em>*</em>", $lang->forums_to_appear_in_desc, $form->generate_forum_select('fid', $mybb->input['fid'], array('size' => 5, 'main_option' => $lang->all_forums))); $form_container->output_row($lang->allow_html . " <em>*</em>", "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml'], array('style' => 'width: 2em;'))); $form_container->output_row($lang->allow_mycode . " <em>*</em>", "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode'], array('style' => 'width: 2em;'))); $form_container->output_row($lang->allow_smilies . " <em>*</em>", "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies'], array('style' => 'width: 2em;'))); $form_container->end(); $buttons[] = $form->generate_submit_button($lang->save_announcement); $buttons[] = $form->generate_submit_button($lang->preview_announcement, array('name' => 'preview')); $form->output_submit_wrapper($buttons); $form->end(); $page->output_footer(); } if ($mybb->input['action'] == "delete") { $query = $db->simple_select("announcements", "*", "aid='{$mybb->input['aid']}'"); $announcement = $db->fetch_array($query); // Does the announcement not exist? if (!$announcement['aid']) {
$form->output_submit_wrapper($buttons); $form->end(); $page->output_footer(); } } $page->output_header($lang->find_attachments); $page->output_nav_tabs($sub_tabs, 'find_attachments'); // If we have any error messages, show them if ($errors) { $page->output_inline_error($errors); } $form = new Form("index.php?module=forum-attachments", "post"); $form_container = new FormContainer($lang->find_where); $form_container->output_row($lang->name_contains, $lang->name_contains_desc, $form->generate_text_box('filename', $mybb->input['filename'], array('id' => 'filename')), 'filename'); $form_container->output_row($lang->type_contains, "", $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype'); $form_container->output_row($lang->forum_is, "", $form->generate_forum_select('forum[]', $mybb->input['forum'], array('multiple' => true, 'size' => 5, 'id' => 'forum')), 'forum'); $form_container->output_row($lang->username_is, "", $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username'); $more_options = array("less_than" => $lang->more_than, "greater_than" => $lang->less_than); $greater_options = array("greater_than" => $lang->greater_than, "is_exactly" => $lang->is_exactly, "less_than" => $lang->less_than); $form_container->output_row($lang->date_posted_is, "", $form->generate_select_box('dateuploaded_dir', $more_options, $mybb->input['dateuploaded_dir'], array('id' => 'dateuploaded_dir')) . " " . $form->generate_text_box('dateuploaded', $mybb->input['dateuploaded'], array('id' => 'dateuploaded')) . " {$lang->days_ago}", 'dateuploaded'); $form_container->output_row($lang->file_size_is, "", $form->generate_select_box('filesize_dir', $greater_options, $mybb->input['filesize_dir'], array('id' => 'filesize_dir')) . " " . $form->generate_text_box('filesize', $mybb->input['filesize'], array('id' => 'filesize')) . " {$lang->kb}", 'dateuploaded'); $form_container->output_row($lang->download_count_is, "", $form->generate_select_box('downloads_dir', $greater_options, $mybb->input['downloads_dir'], array('id' => 'downloads_dir')) . " " . $form->generate_text_box('downloads', $mybb->input['downloads'], array('id' => 'downloads')) . "", 'dateuploaded'); $form_container->end(); $form_container = new FormContainer($lang->display_options); $sort_options = array("filename" => $lang->filename, "filesize" => $lang->filesize, "downloads" => $lang->download_count, "dateuploaded" => $lang->date_uploaded, "username" => $lang->post_username); $sort_directions = array("asc" => $lang->asc, "desc" => $lang->desc); $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby')) . " {$lang->in} " . $form->generate_select_box('order', $sort_directions, $mybb->input['order'], array('id' => 'order')), 'sortby'); $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $mybb->input['perpage'], array('id' => 'perpage')), 'perpage'); $form_container->end(); $buttons[] = $form->generate_submit_button($lang->button_find_attachments); $form->output_submit_wrapper($buttons);
} // Prepare the data if (!is_array($dlitem['grplist'])) { $dlitem['grplist'] = explode(',', $dlitem['grplist']); } // create a standard form container $form_container = new FormContainer($lang->downloads_dlmngr_edit); // create the save flag echo $form->generate_hidden_field("save", "save", array('id' => "save")) . "\n"; // display the text fields // output_row(title, desc, item, something I just set to the same as the ID) // generate_INPUTTYPE(name, vlaue, array(html modifiers)) $form_container->output_row($lang->downloads_dlmngr_title, $lang->downloads_dlmngr_title_desc, $form->generate_text_box('title', $dlitem['title'], array('id' => 'title')), 'title'); $form_container->output_row($lang->downloads_dlmngr_desc_short, $lang->downloads_dlmngr_desc_short_desc, $form->generate_text_box('desc_short', $dlitem['desc_short'], array('id' => 'desc_short')), 'desc_short'); $form_container->output_row($lang->downloads_dlmngr_description, $lang->downloads_dlmngr_description_desc, $form->generate_text_area('description', $dlitem['description'], array('id' => 'description', 'style' => 'width: 100%;')), 'description'); $form_container->output_row($lang->downloads_dlmngr_fid, $lang->downloads_dlmngr_fid_desc, $form->generate_forum_select('fid', $dlitem['fid'], array('id' => 'fid', 'main_option' => $lang->none)), 'fid'); $query = $db->simple_select("downloads_catlist", "*", "1=1"); while ($cat = $db->fetch_array($query)) { $categories[$cat['catid']] = $cat['title']; } $form_container->output_row($lang->downloads_dlmngr_cat, $lang->downloads_dlmngr_cat_desc, $form->generate_select_box('cat', $categories, $dlitem['cat'], array('id' => 'cat')), 'cat'); $form_container->output_row($lang->downloads_dlmngr_grpflag, $lang->downloads_dlmngr_grpflag_desc, $form->generate_check_box('grpflag', '1', $lang->downloads_dlmngr_grpflag_desc_option, array('checked' => $dlitem['grpflag'])), 'grpflag'); $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title')); while ($usergroup = $db->fetch_array($query)) { $options[$usergroup['gid']] = $usergroup['title']; $display_group_options[$usergroup['gid']] = $usergroup['title']; } $form_container->output_row($lang->downloads_dlmngr_grpflag, $lang->downloads_dlmngr_grpflag_desc, $form->generate_select_box('grplist[]', $options, $dlitem['grplist'], array('multiple' => true, 'size' => 5)), 'grplist'); $form_container->output_row($lang->downloads_dlmngr_preview, $lang->downloads_dlmngr_preview_desc, $form->generate_text_box('preview', $dlitem['preview'], array('id' => 'preview')), 'preview'); $form_container->output_row($lang->downloads_dlmngr_filename, $lang->downloads_dlmngr_filename_desc, $form->generate_text_box('filename', $dlitem['filename'], array('id' => 'filename')), 'filename'); // end the container
while ($existing = $db->fetch_array($query)) { $existing_permissions[$existing['gid']] = $existing; } $types = array('f' => $lang->forum, 'c' => $lang->category); $create_a_options_f = array('id' => 'forum'); $create_a_options_c = array('id' => 'category'); if ($forum_data['type'] == "f") { $create_a_options_f['checked'] = true; } else { $create_a_options_c['checked'] = true; } $form_container = new FormContainer($lang->edit_forum); $form_container->output_row($lang->forum_type, $lang->forum_type_desc, $form->generate_radio_button('type', 'f', $lang->forum, $create_a_options_f) . "<br />\n" . $form->generate_radio_button('type', 'c', $lang->category, $create_a_options_c)); $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $forum_data['title'], array('id' => 'title')), 'title'); $form_container->output_row($lang->description, "", $form->generate_text_area('description', $forum_data['description'], array('id' => 'description')), 'description'); $form_container->output_row($lang->parent_forum . " <em>*</em>", $lang->parent_forum_desc, $form->generate_forum_select('pid', $forum_data['pid'], array('id' => 'pid', 'main_option' => $lang->none)), 'pid'); $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $forum_data['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder'); $form_container->end(); $form_container = new FormContainer($lang->additional_forum_options); $form_container->output_row($lang->forum_link, $lang->forum_link_desc, $form->generate_text_box('linkto', $forum_data['linkto'], array('id' => 'linkto')), 'linkto'); $form_container->output_row($lang->forum_password, $lang->forum_password_desc, $form->generate_text_box('password', $forum_data['password'], array('id' => 'password')), 'password'); $access_options = array($form->generate_check_box('active', 1, $lang->forum_is_active . "<br />\n<small>{$lang->forum_is_active_desc}</small>", array('checked' => $forum_data['active'], 'id' => 'active')), $form->generate_check_box('open', 1, $lang->forum_is_open . "<br />\n<small>{$lang->forum_is_open_desc}</small>", array('checked' => $forum_data['open'], 'id' => 'open'))); $form_container->output_row($lang->access_options, "", "<div class=\"forum_settings_bit\">" . implode("</div><div class=\"forum_settings_bit\">", $access_options) . "</div>"); $styles = array('0' => $lang->use_default); $query = $db->simple_select("themes", "tid,name", "name!='((master))' AND name!='((master-backup))'", array('order_by' => 'name')); while ($style = $db->fetch_array($query)) { $styles[$style['tid']] = $style['name']; } $style_options = array($form->generate_check_box('overridestyle', 1, $lang->override_user_style, array('checked' => $forum_data['overridestyle'], 'id' => 'overridestyle')), $lang->forum_specific_style . "<br />\n" . $form->generate_select_box('style', $styles, $forum_data['style'], array('id' => 'style'))); $form_container->output_row($lang->style_options, "", "<div class=\"forum_settings_bit\">" . implode("</div><div class=\"forum_settings_bit\">", $style_options) . "</div>"); $display_methods = array('0' => $lang->dont_display_rules, '1' => $lang->display_rules_inline, '3' => $lang->display_rules_inline_new, '2' => $lang->display_rules_link);
$selected_values = explode(',', (string) $setting['value']); foreach ($selected_values as &$value) { $value = (int) $value; } unset($value); } $forum_checked = array('all' => '', 'custom' => '', 'none' => ''); if ($setting['value'] == -1) { $forum_checked['all'] = 'checked="checked"'; } elseif ($setting['value'] != '') { $forum_checked['custom'] = 'checked="checked"'; } else { $forum_checked['none'] = 'checked="checked"'; } print_selection_javascript(); $setting_code = "\n\t\t\t\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">\n\t\t\t\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"all\" {$forum_checked['all']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>\n\t\t\t\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"custom\" {$forum_checked['custom']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>\n\t\t\t\t\t<dd style=\"margin-top: 4px;\" id=\"{$element_id}_forums_groups_custom\" class=\"{$element_id}_forums_groups\">\n\t\t\t\t\t\t<table cellpadding=\"4\">\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td valign=\"top\"><small>{$lang->forums_colon}</small></td>\n\t\t\t\t\t\t\t\t<td>" . $form->generate_forum_select('select[' . $setting['name'] . '][]', $selected_values, array('id' => $element_id, 'multiple' => true, 'size' => 5)) . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</dd>\n\t\t\t\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"{$element_name}\" value=\"none\" {$forum_checked['none']} class=\"{$element_id}_forums_groups_check\" onclick=\"checkAction('{$element_id}');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>\n\t\t\t\t</dl>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tcheckAction('{$element_id}');\n\t\t\t\t</script>"; } else { if ($type[0] == "forumselectsingle") { $selected_value = (int) $setting['value']; // No need to check if empty, int will give 0 $setting_code = $form->generate_forum_select($element_name, $selected_value, array('id' => $element_id, 'main_option' => $lang->none)); } else { if ($type[0] == "groupselect") { $selected_values = ''; if ($setting['value'] != '' && $setting['value'] != -1) { $selected_values = explode(',', (string) $setting['value']); foreach ($selected_values as &$value) { $value = (int) $value; } unset($value); }
$forum_checked[1] = ''; $forum_checked[2] = "checked=\"checked\""; } $mybb->input['group_1_groups'] = explode(",", $threadprefix['groups']); if (!$threadprefix['groups'] || $threadprefix['groups'] == -1) { $group_checked[1] = "checked=\"checked\""; $group_checked[2] = ''; } else { $group_checked[1] = ''; $group_checked[2] = "checked=\"checked\""; } } $form_container = new FormContainer($lang->prefix_options); $form_container->output_row($lang->prefix . ' <em>*</em>', $lang->prefix_desc, $form->generate_text_box('prefix', $mybb->input['prefix'], array('id' => 'prefix')), 'prefix'); $form_container->output_row($lang->display_style . ' <em>*</em>', $lang->display_style_desc, $form->generate_text_box('displaystyle', $mybb->input['displaystyle'], array('id' => 'displaystyle')), 'displaystyle'); $actions = "<script type=\"text/javascript\">\n function checkAction(id)\n {\n var checked = '';\n \n \$\$('.'+id+'s_check').each(function(e)\n {\n if(e.checked == true)\n {\n checked = e.value;\n }\n });\n \$\$('.'+id+'s').each(function(e)\n {\n \tElement.hide(e);\n });\n if(\$(id+'_'+checked))\n {\n Element.show(id+'_'+checked);\n }\n } \n</script>\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td valign=\"top\"><small>{$lang->forums_colon}</small></td>\n\t\t\t\t\t<td>" . $form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5)) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t</dl>\n\t<script type=\"text/javascript\">\n\tcheckAction('forum');\n\t</script>"; $form_container->output_row($lang->available_in_forums . ' <em>*</em>', '', $actions); $group_select = "\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td valign=\"top\"><small>{$lang->groups_colon}</small></td>\n\t\t\t\t\t<td>" . $form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5)) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t</dl>\n\t<script type=\"text/javascript\">\n\t\tcheckAction('group');\n\t</script>"; $form_container->output_row($lang->available_to_groups . " <em>*</em>", '', $group_select); $form_container->end(); $buttons[] = $form->generate_submit_button($lang->save_thread_prefix); $form->output_submit_wrapper($buttons); $form->end(); $page->output_footer(); } if ($mybb->input['action'] == 'delete_prefix') { $plugins->run_hooks('admin_config_thread_prefixes_delete_prefix'); $prefix = build_prefixes($mybb->input['pid']); if (!$prefix['pid']) { flash_message($lang->error_invalid_thread_prefix, 'error'); admin_redirect('index.php?module=config-thread_prefixes');
function threadfields_add_edit_handler(&$tf, $update) { global $mybb, $page, $lang, $db, $plugins, $sub_tabs; global $form; if ($update) { $title = $lang->edit_threadfield; } else { $title = $lang->add_threadfield; } $props = xthreads_threadfields_props(); if ($mybb->request_method == 'post') { foreach ($props as $field => &$prop) { if ($field == 'field') { $field = 'newfield'; } // cause you can't "continue" in a switch statement, lol... if ($field == 'forums' || $field == 'editable_gids' || $field == 'viewable_gids' || $field == 'filemaxsize' || $field == 'multival') { continue; } if ($prop['datatype'] == 'string') { $mybb->input[$field] = trim($mybb->input[$field]); } else { $mybb->input[$field] = (int) $mybb->input[$field]; } } $mybb->input['textmask'] = str_replace("", '', $mybb->input['textmask']); $mybb->input['filemaxsize'] = xthreads_size_to_bytes($mybb->input['filemaxsize']); $mybb->input['fileimage_mindim'] = strtolower(trim($mybb->input['fileimage_mindim'])); $mybb->input['fileimage_maxdim'] = strtolower(trim($mybb->input['fileimage_maxdim'])); if (!xthreads_empty($mybb->input['formatmap'])) { $fm = array(); $fms = str_replace("{\n}", "\r", str_replace("\r", '', $mybb->input['formatmap'])); foreach (explode("\n", $fms) as $map) { $map = str_replace("\r", "\n", $map); $p = strpos($map, '{|}'); if (!$p) { continue; } // can't be zero index either - blank display format used for that $fmkey = substr($map, 0, $p); if (isset($fm[$fmkey])) { $errors[] = $lang->sprintf($lang->error_dup_formatmap, htmlspecialchars_uni($fmkey)); unset($fm); break; } $fm[$fmkey] = substr($map, $p + 3); } if (isset($fm)) { $mybb->input['formatmap'] = serialize($fm); } } if (is_array($mybb->input['forums'])) { $mybb->input['forums'] = implode(',', array_unique(array_map('intval', array_map('trim', $mybb->input['forums'])))); if (empty($mybb->input['forums'])) { $mybb->input['forums'] = ''; } } else { $mybb->input['forums'] = trim($mybb->input['forums']); if ($mybb->input['forums']) { $mybb->input['forums'] = implode(',', array_unique(array_map('intval', array_map('trim', explode(',', $mybb->input['forums']))))); } if (!$mybb->input['forums']) { $mybb->input['forums'] = ''; } } if ($mybb->input['editable'] == '99') { if (is_array($mybb->input['editable_gids'])) { $mybb->input['editable_gids'] = implode(',', array_unique(array_map('intval', array_map('trim', $mybb->input['editable_gids'])))); if (empty($mybb->input['editable_gids'])) { $mybb->input['editable_gids'] = ''; } } else { $mybb->input['editable_gids'] = trim($mybb->input['editable_gids']); if ($mybb->input['editable_gids']) { $mybb->input['editable_gids'] = implode(',', array_unique(array_map('intval', array_map('trim', explode(',', $mybb->input['editable_gids']))))); } if (!$mybb->input['editable_gids']) { $mybb->input['editable_gids'] = ''; } } if ($mybb->input['editable_gids']) { $mybb->input['editable'] = 0; } else { $mybb->input['editable'] = XTHREADS_EDITABLE_NONE; } // no group ids selected } else { $mybb->input['editable'] = min_max((int) $mybb->input['editable'], XTHREADS_EDITABLE_ALL, XTHREADS_EDITABLE_NONE); $mybb->input['editable_gids'] = ''; } $mybb->input['hidefield'] = 0; foreach (array('input' => XTHREADS_HIDE_INPUT, 'thread' => XTHREADS_HIDE_THREAD) as $k => $v) { if ($mybb->input['hidefield_' . $k]) { $mybb->input['hidefield'] |= $v; } } if (!xthreads_empty($mybb->input['editable_values'])) { $ev = array(); $evs = str_replace("{\n}", "\r", str_replace("\r", '', $mybb->input['editable_values'])); foreach (explode("\n", $evs) as $editable_value) { $editable_value = str_replace("\r", "\n", $editable_value); $p = strpos($editable_value, '{|}'); if ($p === false) { continue; } $evkey = substr($editable_value, 0, $p); if (isset($ev[$evkey])) { $errors[] = $lang->sprintf($lang->error_dup_editable_value, htmlspecialchars_uni($evkey)); unset($ev); break; } $ev[$evkey] = array_unique(array_map('intval', explode(',', substr($editable_value, $p + 3)))); // remove '0' element if (($zerorm = array_search(0, $ev[$evkey])) !== false) { unset($ev[$evkey][$zerorm]); } } if (isset($ev)) { $mybb->input['editable_values'] = serialize($ev); } } if (is_array($mybb->input['viewable_gids'])) { $mybb->input['viewable_gids'] = implode(',', array_unique(array_map('intval', array_map('trim', $mybb->input['viewable_gids'])))); if (empty($mybb->input['viewable_gids'])) { $mybb->input['viewable_gids'] = ''; } } else { $mybb->input['viewable_gids'] = trim($mybb->input['viewable_gids']); if ($mybb->input['viewable_gids']) { $mybb->input['viewable_gids'] = implode(',', array_unique(array_map('intval', array_map('trim', explode(',', $mybb->input['viewable_gids']))))); } if (!$mybb->input['viewable_gids']) { $mybb->input['viewable_gids'] = ''; } } $mybb->input['sanitize'] = min_max((int) $mybb->input['sanitize'], XTHREADS_SANITIZE_HTML, XTHREADS_SANITIZE_NONE); //if($mybb->input['sanitize'] == XTHREADS_SANITIZE_PARSER) { $parser_opts = array('parser_nl2br' => XTHREADS_SANITIZE_PARSER_NL2BR, 'parser_nobadw' => XTHREADS_SANITIZE_PARSER_NOBADW, 'parser_html' => XTHREADS_SANITIZE_PARSER_HTML, 'parser_mycode' => XTHREADS_SANITIZE_PARSER_MYCODE, 'parser_mycodeimg' => XTHREADS_SANITIZE_PARSER_MYCODEIMG, 'parser_mycodevid' => XTHREADS_SANITIZE_PARSER_VIDEOCODE, 'parser_smilies' => XTHREADS_SANITIZE_PARSER_SMILIES); foreach ($parser_opts as $opt => $n) { if ($mybb->input[$opt]) { $mybb->input['sanitize'] |= $n; } } //} $mybb->input['inputtype'] = min_max((int) $mybb->input['inputtype'], XTHREADS_INPUT_TEXT, XTHREADS_INPUT_FILE_URL); if (xthreads_empty($mybb->input['title'])) { $errors[] = $lang->error_missing_title; } if (xthreads_empty($mybb->input['newfield'])) { $errors[] = $lang->error_missing_field; } if (!xthreads_empty($mybb->input['textmask'])) { // test for bad regex xthreads_catch_errorhandler(); @preg_match('~' . str_replace('~', '\\~', $mybb->input['textmask']) . '~si', 'testvalue'); restore_error_handler(); if (!empty($GLOBALS['_previous_error'])) { $errmsg =& $GLOBALS['_previous_error'][1]; if (substr($errmsg, 0, 12) == 'preg_match()') { $p = strpos($errmsg, ':', 12); if ($p) { $errmsg = trim(substr($errmsg, $p + 1)); } else { $errmsg = trim(substr($errmsg, 12)); } $errors[] = $lang->sprintf($lang->error_bad_textmask, $errmsg); } } } switch ($mybb->input['inputtype']) { case XTHREADS_INPUT_SELECT: case XTHREADS_INPUT_RADIO: case XTHREADS_INPUT_CHECKBOX: $mybb->input['sanitize'] = $mybb->input['inputtype'] == XTHREADS_INPUT_SELECT ? XTHREADS_SANITIZE_HTML : XTHREADS_SANITIZE_NONE; $mybb->input['textmask'] = ''; // must have value defined if (xthreads_empty($mybb->input['vallist'])) { $errors[] = $lang->error_require_valllist; } break; case XTHREADS_INPUT_TEXTAREA: case XTHREADS_INPUT_FILE: case XTHREADS_INPUT_FILE_URL: $mybb->input['allowfilter'] = 0; $mybb->input['vallist'] = ''; break; case XTHREADS_INPUT_TEXT: $mybb->input['vallist'] = ''; } if ($mybb->input['multival_enable'] || $mybb->input['inputtype'] == XTHREADS_INPUT_CHECKBOX) { if (xthreads_empty($mybb->input['multival'])) { $errors[] = $lang->error_require_multival_delimiter; } // force textual datatype if ($mybb->input['datatype'] !== XTHREADS_DATATYPE_TEXT) { $mybb->input['datatype'] = XTHREADS_DATATYPE_TEXT; } } else { $mybb->input['multival'] = ''; } if ($mybb->input['use_formhtml']) { if (xthreads_empty($mybb->input['formhtml'])) { $errors[] = $lang->error_require_formhtml; } } else { $mybb->input['formhtml'] = ''; } if ($mybb->input['datatype'] !== XTHREADS_DATATYPE_TEXT) { // verify value list if applicable /* if($mybb->input['inputtype'] == XTHREADS_INPUT_SELECT || $mybb->input['inputtype'] == XTHREADS_INPUT_RADIO) { // maybe we won't do this... } */ $mybb->input['datatype'] = min_max($mybb->input['datatype'], XTHREADS_DATATYPE_TEXT, XTHREADS_DATATYPE_FLOAT); } $mybb->input['fileimage'] = ''; if ($mybb->input['filereqimg']) { if ($mybb->input['fileimage_mindim'] && !preg_match('~^[0-9]+x[0-9]+$~', $mybb->input['fileimage_mindim'])) { $errors[] = $lang->error_invalid_min_dims; } if ($mybb->input['fileimage_maxdim'] && !preg_match('~^[0-9]+x[0-9]+$~', $mybb->input['fileimage_maxdim'])) { $errors[] = $lang->error_invalid_max_dims; } if ($mybb->input['fileimage_mindim']) { $mybb->input['fileimage'] = $mybb->input['fileimage_mindim']; } else { $mybb->input['fileimage'] = '0x0'; } if ($mybb->input['fileimage_maxdim']) { $mybb->input['fileimage'] .= '|' . $mybb->input['fileimage_maxdim']; } } //if($mybb->input['fileimgthumbs']) { // TODO: verify format //if(!preg_match('~^[0-9]+x[0-9]+(\\|[0-9]+x[0-9]+)*$~', $mybb->input['fileimgthumbs'])) // $errors[] = $lang->error_invalid_thumb_dims; //} if ($update) { // check that sent field name is valid // and whilst we're here, check for bad conversions (eg file -> textbox) $oldfield = $db->fetch_array($db->simple_select('threadfields', '*', 'field="' . $db->escape_string($mybb->input['field']) . '"')); if (empty($oldfield)) { $errors[] = $lang->error_bad_old_field; } else { switch ($oldfield['inputtype']) { case XTHREADS_INPUT_FILE: case XTHREADS_INPUT_FILE_URL: if ($oldfield['inputtype'] != $mybb->input['inputtype']) { $errors['error_invalid_inputtype'] = $lang->error_invalid_inputtype; } break; default: if ($mybb->input['inputtype'] == XTHREADS_INPUT_FILE || $mybb->input['inputtype'] == XTHREADS_INPUT_FILE_URL) { $errors['error_invalid_inputtype'] = $lang->error_invalid_inputtype; } } } } if (!xthreads_empty($mybb->input['newfield'])) { if ($mybb->input['newfield'] == 'tid') { $errors[] = $lang->error_field_name_tid; } elseif (strlen($mybb->input['newfield']) > 50) { $errors[] = $lang->error_field_name_too_long; } elseif (!preg_match('~^[a-zA-Z0-9_]+$~', $mybb->input['newfield'])) { $errors[] = $lang->error_field_name_invalid; } elseif (isset($mybb->input['newfield'][2]) && $mybb->input['newfield'][0] == '_' && $mybb->input['newfield'][1] == '_') { // don't allow fields starting with "__" (reserved for special use) // in hindsight, special uses (eg filters) really should've used something like '~' so we don't need to do this, but it's too late now $errors[] = $lang->error_field_name_reserved; } elseif (!$update || $mybb->input['field'] != $mybb->input['newfield']) { $ftest = $db->fetch_field($db->simple_select('threadfields', 'field', 'field="' . $db->escape_string($mybb->input['newfield']) . '"'), 'field'); if (!xthreads_empty($ftest)) { $errors[] = $lang->error_field_name_in_use; } } } // check for syntax errors in conditionals // this is a bit tricky because we need the cache function to build the conditional for checking if ($update) { $test_tf = array_merge($oldfield, $mybb->input); } else { $test_tf = $mybb->input; } xthreads_buildtfcache_parseitem($test_tf); // test for bad conditional syntax foreach (array('defaultval', 'blankval', 'inputformat', 'inputvalidate', 'dispformat', 'dispitemformat', 'unviewableval', 'formhtml', 'formhtml_item') as $condcheck) { if ($test_tf[$condcheck] && !xthreads_check_evalstr($test_tf[$condcheck])) { if ($condcheck == 'formhtml_item') { $condcheck = 'formhtml'; } $tflangkey = 'threadfields_' . $condcheck; $errors[] = $lang->sprintf($lang->error_bad_conditional, $lang->{$tflangkey}); } } if (!xthreads_empty($test_tf['formatmap'])) { foreach ($test_tf['formatmap'] as &$fm) { if ($fm && !xthreads_check_evalstr($fm)) { $errors[] = $lang->sprintf($lang->error_bad_conditional, $lang->threadfields_formatmap); break; } } } if (!xthreads_empty($test_tf['fileimgthumbs'])) { foreach ($test_tf['fileimgthumbs'] as $thumb => $chain) { if ($chain) { if (!xthreads_check_evalstr('".$img->' . $chain . '."')) { $errors[] = $lang->sprintf($lang->error_bad_conditional, $lang->threadfields_fileimgthumbs); break; } } } } if (!$errors) { $new_tf = array(); foreach (array_keys($props) as $field) { if ($field == 'field') { $new_tf[$field] = $db->escape_string($mybb->input['newfield']); } else { $new_tf[$field] = $db->escape_string($mybb->input[$field]); } } if ($mybb->input['inputtype'] == XTHREADS_INPUT_FILE) { if (xthreads_empty($mybb->input['multival'])) { $fieldtype = xthreads_db_fielddef('int', null, true) . ' not null default 0'; } else { $fieldtype = 'varchar(255) not null default ""'; } // we'll stick a hard limit of 25 files } elseif ($mybb->input['inputtype'] == XTHREADS_INPUT_FILE_URL) { $fieldtype = 'varchar(255) not null default ""'; } else { switch ($new_tf['datatype']) { case XTHREADS_DATATYPE_INT: case XTHREADS_DATATYPE_UINT: $fieldtype = xthreads_db_fielddef('int', null, $new_tf['datatype'] == XTHREADS_DATATYPE_UINT) . ' default null'; break; case XTHREADS_DATATYPE_BIGINT: case XTHREADS_DATATYPE_BIGUINT: $fieldtype = xthreads_db_fielddef('bigint', null, $new_tf['datatype'] == XTHREADS_DATATYPE_BIGUINT) . ' default null'; break; case XTHREADS_DATATYPE_FLOAT: $fieldtype = 'double default null'; break; default: switch ($mybb->input['inputtype']) { case XTHREADS_INPUT_TEXTAREA: $fieldtype = 'text not null'; break; case XTHREADS_INPUT_SELECT: case XTHREADS_INPUT_RADIO: if ($new_tf['multival'] === '' || $mybb->input['inputtype'] == XTHREADS_INPUT_RADIO) { $fieldtype = 'varchar(255) not null default ""'; $using_long_varchar = false; break; } default: if ($new_tf['allowfilter']) { // initially, try 1024 chars $fieldtype = 'varchar(1024) not null default ""'; $using_long_varchar = true; } else { $fieldtype = 'text not null'; } } } } if ($update) { $plugins->run_hooks('admin_config_threadfields_edit_commit'); $db->update_query('threadfields', $new_tf, 'field="' . $db->escape_string($mybb->input['field']) . '"'); $alterations = array(); // TODO: perhaps only run this query if necessary //if($mybb->input['field'] != $mybb->input['newfield']) $alterfield_base = 'CHANGE `' . $db->escape_string($mybb->input['field']) . '` `' . $new_tf['field'] . '` '; $alterations['field'] = $alterfield_base . $fieldtype; if ((bool) $new_tf['allowfilter'] != (bool) $oldfield['allowfilter']) { if ($new_tf['allowfilter']) { $alterations['addkey'] = 'ADD KEY `' . $new_tf['field'] . '` (`' . $new_tf['field'] . '`)'; } else { $alterations['dropkey'] = 'DROP KEY `' . $db->escape_string($mybb->input['field']) . '`'; } } elseif ($new_tf['allowfilter'] && $mybb->input['field'] != $mybb->input['newfield']) { // change key name - only way to do this in MySQL appears to be recreating the key... $alterations['dropkey'] = 'DROP KEY `' . $db->escape_string($mybb->input['field']) . '`'; $alterations['addkey'] = 'ADD KEY `' . $new_tf['field'] . '` (`' . $new_tf['field'] . '`)'; } if (!empty($alterations)) { $qry_base = 'ALTER TABLE `' . $db->table_prefix . 'threadfields_data` '; if ($using_long_varchar) { if (!$db->write_query($qry_base . implode(', ', $alterations), true)) { $alterations['field'] = $alterfield_base . str_replace('varchar(1024)', 'varchar(255)', $fieldtype); $db->write_query($qry_base . implode(', ', $alterations)); } } else { $db->write_query($qry_base . implode(', ', $alterations)); } if ($mybb->input['field'] != $mybb->input['newfield'] && ($new_tf['inputtype'] == XTHREADS_INPUT_FILE || $new_tf['inputtype'] == XTHREADS_INPUT_FILE_URL)) { // need to update xtattachments table too! $db->update_query('xtattachments', array('field' => $new_tf['field']), 'field="' . $db->escape_string($mybb->input['field']) . '"'); } } } else { $plugins->run_hooks('admin_config_threadfields_add_commit'); $db->insert_query('threadfields', $new_tf); $addkey = ''; if ($new_tf['allowfilter']) { $addkey .= ', ADD KEY (`' . $new_tf['field'] . '`)'; } $qry_base = 'ALTER TABLE `' . $db->table_prefix . 'threadfields_data` ADD COLUMN `' . $new_tf['field'] . '` '; if ($using_long_varchar) { if (!$db->write_query($qry_base . $fieldtype . $addkey, true)) { $db->write_query($qry_base . str_replace('varchar(1024)', 'varchar(255)', $fieldtype) . $addkey); } } else { $db->write_query($qry_base . $fieldtype . $addkey); } } // Log admin action log_admin_action($new_tf['field'], htmlspecialchars_uni($mybb->input['title'])); xthreads_buildtfcache(); if ($update) { flash_message($lang->success_updated_threadfield, 'success'); } else { flash_message($lang->success_added_threadfield, 'success'); } admin_redirect(xthreads_admin_url('config', 'threadfields')); } } $page->add_breadcrumb_item($title); $page->output_header($lang->custom_threadfields . ' - ' . $title); echo '<noscript>'; $page->output_alert($lang->threadfields_enable_js); echo '</noscript>'; if (!$update) { $page->output_nav_tabs($sub_tabs, 'threadfields_add'); } if ($update) { $form = new Form(xthreads_admin_url('config', 'threadfields') . '&action=edit&field=' . urlencode($tf['field']), 'post'); } else { $form = new Form(xthreads_admin_url('config', 'threadfields&action=add'), 'post'); } if ($errors) { $page->output_inline_error($errors); $GLOBALS['data'] =& $mybb->input; } else { $GLOBALS['data'] =& $tf; } global $data; global $form_container; $form_container = new FormContainer($title); $form_container->output_row($lang->threadfields_title . ' <em>*</em>', $lang->threadfields_title_desc, $form->generate_text_box('title', $data['title'], array('id' => 'title')), 'title'); if (isset($data['newfield'])) { $key =& $data['newfield']; } else { $key =& $data['field']; } $form_container->output_row($lang->threadfields_name . ' <em>*</em>', $lang->threadfields_name_desc, $form->generate_text_box('newfield', $key, array('id' => 'newfield')), 'newfield'); if ($data['forums'] && !is_array($data['forums'])) { $data['forums'] = array_map('intval', array_map('trim', explode(',', $data['forums']))); } $form_container->output_row($lang->threadfields_forums, $lang->threadfields_forums_desc, $form->generate_forum_select('forums[]', $data['forums'], array('multiple' => true, 'size' => 5)), 'forums'); $hidefield_boxes = ''; foreach (array('input' => XTHREADS_HIDE_INPUT, 'thread' => XTHREADS_HIDE_THREAD) as $k => $v) { $l = 'threadfields_hidefield_' . $k; $ld = 'threadfields_hidefield_' . $k . '_desc'; $hidefield_boxes .= $form->generate_check_box('hidefield_' . $k, '1', $lang->{$l}, array('checked' => (bool) ($data['hidefield'] & $v))) . '<div style="margin-left: 2.25em;" class="description">' . $lang->{$ld} . '</div>'; } $form_container->output_row($lang->threadfields_hidefield, $lang->threadfields_hidefield_desc, $hidefield_boxes, 'hidefield'); $inputtypes = array(XTHREADS_INPUT_TEXT => $lang->threadfields_inputtype_text, XTHREADS_INPUT_TEXTAREA => $lang->threadfields_inputtype_textarea, XTHREADS_INPUT_SELECT => $lang->threadfields_inputtype_select, XTHREADS_INPUT_RADIO => $lang->threadfields_inputtype_radio, XTHREADS_INPUT_CHECKBOX => $lang->threadfields_inputtype_checkbox, XTHREADS_INPUT_FILE => $lang->threadfields_inputtype_file); if ($update) { // disable some conversions as they are not possible if (isset($errors['error_invalid_inputtype'])) { // but if invalid type is supplied, don't lock the user in either $inputtype = $oldfield['inputtype']; } else { $inputtype = $data['inputtype']; } if ($inputtype == XTHREADS_INPUT_FILE || $inputtype == XTHREADS_INPUT_FILE_URL) { foreach ($inputtypes as $k => &$v) { if ($k != $inputtype) { unset($inputtypes[$k]); } } } else { unset($inputtypes[XTHREADS_INPUT_FILE], $inputtypes[XTHREADS_INPUT_FILE_URL]); } } // TODO: weird issue where inputtype isn't being set... if (!ini_get('file_uploads')) { $lang->threadfields_file_name_info .= '<div style="color: red; font-style: italic;">' . $lang->threadfields_file_upload_disabled_warning . '</div>'; } make_form_row('inputtype', 'select_box', $inputtypes, '<div id="inputtype_file_explain" style="font-size: 0.95em; margin-top: 1em;">' . $lang->threadfields_file_name_info . '</div>'); make_form_row('disporder', 'text_box'); $form_container->end(); unset($GLOBALS['form_container']); global $form_container; $form_container = new FormContainer($lang->threadfields_cat_input); if ($data['editable_gids'] && !is_array($data['editable_gids'])) { $data['editable_gids'] = array_map('intval', array_map('trim', explode(',', $data['editable_gids']))); } if (!empty($data['editable_gids'])) { $data['editable'] = 99; } make_form_row('editable', 'select_box', array(XTHREADS_EDITABLE_ALL => $lang->threadfields_editable_everyone, XTHREADS_EDITABLE_REQ => $lang->threadfields_editable_requied, XTHREADS_EDITABLE_MOD => $lang->threadfields_editable_mod, XTHREADS_EDITABLE_ADMIN => $lang->threadfields_editable_admin, XTHREADS_EDITABLE_NONE => $lang->threadfields_editable_none, 99 => $lang->threadfields_editable_bygroup)); $form_container->output_row($lang->threadfields_editable_gids, $lang->threadfields_editable_gids_desc, xt_generate_group_select('editable_gids[]', $data['editable_gids'], array('multiple' => true, 'size' => 5)), 'editable_gids', array(), array('id' => 'row_editable_gids')); make_form_row('maxlen', 'text_box'); make_form_row('vallist', 'text_area'); make_form_row('fileexts', 'text_box'); if (!is_int(2147483648)) { // detect 32-bit PHP $lang->threadfields_filemaxsize_desc .= $lang->threadfields_filemaxsize_desc_2gbwarn; } // PHP upload limits $upload_max_filesize = @ini_get('upload_max_filesize'); $post_max_size = @ini_get('post_max_size'); // TODO: maybe also pull in [ file_uploads, max_file_uploads, max_input_time ] ? if ($upload_max_filesize || $post_max_size) { $lang->threadfields_filemaxsize_desc .= '<br /><br />' . $lang->threadfields_filemaxsize_desc_phplimit; if (!$lang->limit_upload_max_filesize) { $lang->load('config_attachment_types'); } if ($upload_max_filesize) { $lang->threadfields_filemaxsize_desc .= '<br />' . $lang->sprintf($lang->limit_upload_max_filesize, $upload_max_filesize); } if ($post_max_size) { $lang->threadfields_filemaxsize_desc .= '<br />' . $lang->sprintf($lang->limit_post_max_size, $post_max_size); } } make_form_row('filemaxsize', 'text_box'); make_form_row('filemagic', 'text_box'); $data['filereqimg'] = $data['fileimage'] ? 1 : 0; if (!function_exists('imagecreate')) { $lang->threadfields_filereqimg_desc .= $lang->threadfields_filereqimg_desc_nogd; } make_form_row('filereqimg', 'yes_no_radio'); unset($data['filereqimg']); $data['fileimage_mindim'] = $data['fileimage_maxdim'] = ''; if ($data['fileimage']) { list($min, $max) = explode('|', $data['fileimage']); if ($min === '0x0') { $min = ''; } $data['fileimage_mindim'] = $min; $data['fileimage_maxdim'] = $max; } make_form_row('fileimage_mindim', 'text_box'); make_form_row('fileimage_maxdim', 'text_box'); unset($data['fileimage_mindim'], $data['fileimage_maxdim']); make_form_row('fileimgthumbs', 'text_box'); $data['multival_enable'] = $data['multival'] !== '' ? 1 : 0; make_form_row('multival_enable', 'yes_no_radio'); unset($data['multival_enable']); make_form_row('multival_limit', 'text_box'); make_form_row('textmask', 'text_box'); make_form_row('inputformat', 'text_area', array('style' => 'font-family: monospace')); make_form_row('inputvalidate', 'text_area', array('style' => 'font-family: monospace')); if (!is_array($data['editable_values'])) { $ev = @unserialize($data['editable_values']); if (is_array($ev)) { $data['editable_values'] =& $ev; } } if (is_array($data['editable_values'])) { $evtxt = ''; foreach ($data['editable_values'] as $k => &$v) { // don't need to htmlspecialchar - it'll be done for us $evtxt .= str_replace("\n", "{\n}", $k) . '{|}' . implode(',', $v) . "\n"; } $data['editable_values'] =& $evtxt; } make_form_row('editable_values', 'text_area', array('style' => 'font-family: monospace')); $form_container->end(); unset($GLOBALS['form_container']); global $form_container; $form_container = new FormContainer($lang->threadfields_cat_inputfield); make_form_row('desc', 'text_box'); make_form_row('defaultval', 'text_area', array('style' => 'font-family: monospace')); make_form_row('fieldwidth', 'text_box'); make_form_row('fieldheight', 'text_box'); make_form_row('tabstop', 'yes_no_radio'); $data['use_formhtml'] = $data['formhtml'] !== '' ? 1 : 0; make_form_row('use_formhtml', 'yes_no_radio'); unset($data['use_formhtml']); $lang->threadfields_formhtml .= ' <em>*</em>'; make_form_row('formhtml', 'text_area', array('style' => 'font-family: monospace')); $form_container->end(); unset($GLOBALS['form_container']); global $form_container; $form_container = new FormContainer($lang->threadfields_cat_output); $sanitize = $data['sanitize']; $data['sanitize'] &= XTHREADS_SANITIZE_MASK; make_form_row('sanitize', 'select_box', array(XTHREADS_SANITIZE_HTML => $lang->threadfields_sanitize_plain, XTHREADS_SANITIZE_HTML_NL => $lang->threadfields_sanitize_plain_nl, XTHREADS_SANITIZE_PARSER => $lang->threadfields_sanitize_mycode, XTHREADS_SANITIZE_NONE => $lang->threadfields_sanitize_none)); $parser_opts = array('parser_nl2br' => $sanitize & XTHREADS_SANITIZE_PARSER_NL2BR, 'parser_nobadw' => $sanitize & XTHREADS_SANITIZE_PARSER_NOBADW, 'parser_html' => $sanitize & XTHREADS_SANITIZE_PARSER_HTML, 'parser_mycode' => $sanitize & XTHREADS_SANITIZE_PARSER_MYCODE, 'parser_mycodeimg' => $sanitize & XTHREADS_SANITIZE_PARSER_MYCODEIMG, 'parser_mycodevid' => $sanitize & XTHREADS_SANITIZE_PARSER_VIDEOCODE, 'parser_smilies' => $sanitize & XTHREADS_SANITIZE_PARSER_SMILIES); if ($mybb->version_code < 1600) { unset($parser_opts['parser_mycodevid']); } $parser_opts_str = ''; foreach ($parser_opts as $opt => $checked) { $langstr = 'threadfields_sanitize_' . $opt; $parser_opts_str .= '<div style="display: block;">' . $form->generate_check_box($opt, 1, $lang->{$langstr}, array('checked' => $checked ? 1 : 0)) . '</div>'; } $form_container->output_row($lang->threadfields_sanitize_parser, $lang->threadfields_sanitize_parser_desc, $parser_opts_str, 'sanitize_parser', array(), array('id' => 'parser_opts')); make_form_row('blankval', 'text_area', array('style' => 'font-family: monospace')); make_form_row('dispformat', 'text_area', array('style' => 'font-family: monospace')); $lang->threadfields_multival .= ' <em>*</em>'; make_form_row('multival', 'text_box'); $lang->threadfields_multival = substr($lang->threadfields_multival, 0, -11); make_form_row('dispitemformat', 'text_area', array('style' => 'font-family: monospace')); if (!is_array($data['formatmap'])) { $fm = @unserialize($data['formatmap']); if (is_array($fm)) { $data['formatmap'] =& $fm; } } if (is_array($data['formatmap'])) { $fmtxt = ''; foreach ($data['formatmap'] as $k => &$v) { // don't need to htmlspecialchar - it'll be done for us $fmtxt .= str_replace("\n", "{\n}", $k . '{|}' . $v) . "\n"; } $data['formatmap'] =& $fmtxt; } make_form_row('formatmap', 'text_area', array('style' => 'font-family: monospace')); if ($data['viewable_gids'] && !is_array($data['viewable_gids'])) { $data['viewable_gids'] = array_map('intval', array_map('trim', explode(',', $data['viewable_gids']))); } $form_container->output_row($lang->threadfields_viewable_gids, $lang->threadfields_viewable_gids_desc, xt_generate_group_select('viewable_gids[]', $data['viewable_gids'], array('multiple' => true, 'size' => 5, 'id' => 'viewable_gids')), 'viewable_gids', array(), array('id' => 'row_viewable_gids')); make_form_row('unviewableval', 'text_area', array('style' => 'font-family: monospace')); $form_container->end(); unset($GLOBALS['form_container']); // this will currently be empty if a file input is chosen... global $form_container; $form_container = new FormContainer($lang->threadfields_cat_misc); make_form_row('allowfilter', 'select_box', array(XTHREADS_FILTER_NONE => $lang->threadfields_filter_none, XTHREADS_FILTER_EXACT => $lang->threadfields_filter_exact, XTHREADS_FILTER_PREFIX => $lang->threadfields_filter_prefix, XTHREADS_FILTER_ANYWHERE => $lang->threadfields_filter_anywhere, XTHREADS_FILTER_WILDCARD => $lang->threadfields_filter_wildcard)); make_form_row('datatype', 'select_box', array(XTHREADS_DATATYPE_TEXT => $lang->threadfields_datatype_text, XTHREADS_DATATYPE_INT => $lang->threadfields_datatype_int, XTHREADS_DATATYPE_UINT => $lang->threadfields_datatype_uint, XTHREADS_DATATYPE_BIGINT => $lang->threadfields_datatype_bigint, XTHREADS_DATATYPE_BIGUINT => $lang->threadfields_datatype_biguint, XTHREADS_DATATYPE_FLOAT => $lang->threadfields_datatype_float)); $form_container->end(); unset($GLOBALS['form_container']); if ($update) { $buttons[] = $form->generate_submit_button($lang->update_threadfield); } else { $buttons[] = $form->generate_submit_button($lang->add_threadfield); } $form->output_submit_wrapper($buttons); $form->end(); ?> <script type="text/javascript"> <!-- var xt_inited = false; function xt_visi(o,v) { document.getElementById(o).style.display = (v ? '':'none'); } document.getElementById('sanitize').onchange = function() { xt_visi('parser_opts', this.options[this.selectedIndex].value == "<?php echo XTHREADS_SANITIZE_PARSER; ?> " && document.getElementById('row_sanitize').style.display != 'none'); }; function xt_multival_enable() { var si = parseInt(document.getElementById('inputtype').options[document.getElementById('inputtype').selectedIndex].value); var checkboxIn = (si == <?php echo XTHREADS_INPUT_CHECKBOX; ?> ); var pureFileIn = (si == <?php echo XTHREADS_INPUT_FILE; ?> ); var fileIn = (pureFileIn || si == <?php echo XTHREADS_INPUT_FILE_URL; ?> ); e = checkboxIn; // forced var datatypeText = (document.getElementById('datatype').options[document.getElementById('datatype').selectedIndex].value == "<?php echo XTHREADS_DATATYPE_TEXT; ?> "); xt_visi('row_multival_enable', checkboxIn || (( si != <?php echo XTHREADS_INPUT_RADIO; ?> && (datatypeText || pureFileIn) ))); if(!e) e = (document.getElementById('multival_enable_yes').checked && document.getElementById('row_multival_enable').style.display != 'none'); xt_visi('row_multival', e); xt_visi('row_multival_limit', e); xt_visi('row_dispitemformat', e); datatypeVisible = (!e && !checkboxIn && !fileIn); xt_visi('row_datatype', datatypeVisible); // hide some sanitise options (if browser supports it) var sanitizeOptShow = ((datatypeVisible && !datatypeText) ? 'none' : ''); for(i in document.getElementById('sanitize').options) { var optItem = document.getElementById('sanitize').options[i]; if(!optItem) continue; // fix IE6 bug if(optItem.value == "<?php echo XTHREADS_SANITIZE_HTML_NL; ?> " || optItem.value == "<?php echo XTHREADS_SANITIZE_NONE; ?> ") { // our target if(sanitizeOptShow == 'none' && document.getElementById('sanitize').selectedIndex == i) document.getElementById('sanitize').selectedIndex = 0; optItem.style.display = sanitizeOptShow; } } dispfmt_obj = document.getElementById('dispformat'); fileVal = "<a href=\"{URL}\">{FILENAME}</a>"; nonFileVal = "{VALUE}"; if(pureFileIn) { if(e) { if(document.getElementById('dispitemformat').value == nonFileVal) { if(dispfmt_obj.value == nonFileVal) document.getElementById('dispitemformat').value = fileVal; else { // swap dispformat <-> dispitemformat document.getElementById('dispitemformat').value = dispfmt_obj.value; dispfmt_obj.value = nonFileVal; } } if(dispfmt_obj.value == fileVal) dispfmt_obj.value = nonFileVal; } else { if(dispfmt_obj.value == nonFileVal) { dispfmt_obj.value = fileVal; if(document.getElementById('dispitemformat').value != nonFileVal) { // maybe swap? var DIFval = document.getElementById('dispitemformat').value.toUpperCase(); if((function(s){ for(i in s) if(DIFval.indexOf("{"+s[i]+"}") > -1) return true; return false; })( ["DOWNLOADS","DOWNLOADS_FRIENDLY","FILENAME","UPLOADMIME","URL","FILESIZE","FILESIZE_FRIENDLY","MD5HASH","UPLOADTIME","UPLOAD_TIME","UPLOAD_DATE","UPDATETIME","UPDATE_TIME","UPDATE_DATE","THUMBS","DIMS","MODIFIED"] )) { dispfmt_obj.value = document.getElementById('dispitemformat').value; document.getElementById('dispitemformat').value = nonFileVal; } } } if(document.getElementById('dispitemformat').value == fileVal) document.getElementById('dispitemformat').value = nonFileVal; } } else { if(document.getElementById('dispitemformat').value == fileVal) document.getElementById('dispitemformat').value = nonFileVal; if(dispfmt_obj.value == fileVal) dispfmt_obj.value = nonFileVal; } } document.getElementById('multival_enable_yes').onclick = xt_multival_enable; document.getElementById('multival_enable_no').onclick = xt_multival_enable; (document.getElementById('use_formhtml_yes').onclick = document.getElementById('use_formhtml_no').onclick = xt_use_formhtml = function() { xt_visi('row_formhtml', document.getElementById('use_formhtml_yes').checked); xt_visi('formhtml_desc_js', true); })(); function xt_filereqimg() { var e = (document.getElementById('filereqimg_yes').checked && document.getElementById('row_filereqimg').style.display != 'none'); xt_visi('row_fileimage_mindim', e); xt_visi('row_fileimage_maxdim', e); xt_visi('row_fileimgthumbs', e); } document.getElementById('filereqimg_yes').onclick = xt_filereqimg; document.getElementById('filereqimg_no').onclick = xt_filereqimg; (document.getElementById('inputtype').onchange = function() { var si = parseInt(this.options[this.selectedIndex].value); var pureFileIn = (si == <?php echo XTHREADS_INPUT_FILE; ?> ); var fileIn = (pureFileIn || si == <?php echo XTHREADS_INPUT_FILE_URL; ?> ); var radioIn = (si == <?php echo XTHREADS_INPUT_RADIO; ?> ); var checkboxIn = (si == <?php echo XTHREADS_INPUT_CHECKBOX; ?> ); var selectBoxIn = (si == <?php echo XTHREADS_INPUT_SELECT; ?> ); var selectIn = (selectBoxIn || radioIn || checkboxIn); var textAreaIn = (si == <?php echo XTHREADS_INPUT_TEXTAREA; ?> ); var textIn = (textAreaIn || si == <?php echo XTHREADS_INPUT_TEXT; ?> ); xt_visi('row_sanitize', !fileIn && !selectIn); document.getElementById('sanitize').onchange(); xt_visi('inputtype_file_explain', pureFileIn); xt_visi('row_allowfilter', !fileIn && !textAreaIn); xt_visi('row_formatmap', !fileIn); xt_visi('row_editable_values', !fileIn); xt_visi('row_defaultval', !pureFileIn); xt_visi('row_textmask', textIn); xt_visi('row_inputformat', !fileIn); xt_visi('row_maxlen', textIn); xt_visi('row_fieldwidth', textIn || fileIn || selectBoxIn); xt_visi('row_fieldheight', textAreaIn || selectBoxIn); xt_visi('row_vallist', selectIn); //xt_visi('row_datatype', !checkboxIn && !fileIn); //xt_visi('row_multival_enable', !checkboxIn && !radioIn && !fileIn); xt_multival_enable(); xt_visi('row_filemagic', pureFileIn); xt_visi('row_fileexts', pureFileIn); xt_visi('row_filemaxsize', pureFileIn); xt_visi('row_filereqimg', pureFileIn); xt_filereqimg(); if(textAreaIn) { if(document.getElementById('sanitize').options[document.getElementById('sanitize').selectedIndex].value == "<?php echo XTHREADS_SANITIZE_HTML; ?> ") document.getElementById('sanitize').selectedIndex++; } else if(textIn) { if(document.getElementById('sanitize').options[document.getElementById('sanitize').selectedIndex].value == "<?php echo XTHREADS_SANITIZE_HTML_NL; ?> ") document.getElementById('sanitize').selectedIndex--; } var setFormhtml = true; if(document.getElementById('use_formhtml_yes').checked) { if(!xt_inited) setFormhtml = (document.getElementById("formhtml").value == ""); else setFormhtml = confirm("<?php echo xt_js_str_escape($lang->threadfields_formhtml_js_reset_warning); ?> "); if(setFormhtml) { document.getElementById('use_formhtml_no').checked = true; } xt_use_formhtml(); } switch(si) { <?php foreach (array(XTHREADS_INPUT_TEXTAREA, XTHREADS_INPUT_SELECT, XTHREADS_INPUT_CHECKBOX, XTHREADS_INPUT_RADIO, XTHREADS_INPUT_FILE, XTHREADS_INPUT_TEXT) as $inputtype) { $formhtml_info = xthreads_default_threadfields_formhtml($inputtype); $formhtml_desc = ''; foreach ($formhtml_info[1] as $fhvar) { $langvar = 'threadfields_formhtml_desc_' . strtolower($fhvar); $formhtml_desc .= '<li><code>{' . $fhvar . '}</code>: ' . $lang->{$langvar} . '</li>'; } echo ' case ' . $inputtype . ': if(setFormhtml) document.getElementById("formhtml").value = "' . xt_js_str_escape($formhtml_info[0]) . '"; document.getElementById("formhtml_desc_ul_js").innerHTML = "' . xt_js_str_escape($formhtml_desc) . '"; break;'; } ?> } }).apply(document.getElementById('inputtype')); (document.getElementById('datatype').onchange = function() { //var isText = this.options[this.selectedIndex].value == "<?php echo XTHREADS_DATATYPE_TEXT; ?> "; //xt_visi('row_multival_enable', isText); xt_multival_enable(); }).apply(document.getElementById('datatype')); (document.getElementById('editable').onchange = function() { xt_visi('row_editable_gids', this.options[this.selectedIndex].value == "99"); }).apply(document.getElementById('editable')); (document.getElementById('viewable_gids').onchange = function() { var e=false; var o=document.getElementById('viewable_gids').options; for(i=0; i<o.length; i++) if(e = o[i].selected) // no, I do mean =, not == break; xt_visi('row_unviewableval', e); }).apply(document.getElementById('viewable_gids')); <?php $textmask_types = array('anything' => '^.*$', 'digit' => '^\\d+$', 'alphadigit' => '^[a-z0-9]+$', 'number' => '^(-?)([0-9]*)(?:\\.(\\d*))?(?:e([+-]?\\d*))?$', 'date' => '^(0?[1-9]|[12]\\d|3[01])/(0?[1-9]|1[012])/((?:19|20)\\d\\d)$', 'date_us' => '^(0?[1-9]|1[012])/(0?[1-9]|[12]\\d|3[01])/((?:19|20)\\d\\d)$', 'uri' => '^([^:/?#]+)\\:((//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?)$', 'url' => '^([a-z0-9]+)\\://([^/?#]+)(/([^\\r\\n"<>#?]*)(\\?([^\\r\\n"<>#]*))?(#([^\\r\\n"<>]*))?)?$', 'httpurl' => '^(https?)\\://([^/?#]+)(/([^\\r\\n"<>#?]*)(\\?([^\\r\\n"<>#]*))?(#([^\\r\\n"<>]*))?)?$', 'email' => '^(.+)@([a-z0-9_.\\-]+)$', 'emailr' => '^([^ "(),:;<>@\\[\\\\\\]]+)@([a-z0-9_.\\-]+)$', 'css' => '^[a-z0-9_\\- ]+$', 'color' => '^[a-z\\-]+|#?[0-9a-f]{6}$'); ?> document.getElementById('textmask').parentNode.innerHTML = '<select name="textmask_select" id="textmask_select">' + <?php foreach ($textmask_types as $type => &$mask) { $langvar = 'threadfields_textmask_' . $type; echo ' \'<option value="', $type, '">', $lang->{$langvar}, '</option>\' + '; } ?> '<option value="custom">'+<?php echo "'", $lang->threadfields_textmask_custom, "'"; ?> +'</option>' + '</select> ' + document.getElementById('textmask').parentNode.innerHTML + '<div id="textmask_select_descriptions" style="font-size: smaller; padding-top: 0.5em;">' + <?php foreach ($textmask_types as $type => &$mask) { $langvar = 'threadfields_textmask_' . $type . '_desc'; if (property_exists($lang, $langvar)) { echo ' \'<div id="textmask_selector_desc_', $type, '" style="display: none;">', xt_js_str_escape($lang->{$langvar}), '</div>\' + '; } } ?> '</div>'; var textmaskMapping = { <?php $comma = ''; foreach ($textmask_types as $type => &$mask) { echo $comma, ' ', $type, ': "', xt_js_str_escape($mask), '"'; if (!$comma) { $comma = ', '; } } ?> }; // determine which option to be selected by default (function() { // we can only index by number, and as we're a little lazy, create a name -> index map var textmaskSelectOpts = document.getElementById('textmask_select').options; var textmaskSelectMap = {}; for(i=0; i<textmaskSelectOpts.length; i++) { textmaskSelectMap[textmaskSelectOpts[i].value] = i; } var mask = document.getElementById('textmask').value; for(var maskName in textmaskMapping) { if(mask == textmaskMapping[maskName]) { document.getElementById('textmask_select').selectedIndex = textmaskSelectMap[maskName]; textmaskSelectUpdated(); return; } } document.getElementById('textmask_select').selectedIndex = textmaskSelectMap["custom"]; })(); document.getElementById('textmask_select').onchange = function() { var maskName = this.options[this.selectedIndex].value; if(textmaskMapping[maskName]) document.getElementById('textmask').value = textmaskMapping[maskName]; textmaskSelectUpdated(); }; document.getElementById('textmask_select').onkeypress = document.getElementById('textmask_select').onkeydown = document.getElementById('textmask_select').onkeyup = function(e) { document.getElementById('textmask_select').onchange(); return true; }; function textmaskSelectUpdated() { var maskName = document.getElementById('textmask_select').options[document.getElementById('textmask_select').selectedIndex].value; var d = (maskName != "custom"); document.getElementById('textmask').readOnly = d; document.getElementById('textmask').tabIndex = (d?'-1':''); // note, this is non-standard document.getElementById('textmask').style.background = (d ? "#F0F0F0":""); document.getElementById('textmask').style.color = (d ? "#808080":""); var o = document.getElementById('textmask_select_descriptions').childNodes; for(i=0; i<o.length; i++) { if(o[i].id == "textmask_selector_desc_"+maskName) o[i].style.display = ""; else o[i].style.display = "none"; } } document.getElementById('textmask').onfocus = function() { if(this.readOnly) document.getElementById('textmask_select').focus(); }; xt_inited = true; //--> </script> <script type="text/javascript" src="jscripts/xtofedit.js?xtver=<?php echo XTHREADS_VERSION; ?> "></script> <script type="text/javascript"> <!-- xtOFEditorLang.confirmFormSubmit = "<?php echo $lang->xthreads_js_confirm_form_submit; ?> "; xtOFEditorLang.windowTitle = "<?php echo $lang->xthreads_js_edit_value; ?> "; xtOFEditorLang.saveButton = "<?php echo $lang->xthreads_js_save_changes; ?> "; xtOFEditorLang.closeSaveChanges = "<?php echo $lang->xthreads_js_close_save_changes; ?> "; var fmtMapEditor = new xtOFEditor(); fmtMapEditor.src = document.getElementById('formatmap'); fmtMapEditor.loadFunc = function(s) { var a = s.replace(/\r/g, "").replace(/\{\n\}/g, "\r").split("\n"); var data = []; for(var i=0; i<a.length; i++) { a[i] = a[i].replace(/\r/g, "\n"); var p = a[i].indexOf("{|}"); if(p < 0) continue; data.push([ a[i].substring(0, p), a[i].substring(p+3) ]); } return data; }; fmtMapEditor.saveFunc = function(a) { var ret = ""; for(var i=0; i<a.length; i++) { ret += a[i].join("{|}").replace(/\n/g, "{\n}") + "\n"; } return ret; }; fmtMapEditor.fields = [ {title: "<?php echo $lang->xthreads_js_formatmap_from; ?> ", width: '45%', elemFunc: fmtMapEditor.textAreaFunc}, {title: "<?php echo $lang->xthreads_js_formatmap_to; ?> ", width: '55%', elemFunc: fmtMapEditor.textAreaFunc} ]; fmtMapEditor.copyStyles=true; fmtMapEditor.init(); var editValEditor = new xtOFEditor(); editValEditor.src = document.getElementById('editable_values'); editValEditor.loadFunc = function(s) { var a = s.replace(/\r/g, "").replace(/\{\n\}/g, "\r").split("\n"); var data = []; for(var i=0; i<a.length; i++) { a[i] = a[i].replace(/\r/g, "\n"); var p = a[i].indexOf("{|}"); if(p < 0) continue; data.push([ a[i].substring(0, p), a[i].substring(p+3).split(",") ]); } return data; }; editValEditor.saveFunc = function(a) { var ret = ""; for(var i=0; i<a.length; i++) { ret += a[i][0].replace(/\n/g, "{\n}") + "{|}" + a[i][1].join(",") + "\n"; } return ret; }; editValEditor.fields = [ {title: "<?php echo $lang->xthreads_js_formatmap_from; ?> ", width: '50%', elemFunc: editValEditor.textAreaFunc}, {title: "<?php echo $lang->xthreads_js_editable_values_groups; ?> ", width: '50%', elemFunc: function(c) { var o = appendNewChild(c, "select"); o.multiple = true; o.size = 3; o.style.width = '100%'; o.innerHTML = '<?php foreach ($GLOBALS['cache']->read('usergroups') as $group) { echo '<option value="' . $group['gid'] . '">' . xt_js_str_escape(htmlspecialchars_uni(strip_tags($group['title']))) . '</option>'; } ?> '; return o; }} ]; editValEditor.copyStyles=true; editValEditor.init(); //--> </script><?php $page->output_footer(); }
admin_redirect("index.php?module=config-settings&action=change&gid={$gid}"); } else { $page->output_header($lang->mysupport); generate_mysupport_tabs("general"); $form = new Form("index.php?module=config-mysupport&action=do_general", "post"); $form_container = new FormContainer($lang->general_header); $table = new Table(); $table->construct_header($lang->mysupport); $current_mysupport_forums = array(); $forums = $cache->read("forums"); foreach ($forums as $forum) { if ($forum['mysupport'] == 1) { $current_mysupport_forums[] = $forum['fid']; } } $mysupport_forums = $form->generate_forum_select('mysupport_forums[]', $current_mysupport_forums, array('multiple' => true, 'size' => 5)); $form_container->output_row($lang->mysupport_forums, '', $mysupport_forums); $current_mysupport_move_forum = ""; $forums = $cache->read("forums"); foreach ($forums as $forum) { if ($forum['mysupportmove'] == 1) { $current_mysupport_move_forum = $forum['fid']; } } $mysupport_move_forum = $form->generate_forum_select('mysupport_move_forum', $current_mysupport_move_forum, array('size' => 5)); $form_container->output_row($lang->mysupport_move_forum, $lang->mysupport_move_forum_desc, $mysupport_move_forum); $current_canmarksolved_groups = array(); $groups = $cache->read("usergroups"); foreach ($groups as $group) { if ($group['canmarksolved'] == 1) { $current_canmarksolved_groups[] = $group['gid'];
if ($db->num_rows($query) != 1) { flash_message($lang->announcement_error, 'error'); admin_redirect("index.php?module=" . MODULE); } $announcement = $db->fetch_array($query); $page->add_breadcrumb_item($lang->edit, "index.php?module=" . MODULE . "&action=edit&aid={$aid}"); $page->output_header($lang->announcement); generate_tabs("list"); $form = new Form("index.php?module=" . MODULE . "&action=do_edit", "post"); $form_container = new FormContainer($lang->announcement); $add_announcement = $form->generate_text_area("announcement", $announcement['Announcement']); $form_container->output_row($lang->announcement_simple . " <em>*</em>", $lang->announcement_desc, $add_announcement); $id = "global"; $add_global = $form->generate_yes_no_radio("global", $announcement['Global'], true, array("id" => $id . "_yes", "class" => $id), array("id" => $id . "_no", "class" => $id)); $form_container->output_row($lang->announcement_global . " <em>*</em>", '', $add_global); $add_forum = $form->generate_forum_select("forum[]", @unserialize($announcement['Forum']), array("multiple" => true)); $form_container->output_row($lang->announcement_forum, $lang->announcement_forum_desc, $add_forum, '', array(), array('id' => 'forum')); $add_thread = $form->generate_text_box("thread", $announcement['tid']); $form_container->output_row($lang->announcement_thread, $lang->announcement_thread_desc, $add_thread, '', array(), array('id' => 'thread')); $add_group = $form->generate_group_select("group[]", @unserialize($announcement['Groups']), array("multiple" => true)); $form_container->output_row($lang->announcement_group, $lang->announcement_group_desc, $add_group); $languages = $lang->get_languages(); $add_languages = $form->generate_select_box("langs[]", $languages, @unserialize($announcement['Langs']), array("multiple" => true)); $form_container->output_row($lang->announcement_languages, $lang->announcement_languages_desc, $add_languages); $add_color = $form->generate_text_box("color", $announcement['Color']); $form_container->output_row($lang->announcement_color . " <em>*</em>", $lang->announcement_color_desc, $add_color); $add_back_color = $form->generate_text_box("back_color", $announcement['BackColor']); $form_container->output_row($lang->announcement_back_color . " <em>*</em>", $lang->announcement_back_color_desc, $add_back_color); $option_list = array("left" => $lang->left, "right" => $lang->right, "top" => $lang->top, "bottom" => $lang->bottom); $add_border_select = $form->generate_select_box("border_select[]", $option_list, @unserialize($announcement['Border']), array("multiple" => true, "id" => "border")); $form_container->output_row($lang->announcement_border_select . " <em>*</em>", $lang->announcement_border_select_desc, $add_border_select);
$query = $db->simple_select('newpoints_forumrules', '*', 'rid=\'' . intval($mybb->input['rid']) . '\''); $rule = $db->fetch_array($query); if (!$rule) { flash_message($lang->newpoints_forumrules_invalid, 'error'); admin_redirect("index.php?module=newpoints-forumrules"); } $form = new Form("index.php?module=newpoints-forumrules&action=edit", "post", "newpoints"); echo $form->generate_hidden_field("my_post_key", $mybb->post_code); echo $form->generate_hidden_field("rid", $rule['rid']); $form_container = new FormContainer($lang->newpoints_forumrules_editrule); $form_container->output_row($lang->newpoints_forumrules_name . "<em>*</em>", $lang->newpoints_forumrules_name_desc, $form->generate_text_box('name', htmlspecialchars_uni($rule['name']), array('id' => 'name')), 'name'); $form_container->output_row($lang->newpoints_forumrules_desc, $lang->newpoints_forumrules_desc_desc, $form->generate_text_box('description', htmlspecialchars_uni($rule['description']), array('id' => 'description')), 'description'); $form_container->output_row($lang->newpoints_forumrules_rate . "<em>*</em>", $lang->newpoints_forumrules_rate_desc, $form->generate_text_box('rate', floatval($rule['rate']), array('id' => 'rate')), 'rate'); $form_container->output_row($lang->newpoints_forumrules_minview, $lang->newpoints_forumrules_minview_desc, $form->generate_text_box('minview', intval($rule['pointsview']), array('id' => 'minview')), 'minview'); $form_container->output_row($lang->newpoints_forumrules_minpost, $lang->newpoints_forumrules_minpost_desc, $form->generate_text_box('minpost', intval($rule['pointspost']), array('id' => 'minpost')), 'minpost'); $form_container->output_row($lang->newpoints_forumrules_forum . "<em>*</em>", $lang->newpoints_forumrules_forum_desc, $form->generate_forum_select('forum', intval($rule['fid']), array('id' => 'forum', 'main_option' => $lang->newpoints_select_forum)), 'forum'); $plugins->run_hooks("newpoints_admin_forumrules_edit"); $form_container->end(); $buttons = array(); $buttons[] = $form->generate_submit_button($lang->newpoints_submit_button); $buttons[] = $form->generate_reset_button($lang->newpoints_reset_button); $form->output_submit_wrapper($buttons); $form->end(); } elseif ($mybb->input['action'] == 'delete_rule') { if ($mybb->input['no']) { admin_redirect("index.php?module=newpoints-forumrules"); } if ($mybb->request_method == "post") { if (!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key']) { $mybb->request_method = "get"; flash_message($lang->newpoints_error, 'error');