{$lang->forum_permissions}
";
}
if($mybb->input['pid'] || ($mybb->input['gid'] && $mybb->input['fid']))
{
if($mybb->input['ajax'] != 1)
{
$form = new Form("index.php?module=forum-management&action=permissions", "post");
}
else
{
$form = new Form("#", "post", "modal_form");
}
echo $form->generate_hidden_field("usecustom", "1");
if($errors)
{
$page->output_inline_error($errors);
$permission_data = $mybb->input;
$query = $db->simple_select("usergroups", "*", "gid='{$permission_data['gid']}'");
$usergroup = $db->fetch_array($query);
$query = $db->simple_select("forums", "*", "fid='{$permission_data['fid']}'");
$forum = $db->fetch_array($query);
}
else
{
$pid = intval($mybb->input['pid']);
$gid = intval($mybb->input['gid']);
$fid = intval($mybb->input['fid']);
if($pid)
{
$query = $db->simple_select("forumpermissions", "*", "pid='{$pid}'");
}
else
{
$query = $db->simple_select("forumpermissions", "*", "fid='{$fid}' AND gid='{$gid}'", array('limit' => 1));
}
$permission_data = $db->fetch_array($query);
if(!$fid)
{
$fid = $permission_data['fid'];
}
if(!$gid)
{
$gid = $permission_data['gid'];
}
if(!$pid)
{
$pid = $permission_data['pid'];
}
$query = $db->simple_select("usergroups", "*", "gid='$gid'");
$usergroup = $db->fetch_array($query);
$query = $db->simple_select("forums", "*", "fid='$fid'");
$forum = $db->fetch_array($query);
$sperms = $permission_data;
$sql = build_parent_list($fid);
$query = $db->simple_select("forumpermissions", "*", "$sql AND gid='$gid'");
$customperms = $db->fetch_array($query);
if($permission_data['pid'])
{
$permission_data['usecustom'] = 1;
echo $form->generate_hidden_field("pid", $pid);
}
else
{
echo $form->generate_hidden_field("fid", $fid);
echo $form->generate_hidden_field("gid", $gid);
if(!$customperms['pid'])
{
$permission_data = usergroup_permissions($gid);
}
else
{
$permission_data = forum_permissions($fid, 0, $gid);
}
}
}
$groups = array(
'canviewthreads' => 'viewing',
'canview' => 'viewing',
'canonlyviewownthreads' => 'viewing',
'candlattachments' => 'viewing',
'canpostthreads' => 'posting_rating',
'canpostreplys' => 'posting_rating',
'canpostattachments' => 'posting_rating',
'canratethreads' => 'posting_rating',
'caneditposts' => 'editing',
'candeleteposts' => 'editing',
'candeletethreads' => 'editing',
'caneditattachments' => 'editing',
'canpostpolls' => 'polls',
'canvotepolls' => 'polls',
'cansearch' => 'misc',
);
$groups = $plugins->run_hooks("admin_forum_management_permission_groups", $groups);
$tabs = array();
foreach(array_unique(array_values($groups)) as $group)
{
$lang_group = "group_".$group;
$tabs[$group] = $lang->$lang_group;
}
if($mybb->input['ajax'] == 1)
{
$page->output_tab_control($tabs, false, "tabs2");
}
else
{
$page->output_tab_control($tabs);
}
$field_list = array();
$fields_array = $db->show_fields_from("forumpermissions");
foreach($fields_array as $field)
{
if(strpos($field['Field'], 'can') !== false)
{
if(array_key_exists($field['Field'], $groups))
{
$field_list[$groups[$field['Field']]][] = $field['Field'];
}
else
{
$field_list['misc'][] = $field['Field'];
}
}
}
foreach(array_unique(array_values($groups)) as $group)
{
$lang_group = "group_".$group;
echo "
\n";
$form_container = new FormContainer("\"".htmlspecialchars_uni($usergroup['title'])."\" {$lang->custom_permissions_for} \"".htmlspecialchars_uni($forum['name'])."\"");
$fields = array();
foreach($field_list[$group] as $field)
{
$lang_field = $group."_field_".$field;
$fields[] = $form->generate_check_box("permissions[{$field}]", 1, $lang->$lang_field, array('checked' => $permission_data[$field], 'id' => $field));
}
$form_container->output_row("", "", "
".implode("
", $fields)."
");
$form_container->end();
echo "
";
}
if($mybb->input['ajax'] == 1)
{
echo "
";
$buttons[] = $form->generate_submit_button($lang->cancel, array('id' => 'modalCancel'));
$buttons[] = $form->generate_submit_button($lang->save_permissions, array('id' => 'modalSubmit'));
$form->output_submit_wrapper($buttons);
echo "
";
$form->end();
echo "
";
}
else
{
$buttons[] = $form->generate_submit_button($lang->save_permissions);
$form->output_submit_wrapper($buttons);
$form->end();
}
}
if($mybb->input['ajax'] != 1)
{
$page->output_footer();
}
}
if($mybb->input['action'] == "add")
{
$plugins->run_hooks("admin_forum_management_add");
if($mybb->request_method == "post")
{
if(!trim($mybb->input['title']))
{
$errors[] = $lang->error_missing_title;
}
$pid = intval($mybb->input['pid']);
$type = $mybb->input['type'];
if($pid <= 0 && $type == "f")
{
$errors[] = $lang->error_no_parent;
}
if(!$errors)
{
if($pid < 0)
{
$pid = 0;
}
$insert_array = array(
"name" => $db->escape_string($mybb->input['title']),
"description" => $db->escape_string($mybb->input['description']),
"linkto" => $db->escape_string($mybb->input['linkto']),
"type" => $db->escape_string($type),
"pid" => $pid,
"parentlist" => '',
"disporder" => intval($mybb->input['disporder']),
"active" => intval($mybb->input['active']),
"open" => intval($mybb->input['open']),
"allowhtml" => intval($mybb->input['allowhtml']),
"allowmycode" => intval($mybb->input['allowmycode']),
"allowsmilies" => intval($mybb->input['allowsmilies']),
"allowimgcode" => intval($mybb->input['allowimgcode']),
"allowvideocode" => intval($mybb->input['allowvideocode']),
"allowpicons" => intval($mybb->input['allowpicons']),
"allowtratings" => intval($mybb->input['allowtratings']),
"usepostcounts" => intval($mybb->input['usepostcounts']),
"password" => $db->escape_string($mybb->input['password']),
"showinjump" => intval($mybb->input['showinjump']),
"modposts" => intval($mybb->input['modposts']),
"modthreads" => intval($mybb->input['modthreads']),
"mod_edit_posts" => intval($mybb->input['mod_edit_posts']),
"modattachments" => intval($mybb->input['modattachments']),
"style" => intval($mybb->input['style']),
"overridestyle" => intval($mybb->input['overridestyle']),
"rulestype" => intval($mybb->input['rulestype']),
"rulestitle" => $db->escape_string($mybb->input['rulestitle']),
"rules" => $db->escape_string($mybb->input['rules']),
"defaultdatecut" => intval($mybb->input['defaultdatecut']),
"defaultsortby" => $db->escape_string($mybb->input['defaultsortby']),
"defaultsortorder" => $db->escape_string($mybb->input['defaultsortorder']),
);
$fid = $db->insert_query("forums", $insert_array);
$parentlist = make_parent_list($fid);
$db->update_query("forums", array("parentlist" => $parentlist), "fid='$fid'");
$inherit = $mybb->input['default_permissions'];
foreach($mybb->input as $id => $permission)
{
if(strpos($id, 'fields_') === false)
{
continue;
}
list(, $gid) = explode('fields_', $id);
// If it isn't an array then it came from the javascript form
if(!is_array($permission))
{
$permission = explode(',', $permission);
$permission = array_flip($permission);
foreach($permission as $name => $value)
{
$permission[$name] = 1;
}
}
foreach(array('canview','canpostthreads','canpostreplys','canpostpolls') as $name)
{
if(in_array($name, $permission) || $permission[$name])
{
$permissions[$name][$gid] = 1;
}
else
{
$permissions[$name][$gid] = 0;
}
}
}
$cache->update_forums();
$canview = $permissions['canview'];
$canpostthreads = $permissions['canpostthreads'];
$canpostpolls = $permissions['canpostpolls'];
$canpostattachments = $permissions['canpostattachments'];
$canpostreplies = $permissions['canpostreplys'];
save_quick_perms($fid);
$plugins->run_hooks("admin_forum_management_add_commit");
// Log admin action
log_admin_action($fid, $insert_array['name']);
flash_message($lang->success_forum_added, 'success');
admin_redirect("index.php?module=forum-management");
}
}
$page->extra_header .= "\n";
$page->extra_header .= "\n";
$page->add_breadcrumb_item($lang->add_forum);
$page->output_header($lang->add_forum);
$page->output_nav_tabs($sub_tabs, 'add_forum');
$form = new Form("index.php?module=forum-management&action=add", "post");
if($errors)
{
$page->output_inline_error($errors);
$forum_data = $mybb->input;
}
else
{
$forum_data['type'] = "f";
$forum_data['title'] = "";
$forum_data['description'] = "";
if(!$mybb->input['pid'])
{
$forum_data['pid'] = "-1";
}
else
{
$forum_data['pid'] = intval($mybb->input['pid']);
}
$forum_data['disporder'] = "1";
$forum_data['linkto'] = "";
$forum_data['password'] = "";
$forum_data['active'] = 1;
$forum_data['open'] = 1;
$forum_data['modposts'] = "";
$forum_data['modthreads'] = "";
$forum_data['modattachments'] = "";
$forum_data['mod_edit_posts'] = "";
$forum_data['overridestyle'] = "";
$forum_data['style'] = "";
$forum_data['rulestype'] = "";
$forum_data['rulestitle'] = "";
$forum_data['rules'] = "";
$forum_data['defaultdatecut'] = "";
$forum_data['defaultsortby'] = "";
$forum_data['defaultsortorder'] = "";
$forum_data['allowhtml'] = "";
$forum_data['allowmycode'] = 1;
$forum_data['allowsmilies'] = 1;
$forum_data['allowimgcode'] = 1;
$forum_data['allowvideocode'] = 1;
$forum_data['allowpicons'] = 1;
$forum_data['allowtratings'] = 1;
$forum_data['showinjump'] = 1;
$forum_data['usepostcounts'] = 1;
}
$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->add_forum);
$form_container->output_row($lang->forum_type, $lang->forum_type_desc, $form->generate_radio_button('type', 'f', $lang->forum, $create_a_options_f)."";
$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."
\n
{$lang->forum_is_active_desc}", array('checked' => $forum_data['active'], 'id' => 'active')),
$form->generate_check_box('open', 1, $lang->forum_is_open."
\n
{$lang->forum_is_open_desc}", array('checked' => $forum_data['open'], 'id' => 'open'))
);
$form_container->output_row($lang->access_options, "", "
".implode("
", $access_options)."
");
$moderator_options = array(
$form->generate_check_box('modposts', 1, $lang->mod_new_posts, array('checked' => $forum_data['modposts'], 'id' => 'modposts')),
$form->generate_check_box('modthreads', 1, $lang->mod_new_threads, array('checked' => $forum_data['modthreads'], 'id' => 'modthreads')),
$form->generate_check_box('modattachments', 1, $lang->mod_new_attachments, array('checked' => $forum_data['modattachments'], 'id' => 'modattachments')),
$form->generate_check_box('mod_edit_posts', 1, $lang->mod_after_edit, array('checked' => $forum_data['mod_edit_posts'], 'id' => 'mod_edit_posts'))
);
$form_container->output_row($lang->moderation_options, "", "
".implode("
", $moderator_options)."
");
$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']] = htmlspecialchars_uni($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."
\n".$form->generate_select_box('style', $styles, $forum_data['style'], array('id' => 'style'))
);
$form_container->output_row($lang->style_options, "", "
".implode("
", $style_options)."
");
$display_methods = array(
'0' => $lang->dont_display_rules,
'1' => $lang->display_rules_inline,
'3' => $lang->display_rules_inline_new,
'2' => $lang->display_rules_link
);
$forum_rules = array(
$lang->display_method."
\n".$form->generate_select_box('rulestype', $display_methods, $forum_data['rulestype'], array('checked' => $forum_data['rulestype'], 'id' => 'rulestype')),
$lang->title."
\n".$form->generate_text_box('rulestitle', $forum_data['rulestitle'], array('checked' => $forum_data['rulestitle'], 'id' => 'rulestitle')),
$lang->rules."
\n".$form->generate_text_area('rules', $forum_data['rules'], array('checked' => $forum_data['rules'], 'id' => 'rules'))
);
$form_container->output_row($lang->forum_rules, "", "
".implode("
", $forum_rules)."
");
$default_date_cut = array(
0 => $lang->board_default,
1 => $lang->datelimit_1day,
5 => $lang->datelimit_5days,
10 => $lang->datelimit_10days,
20 => $lang->datelimit_20days,
50 => $lang->datelimit_50days,
75 => $lang->datelimit_75days,
100 => $lang->datelimit_100days,
365 => $lang->datelimit_lastyear,
9999 => $lang->datelimit_beginning,
);
$default_sort_by = array(
"" => $lang->board_default,
"subject" => $lang->sort_by_subject,
"lastpost" => $lang->sort_by_lastpost,
"starter" => $lang->sort_by_starter,
"started" => $lang->sort_by_started,
"rating" => $lang->sort_by_rating,
"replies" => $lang->sort_by_replies,
"views" => $lang->sort_by_views,
);
$default_sort_order = array(
"" => $lang->board_default,
"asc" => $lang->sort_order_asc,
"desc" => $lang->sort_order_desc,
);
$view_options = array(
$lang->default_date_cut."
\n".$form->generate_select_box('defaultdatecut', $default_date_cut, $forum_data['defaultdatecut'], array('checked' => $forum_data['defaultdatecut'], 'id' => 'defaultdatecut')),
$lang->default_sort_by."
\n".$form->generate_select_box('defaultsortby', $default_sort_by, $forum_data['defaultsortby'], array('checked' => $forum_data['defaultsortby'], 'id' => 'defaultsortby')),
$lang->default_sort_order."
\n".$form->generate_select_box('defaultsortorder', $default_sort_order, $forum_data['defaultsortorder'], array('checked' => $forum_data['defaultsortorder'], 'id' => 'defaultsortorder')),
);
$form_container->output_row($lang->default_view_options, "", "
".implode("
", $view_options)."
");
$misc_options = array(
$form->generate_check_box('allowhtml', 1, $lang->allow_html, array('checked' => $forum_data['allowhtml'], 'id' => 'allowhtml')),
$form->generate_check_box('allowmycode', 1, $lang->allow_mycode, array('checked' => $forum_data['allowmycode'], 'id' => 'allowmycode')),
$form->generate_check_box('allowsmilies', 1, $lang->allow_smilies, array('checked' => $forum_data['allowsmilies'], 'id' => 'allowsmilies')),
$form->generate_check_box('allowimgcode', 1, $lang->allow_img_code, array('checked' => $forum_data['allowimgcode'], 'id' => 'allowimgcode')),
$form->generate_check_box('allowvideocode', 1, $lang->allow_video_code, array('checked' => $forum_data['allowvideocode'], 'id' => 'allowvideocode')),
$form->generate_check_box('allowpicons', 1, $lang->allow_post_icons, array('checked' => $forum_data['allowpicons'], 'id' => 'allowpicons')),
$form->generate_check_box('allowtratings', 1, $lang->allow_thread_ratings, array('checked' => $forum_data['allowtratings'], 'id' => 'allowtratings')),
$form->generate_check_box('showinjump', 1, $lang->show_forum_jump, array('checked' => $forum_data['showinjump'], 'id' => 'showinjump')),
$form->generate_check_box('usepostcounts', 1, $lang->use_postcounts, array('checked' => $forum_data['usepostcounts'], 'id' => 'usepostcounts'))
);
$form_container->output_row($lang->misc_options, "", "
".implode("
", $misc_options)."
");
$form_container->end();
echo "
";
$query = $db->simple_select("usergroups", "*", "", array("order_dir" => "name"));
while($usergroup = $db->fetch_array($query))
{
$usergroups[$usergroup['gid']] = $usergroup;
}
$cached_forum_perms = $cache->read("forumpermissions");
$field_list = array(
'canview' => $lang->permissions_canview,
'canpostthreads' => $lang->permissions_canpostthreads,
'canpostreplys' => $lang->permissions_canpostreplys,
'canpostpolls' => $lang->permissions_canpostpolls,
);
$field_list2 = array(
'canview' => $lang->perm_drag_canview,
'canpostthreads' => $lang->perm_drag_canpostthreads,
'canpostreplys' => $lang->perm_drag_canpostreplys,
'canpostpolls' => $lang->perm_drag_canpostpolls,
);
$ids = array();
$form_container = new FormContainer($lang->forum_permissions);
$form_container->output_row_header($lang->permissions_group, array("class" => "align_center", 'style' => 'width: 40%'));
$form_container->output_row_header($lang->overview_allowed_actions, array("class" => "align_center"));
$form_container->output_row_header($lang->overview_disallowed_actions, array("class" => "align_center"));
if($mybb->request_method == "post")
{
foreach($usergroups as $usergroup)
{
if(isset($mybb->input['fields_'.$usergroup['gid']]))
{
$input_permissions = $mybb->input['fields_'.$usergroup['gid']];
if(!is_array($input_permissions))
{
// Convering the comma separated list from Javascript form into a variable
$input_permissions = explode(',' , $input_permissions);
}
foreach($input_permissions as $input_permission)
{
$mybb->input['permissions'][$usergroup['gid']][$input_permission] = 1;
}
}
}
}
foreach($usergroups as $usergroup)
{
$perms = array();
if(isset($mybb->input['default_permissions']) && $mybb->input['default_permissions'][$usergroup['gid']])
{
if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']])
{
$perms = $existing_permissions[$usergroup['gid']];
$default_checked = false;
}
elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['fid']][$usergroup['gid']])
{
$perms = $cached_forum_perms[$forum_data['fid']][$usergroup['gid']];
$default_checked = true;
}
else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['pid']][$usergroup['gid']])
{
$perms = $cached_forum_perms[$forum_data['pid']][$usergroup['gid']];
$default_checked = true;
}
}
if(!$perms)
{
$perms = $usergroup;
$default_checked = true;
}
foreach($field_list as $forum_permission => $forum_perm_title)
{
if(isset($mybb->input['permissions']))
{
if($mybb->input['default_permissions'][$usergroup['gid']])
{
$default_checked = true;
}
else
{
$default_checked = false;
}
if($mybb->input['permissions'][$usergroup['gid']][$forum_permission])
{
$perms_checked[$forum_permission] = 1;
}
else
{
$perms_checked[$forum_permission] = 0;
}
}
else
{
if($perms[$forum_permission] == 1)
{
$perms_checked[$forum_permission] = 1;
}
else
{
$perms_checked[$forum_permission] = 0;
}
}
}
$usergroup['title'] = htmlspecialchars_uni($usergroup['title']);
if($default_checked)
{
$inherited_text = $lang->inherited_permission;
}
else
{
$inherited_text = $lang->custom_permission;
}
$form_container->output_cell("\n";
if(!isset($forum_cache) || !is_array($forum_cache))
{
cache_forums();
}
$form_container = new FormContainer($lang->sprintf($lang->in_forums, $forum_cache[$fid]['name']));
}
else
{
$form_container = new FormContainer($lang->manage_forums);
}
$form_container->output_row_header($lang->forum);
$form_container->output_row_header($lang->order, array("class" => "align_center", 'width' => '5%'));
$form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 200px'));
build_admincp_forums_list($form_container, $fid);
$submit_options = array();
if($form_container->num_rows() == 0)
{
$form_container->output_cell($lang->no_forums, array('colspan' => 3));
$form_container->construct_row();
$submit_options = array('disabled' => true);
}
$form_container->end();
$buttons[] = $form->generate_submit_button($lang->update_forum_orders, $submit_options);
$buttons[] = $form->generate_reset_button($lang->reset);
$form->output_submit_wrapper($buttons);
if(!$fid)
{
$form->end();
}
if($fid)
{
echo "
\n";
$form->end();
$query = $db->simple_select("usergroups", "*", "", array("order_dir" => "name"));
while($usergroup = $db->fetch_array($query))
{
$usergroups[$usergroup['gid']] = $usergroup;
}
$query = $db->simple_select("forumpermissions", "*", "fid='{$fid}'");
while($existing = $db->fetch_array($query))
{
$existing_permissions[$existing['gid']] = $existing;
}
$cached_forum_perms = $cache->read("forumpermissions");
$field_list = array(
'canview' => $lang->permissions_canview,
'canpostthreads' => $lang->permissions_canpostthreads,
'canpostreplys' => $lang->permissions_canpostreplys,
'canpostpolls' => $lang->permissions_canpostpolls,
);
$field_list2 = array(
'canview' => $lang->perm_drag_canview,
'canpostthreads' => $lang->perm_drag_canpostthreads,
'canpostreplys' => $lang->perm_drag_canpostreplys,
'canpostpolls' => $lang->perm_drag_canpostpolls,
);
$ids = array();
$form = new Form("index.php?module=forum-management", "post", "management");
echo $form->generate_hidden_field("fid", $mybb->input['fid']);
echo $form->generate_hidden_field("update", "permissions");
echo "\n";
$form_container = new FormContainer($lang->sprintf($lang->forum_permissions_in, $forum_cache[$fid]['name']));
$form_container->output_row_header($lang->permissions_group, array("class" => "align_center", 'style' => 'width: 30%'));
$form_container->output_row_header($lang->overview_allowed_actions, array("class" => "align_center"));
$form_container->output_row_header($lang->overview_disallowed_actions, array("class" => "align_center"));
$form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 120px', 'colspan' => 2));
foreach($usergroups as $usergroup)
{
$perms = array();
if(isset($mybb->input['default_permissions']))
{
if($mybb->input['default_permissions'][$usergroup['gid']])
{
if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']])
{
$perms = $existing_permissions[$usergroup['gid']];
$default_checked = false;
}
elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum['fid']][$usergroup['gid']])
{
$perms = $cached_forum_perms[$forum['fid']][$usergroup['gid']];
$default_checked = true;
}
else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum['pid']][$usergroup['gid']])
{
$perms = $cached_forum_perms[$forum['pid']][$usergroup['gid']];
$default_checked = true;
}
}
if(!$perms)
{
$perms = $usergroup;
$default_checked = true;
}
}
else
{
if(isset($existing_permissions) && is_array($existing_permissions) && $existing_permissions[$usergroup['gid']])
{
$perms = $existing_permissions[$usergroup['gid']];
$default_checked = false;
}
elseif(is_array($cached_forum_perms) && isset($cached_forum_perms[$forum['fid']]) && $cached_forum_perms[$forum['fid']][$usergroup['gid']])
{
$perms = $cached_forum_perms[$forum['fid']][$usergroup['gid']];
$default_checked = true;
}
else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum['pid']][$usergroup['gid']])
{
$perms = $cached_forum_perms[$forum['pid']][$usergroup['gid']];
$default_checked = true;
}
if(!$perms)
{
$perms = $usergroup;
$default_checked = true;
}
}
foreach($field_list as $forum_permission => $forum_perm_title)
{
if(isset($mybb->input['permissions']))
{
if($mybb->input['permissions'][$usergroup['gid']][$forum_permission])
{
$perms_checked[$forum_permission] = 1;
}
else
{
$perms_checked[$forum_permission] = 0;
}
}
else
{
if($perms[$forum_permission] == 1)
{
$perms_checked[$forum_permission] = 1;
}
else
{
$perms_checked[$forum_permission] = 0;
}
}
}
$usergroup['title'] = htmlspecialchars_uni($usergroup['title']);
if($default_checked == 1)
{
$inherited_text = $lang->inherited_permission;
}
else
{
$inherited_text = $lang->custom_permission;
}
$form_container->output_cell("
{$usergroup['title']} ({$inherited_text})");
$field_select = "
\n";
$field_select .= "
\n";
foreach($perms_checked as $perm => $value)
{
if($value == 1)
{
$field_select .= "- {$field_list2[$perm]}
";
}
}
$field_select .= "
\n";
$field_select .= "
\n";
foreach($perms_checked as $perm => $value)
{
if($value == 0)
{
$field_select .= "- {$field_list2[$perm]}
";
}
}
$field_select .= "
\n";
$field_select .= $form->generate_hidden_field("fields_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_'.$usergroup['gid']));
$field_select .= $form->generate_hidden_field("fields_inherit_".$usergroup['gid'], (int)$default_checked, array('id' => 'fields_inherit_'.$usergroup['gid']));
$field_select .= $form->generate_hidden_field("fields_default_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_default_'.$usergroup['gid']));
$field_select = str_replace("'", "\\'", $field_select);
$field_select = str_replace("\n", "", $field_select);
$field_select = "\n";
$field_selected = array();
foreach($field_list as $forum_permission => $permission_title)
{
$field_options[$forum_permission] = $permission_title;
if($perms_checked[$forum_permission])
{
$field_selected[] = $forum_permission;
}
}
$field_select .= "
\n";
$form_container->output_cell($field_select, array('colspan' => 2));
if(!$default_checked)
{
$form_container->output_cell("
{$lang->edit_permissions}", array("class" => "align_center"));
$form_container->output_cell("
post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_clear_custom_permission}')\">{$lang->clear_custom_perms}", array("class" => "align_center"));
}
else
{
$form_container->output_cell("
{$lang->set_custom_perms}", array("class" => "align_center", "colspan" => 2));
}
$form_container->construct_row(array('id' => 'row_'.$usergroup['gid']));
$ids[] = $usergroup['gid'];
}
$form_container->end();
$buttons = array();
$buttons[] = $form->generate_submit_button($lang->update_forum_permissions);
$buttons[] = $form->generate_reset_button($lang->reset);
$form->output_submit_wrapper($buttons);
// Write in our JS based field selector
echo "\n";
echo "
\n";
$form->end();
echo "\n";
$form_container = new FormContainer($lang->sprintf($lang->moderators_assigned_to, $forum_cache[$fid]['name']));
$form_container->output_row_header($lang->name, array('width' => '75%'));
$form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 200px', 'colspan' => 2));
$query = $db->query("
SELECT m.mid, m.id, m.isgroup, u.username, g.title
FROM ".TABLE_PREFIX."moderators m
LEFT JOIN ".TABLE_PREFIX."users u ON (m.isgroup='0' AND m.id=u.uid)
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (m.isgroup='1' AND m.id=g.gid)
WHERE fid='{$fid}'
ORDER BY m.isgroup DESC, u.username, g.title
");
while($moderator = $db->fetch_array($query))
{
if($moderator['isgroup'])
{
$moderator['img'] = "
style}/images/icons/group.gif\" alt=\"{$lang->group}\" title=\"{$lang->group}\" />";
$form_container->output_cell("{$moderator['img']}
".htmlspecialchars_uni($moderator['title'])." ({$lang->usergroup} {$moderator['id']})");
$form_container->output_cell("
{$lang->edit}", array("class" => "align_center"));
$form_container->output_cell("
post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_moderator_deletion}')\">{$lang->delete}", array("class" => "align_center"));
}
else
{
$moderator['img'] = "
style}/images/icons/user.gif\" alt=\"{$lang->user}\" title=\"{$lang->user}\" />";
$form_container->output_cell("{$moderator['img']}
".htmlspecialchars_uni($moderator['username'])."");
$form_container->output_cell("
{$lang->edit}", array("class" => "align_center"));
$form_container->output_cell("
post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_moderator_deletion}')\">{$lang->delete}", array("class" => "align_center"));
}
$form_container->construct_row();
}
if($form_container->num_rows() == 0)
{
$form_container->output_cell($lang->no_moderators, array('colspan' => 3));
$form_container->construct_row();
}
$form_container->end();
// Users
$buttons = array();
$form = new Form("index.php?module=forum-management", "post", "management");
echo $form->generate_hidden_field("fid", $mybb->input['fid']);
echo $form->generate_hidden_field("add", "moderators");
// Usergroup Moderator
if(!is_array($usergroups))
{
$usergroups = $groupscache;
}
foreach($usergroups as $group)
{
$modgroups[$group['gid']] = $lang->usergroup." ".$group['gid'].": ".$group['title'];
}
if(!isset($mybb->input['usergroup']))
{
$mybb->input['usergroup'] = '';
}
if(!isset($mybb->input['username']))
{
$mybb->input['username'] = '';
}
$form_container = new FormContainer($lang->add_usergroup_as_moderator);
$form_container->output_row($lang->usergroup."
*", $lang->moderator_usergroup_desc, $form->generate_select_box('usergroup', $modgroups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
$form_container->end();
$buttons[] = $form->generate_submit_button($lang->add_usergroup_moderator);
$form->output_submit_wrapper($buttons);
$form->end();
echo "
";
$form = new Form("index.php?module=forum-management", "post", "management");
echo $form->generate_hidden_field("fid", $mybb->input['fid']);
echo $form->generate_hidden_field("add", "moderators");
$form_container = new FormContainer($lang->add_user_as_moderator);
$form_container->output_row($lang->username."
*", $lang->moderator_username_desc, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
$form_container->end();
// Autocompletion for usernames
echo '
';
$buttons = array($form->generate_submit_button($lang->add_user_moderator));
$form->output_submit_wrapper($buttons);
$form->end();
echo "
\n";
}
$page->output_footer();
}
/**
*
*/
function build_admincp_forums_list(&$form_container, $pid=0, $depth=1)
{
global $mybb, $lang, $db, $sub_forums;
static $forums_by_parent;
if(!is_array($forums_by_parent))
{
$forum_cache = cache_forums();
foreach($forum_cache as $forum)
{
$forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}
if(!is_array($forums_by_parent[$pid]))
{
return;
}
foreach($forums_by_parent[$pid] as $children)
{
foreach($children as $forum)
{
$forum['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&", $forum['name']); // Fix & but allow unicode
if($forum['active'] == 0)
{
$forum['name'] = "