Zeile 11 | Zeile 11 |
---|
/** * Builds the "view management" interface allowing administrators to edit their custom designed "views" *
|
/** * Builds the "view management" interface allowing administrators to edit their custom designed "views" *
|
* @param string The base URL to this instance of the view manager * @param string The internal type identifier for this view * @param array Array of fields this view supports * @param array Array of possible sort options this view supports if any * @param string Optional callback function which generates list of "conditions" for this view
| * @param string $base_url The base URL to this instance of the view manager * @param string $type The internal type identifier for this view * @param array $fields Array of fields this view supports * @param array $sort_options Array of possible sort options this view supports if any * @param string $conditions_callback Optional callback function which generates list of "conditions" for this view
|
*/ function view_manager($base_url, $type, $fields, $sort_options=array(), $conditions_callback="") {
| */ function view_manager($base_url, $type, $fields, $sort_options=array(), $conditions_callback="") {
|
Zeile 52 | Zeile 52 |
---|
admin_redirect($base_url."&action=views"); }
|
admin_redirect($base_url."&action=views"); }
|
| $errors = array();
|
if($mybb->input['do'] == "add") { if($mybb->request_method == "post")
| if($mybb->input['do'] == "add") { if($mybb->request_method == "post")
|
Zeile 64 | Zeile 65 |
---|
{ $mybb->input['fields'] = explode(",", $mybb->input['fields_js']); }
|
{ $mybb->input['fields'] = explode(",", $mybb->input['fields_js']); }
|
if(count($mybb->input['fields']) <= 0)
| if(!isset($mybb->input['fields']) || !is_array($mybb->input['fields']) || count($mybb->input['fields']) <= 0)
|
{ $errors[] = $lang->error_no_view_fields; }
| { $errors[] = $lang->error_no_view_fields; }
|
Zeile 89 | Zeile 90 |
---|
$mybb->input['visibility'] = 2; }
|
$mybb->input['visibility'] = 2; }
|
if(!$errors)
| if(empty($errors))
|
{ $new_view = array( "uid" => $mybb->user['uid'],
| { $new_view = array( "uid" => $mybb->user['uid'],
|
Zeile 131 | Zeile 132 |
---|
$page->output_nav_tabs($sub_tabs, 'create_view');
// If we have any error messages, show them
|
$page->output_nav_tabs($sub_tabs, 'create_view');
// If we have any error messages, show them
|
if($errors)
| if(!empty($errors))
|
{ $page->output_inline_error($errors); }
$form_container = new FormContainer($lang->create_new_view);
|
{ $page->output_inline_error($errors); }
$form_container = new FormContainer($lang->create_new_view);
|
$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->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->get_input('title'), array('id' => 'title')), 'title');
|
|
|
if($mybb->input['visibility'] == 2) { $visibility_public_checked = true; } else { $visibility_private_checked = true; }
| $visibility_public_checked = $mybb->get_input('visibility') == 2; $visibility_private_checked = !$visibility_public_checked;
|
$visibility_options = array( $form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)) ); $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options));
|
$visibility_options = array( $form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)) ); $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options));
|
$form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0)));
| $form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->get_input('isdefault'), array('yes' => 1, 'no' => 0)));
|
if(count($sort_options) > 0) { $sort_directions = array( "asc" => $lang->ascending, "desc" => $lang->descending );
|
if(count($sort_options) > 0) { $sort_directions = array( "asc" => $lang->ascending, "desc" => $lang->descending );
|
$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('sortorder', $sort_directions, $mybb->input['sortorder'], array('id' => 'sortorder')), 'sortby'); }
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $mybb->input['perpage'], array('id' => 'perpage', 'min' => 1)), 'perpage');
| $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->get_input('sortby'), array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('sortorder', $sort_directions, $mybb->get_input('sortorder'), array('id' => 'sortorder')), 'sortby'); }
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $mybb->get_input('perpage'), array('id' => 'perpage', 'min' => 1)), 'perpage');
|
if($type == "user") {
|
if($type == "user") {
|
$form_container->output_row($lang->display_results_as, "", $form->generate_radio_button('view_type', 'table', $lang->table, array('checked' => ($mybb->input['view_type'] != "card" ? true : false)))."<br />".$form->generate_radio_button('view_type', 'card', $lang->business_card, array('checked' => ($mybb->input['view_type'] == "card" ? true : false))));
| $form_container->output_row($lang->display_results_as, "", $form->generate_radio_button('view_type', 'table', $lang->table, array('checked' => ($mybb->get_input('view_type') != "card" ? true : false)))."<br />".$form->generate_radio_button('view_type', 'card', $lang->business_card, array('checked' => ($mybb->get_input('view_type') == "card" ? true : false))));
|
}
$form_container->end();
|
}
$form_container->end();
|
$field_select .= "<div class=\"view_fields\">\n";
| $active = array();
$field_select = "<div class=\"view_fields\">\n";
|
$field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n";
|
$field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n";
|
if(is_array($mybb->input['fields']))
| if(isset($mybb->input['fields']) && is_array($mybb->input['fields']))
|
{ foreach($mybb->input['fields'] as $field) {
| { foreach($mybb->input['fields'] as $field) {
|
Zeile 191 | Zeile 188 |
---|
$field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled\">\n"; foreach($fields as $key => $field) {
|
$field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled\">\n"; foreach($fields as $key => $field) {
|
if($active[$key])
| if(!empty($active[$key]))
|
{ continue; }
| { continue; }
|
Zeile 207 | Zeile 204 |
---|
document.write('".str_replace("/", "\/", $field_select)."'); //]]> </script>\n";
|
document.write('".str_replace("/", "\/", $field_select)."'); //]]> </script>\n";
|
foreach($fields as $key => $field) { $field_options[$key] = $field['title']; }
$field_select .= "<noscript>".$form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true))."</noscript>\n";
| foreach($fields as $key => $field) { $field_options[$key] = $field['title']; }
$field_select .= "<noscript>".$form->generate_select_box('fields[]', $field_options, $mybb->get_input('fields'), array('id' => 'fields', 'multiple' => true))."</noscript>\n";
|
$form_container = new FormContainer($lang->fields_to_show);
|
$form_container = new FormContainer($lang->fields_to_show);
|
$form_container->output_row($lang->fields_to_show_desc, $description, $field_select);
| $form_container->output_row($lang->fields_to_show_desc, '', $field_select);
|
$form_container->end();
// Build the search conditions if(function_exists($conditions_callback)) { $conditions_callback($mybb->input, $form);
|
$form_container->end();
// Build the search conditions if(function_exists($conditions_callback)) { $conditions_callback($mybb->input, $form);
|
}
| }
|
$buttons[] = $form->generate_submit_button($lang->save_view); $form->output_submit_wrapper($buttons);
| $buttons[] = $form->generate_submit_button($lang->save_view); $form->output_submit_wrapper($buttons);
|
Zeile 238 | Zeile 235 |
---|
// Does the view not exist? if(!$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid'])
|
// Does the view not exist? if(!$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid'])
|
{
| {
|
flash_message($lang->error_invalid_admin_view, 'error'); admin_redirect($base_url."&action=views"); }
| flash_message($lang->error_invalid_admin_view, 'error'); admin_redirect($base_url."&action=views"); }
|
Zeile 252 | Zeile 249 |
---|
if($mybb->input['fields_js']) { $mybb->input['fields'] = explode(",", $mybb->input['fields_js']);
|
if($mybb->input['fields_js']) { $mybb->input['fields'] = explode(",", $mybb->input['fields_js']);
|
}
| }
|
|
|
if(count($mybb->input['fields']) <= 0)
| if(!is_array($mybb->input['fields']) || count($mybb->input['fields']) <= 0)
|
{ $errors[] = $lang->error_no_view_fields; }
| { $errors[] = $lang->error_no_view_fields; }
|
Zeile 267 | Zeile 264 |
---|
if(!in_array($mybb->input['sortby'], array_keys($sort_options))) { $errors[] = $lang->error_invalid_view_sortby;
|
if(!in_array($mybb->input['sortby'], array_keys($sort_options))) { $errors[] = $lang->error_invalid_view_sortby;
|
}
| }
|
if($mybb->input['sortorder'] != "asc" && $mybb->input['sortorder'] != "desc") { $errors[] = $lang->error_invalid_view_sortorder; }
if($mybb->input['visibility'] == 0)
|
if($mybb->input['sortorder'] != "asc" && $mybb->input['sortorder'] != "desc") { $errors[] = $lang->error_invalid_view_sortorder; }
if($mybb->input['visibility'] == 0)
|
{
| {
|
$mybb->input['visibility'] = 2; }
|
$mybb->input['visibility'] = 2; }
|
if(!$errors)
| if(empty($errors))
|
{ $updated_view = array( "title" => $db->escape_string($mybb->input['title']),
| { $updated_view = array( "title" => $db->escape_string($mybb->input['title']),
|
Zeile 323 | Zeile 320 |
---|
$page->output_nav_tabs($sub_tabs, 'edit_view');
// If we have any error messages, show them
|
$page->output_nav_tabs($sub_tabs, 'edit_view');
// If we have any error messages, show them
|
if($errors)
| if(!empty($errors))
|
{ $page->output_inline_error($errors); }
| { $page->output_inline_error($errors); }
|
Zeile 346 | Zeile 343 |
---|
$form_container = new FormContainer($lang->edit_view); $form_container->output_row($lang->view." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
$form_container = new FormContainer($lang->edit_view); $form_container->output_row($lang->view." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
if($mybb->input['visibility'] == 2) { $visibility_public_checked = true; } else { $visibility_private_checked = true; }
| $visibility_public_checked = $mybb->input['visibility'] == 2; $visibility_private_checked = !$visibility_public_checked;
|
$visibility_options = array( $form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)) ); $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options));
|
$visibility_options = array( $form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)) ); $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options));
|
|
|
$form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0)));
|
$form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0)));
|
if(count($sort_options) > 0)
| if(is_array($sort_options) && count($sort_options) > 0)
|
{ $sort_directions = array( "asc" => $lang->ascending,
| { $sort_directions = array( "asc" => $lang->ascending,
|
Zeile 381 | Zeile 372 |
---|
$form_container->end();
|
$form_container->end();
|
$field_select .= "<div class=\"view_fields\">\n";
| $field_select = "<div class=\"view_fields\">\n";
|
$field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n"; if(is_array($mybb->input['fields'])) {
| $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n"; if(is_array($mybb->input['fields'])) {
|
Zeile 400 | Zeile 391 |
---|
{ foreach($fields as $key => $field) {
|
{ foreach($fields as $key => $field) {
|
if($active[$key])
| if(!empty($active[$key]))
|
{ continue; }
| { continue; }
|
Zeile 425 | Zeile 416 |
---|
$field_select .= "<noscript>".$form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true))."</noscript>\n";
$form_container = new FormContainer($lang->fields_to_show);
|
$field_select .= "<noscript>".$form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true))."</noscript>\n";
$form_container = new FormContainer($lang->fields_to_show);
|
$form_container->output_row($lang->fields_to_show_desc, $description, $field_select);
| $form_container->output_row($lang->fields_to_show_desc, '', $field_select);
|
$form_container->end();
// Build the search conditions
| $form_container->end();
// Build the search conditions
|
Zeile 443 | Zeile 434 |
---|
else if($mybb->input['do'] == "delete") {
|
else if($mybb->input['do'] == "delete") {
|
if($mybb->input['no'])
| if($mybb->get_input('no'))
|
{ admin_redirect($base_url."&action=views"); }
| { admin_redirect($base_url."&action=views"); }
|
Zeile 575 | Zeile 566 |
---|
$view_type = "group"; if($view['username']) {
|
$view_type = "group"; if($view['username']) {
|
$created = "<br /><small>{$lang->created_by} {$view['username']}</small>";
| $username = htmlspecialchars_uni($view['username']); $created = "<br /><small>{$lang->created_by} {$username}</small>";
|
} } else
| } } else
|
Zeile 587 | Zeile 579 |
---|
if($default_view == $view['vid']) { $default_add = " ({$lang->default})";
|
if($default_view == $view['vid']) { $default_add = " ({$lang->default})";
|
}
$title_string = "view_title_{$view['vid']}";
if($lang->$title_string) {
| }
$title_string = "view_title_{$view['vid']}";
if(isset($lang->$title_string)) {
|
$view['title'] = $lang->$title_string; }
| $view['title'] = $lang->$title_string; }
|
Zeile 615 | Zeile 607 |
---|
}
$table->output($lang->view);
|
}
$table->output($lang->view);
|
|
|
echo <<<LEGEND <br /> <fieldset>
| echo <<<LEGEND <br /> <fieldset>
|
Zeile 634 | Zeile 626 |
---|
$query = $db->simple_select("adminoptions", "defaultviews", "uid='{$mybb->user['uid']}'"); $default_views = my_unserialize($db->fetch_field($query, "defaultviews"));
|
$query = $db->simple_select("adminoptions", "defaultviews", "uid='{$mybb->user['uid']}'"); $default_views = my_unserialize($db->fetch_field($query, "defaultviews"));
|
if(!$db->num_rows($query)) { $create = true; }
| $create = !$db->num_rows($query);
|
$default_views[$type] = $vid; $default_views = my_serialize($default_views); $updated_admin = array("defaultviews" => $db->escape_string($default_views));
| $default_views[$type] = $vid; $default_views = my_serialize($default_views); $updated_admin = array("defaultviews" => $db->escape_string($default_views));
|
Zeile 648 | Zeile 638 |
---|
$updated_admin['notes'] = ''; $updated_admin['permissions'] = ''; $db->insert_query("adminoptions", $updated_admin);
|
$updated_admin['notes'] = ''; $updated_admin['permissions'] = ''; $db->insert_query("adminoptions", $updated_admin);
|
}
| }
|
else { $db->update_query("adminoptions", $updated_admin, "uid='{$mybb->user['uid']}'"); } }
|
else { $db->update_query("adminoptions", $updated_admin, "uid='{$mybb->user['uid']}'"); } }
|
| /** * @param string $type * * @return bool|array */
|
function fetch_default_view($type) { global $mybb, $db;
| function fetch_default_view($type) { global $mybb, $db;
|