'; $site = 'options-general.php?page=teachpress/settings.php'; // Tab selector $tab_list = ['general', 'publication_data', 'publication_templates', 'db_status' ]; $tab_input = isset( $_GET['tab'] ) ? htmlspecialchars($_GET['tab']) : 'general'; $tab = ( in_array($tab_input, $tab_list) ) ? $tab_input : ''; // update dababase if ( isset($_GET['up']) ) { TP_Settings_Page::update_database($site); } // sync database if ( isset($_GET['sync']) ) { $sync = intval($_GET['sync']); if ( $sync === 1 ) { tp_db_sync('authors'); TP_Settings_Page::update_database($site, false); } if ( $sync === 2 ) { tp_db_sync('stud_meta'); } } // install database if ( isset($_GET['ins']) ) { tp_install(); } // delete database if ( isset( $_GET['drop_tp'] ) || isset( $_POST['drop_tp_ok'] ) ) { TP_Settings_Page::delete_database(); } // change general options if ( isset( $_POST['einstellungen'] ) ) { self::check_nonce_field(); TP_Settings_Page::change_general_options(); } // delete settings if ( isset( $_GET['delete'] ) ) { self::check_nonce_field(); TP_Options::delete_option($_GET['delete']); get_tp_message(__('Deleted', 'teachpress')); } // Delete data field if ( isset( $_GET['delete_field'] ) || isset( $_GET['delete_field_ok'] ) ) { self::check_nonce_field(); TP_Settings_Page::delete_meta_fields($tab); } // add meta field options if ( isset($_POST['add_field']) ) { self::check_nonce_field(); $table = 'teachpress_pub'; TP_Settings_Page::add_meta_fields($table); } // test if database is installed TP_Admin::database_test(); echo '
 ) . ')
 ) . ')
' . get_tp_option('db-version') . ' "Lemon Tart"
Website | teachPress on GitHub | Dokumentation | Changelog
©2008-2023 by Michael Winkler | License: GPLv2 or later
'; echo '
'; } /** * Returns the select for for user role field * @param string $type * @access private * @since 5.0.0 */ private static function get_user_role_form ($type){ $title = ( $type === 'userrole_publications' ) ? __('Backend access for publication module','teachpress') : __('Backend access for course module','teachpress'); $cap = ( $type === 'userrole_publications' ) ? 'use_teachpress' : 'use_teachpress_courses'; echo '| ' . __('teachPress version','teachpress') . ' | '; echo '' . get_tp_option('db-version') . ' | '; echo ''; echo ''; echo ' |
|---|---|---|
| '; echo ' | '; echo ''; echo ' | '; echo '' . __('Select which style sheet you will use. teachpress_front.css is the teachPress default style. If you have created your own style in the default style sheet of your theme, you can activate this here.','teachpress') . ' | '; echo '
' . __('Related content','teachpress') . ' | ';
echo '||
| ' . __('Type','teachpress') . ' | '; echo ''; TP_Settings_Page::get_rel_page_form('rel_page_publications'); echo ' | '; echo '' . __('If you create a publication you can define a link to related content. It is kind of a "more information link", which helps you to connect a course/publication with a page. If you want to use custom post types instead of pages, so you can set it here.','teachpress') . ' | '; echo '
| ' . __('Default category for related content','teachpress') . ' | '; echo ''; wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'rel_content_category', 'orderby' => 'name', 'selected' => get_tp_option('rel_content_category'), 'hierarchical' => true, 'show_option_none' => __('none','teachpress'))); echo ' | '; echo '' . __('Used if the related content type for publicaitons is set on','teachpress') . ': ' . __('Posts') . ' | '; echo '
| ' . __('Automatic related content','teachpress') . ' | '; echo '' . TP_Admin::get_checkbox('rel_content_auto', __('Create an automatic related content with every new publication','teachpress'), get_tp_option('rel_content_auto')) . ' | '; echo '|
| ' . __('Template for related content','teachpress') . ' | '; echo ''; echo ' | |
' . __('Import / Export','teachpress') . ' | ';
echo '||
| ' . __('BibTeX special chars','teachpress') . ' | '; echo '' . TP_Admin::get_checkbox('convert_bibtex', __('Try to convert utf-8 chars into BibTeX compatible ASCII strings','teachpress'), get_tp_option('convert_bibtex')) . ' | '; echo '|
| ' . __('Update existing publications','teachpress') . ' | '; echo '' . TP_Admin::get_checkbox('import_overwrite', __('Allow optional updating for publication import','teachpress'), get_tp_option('import_overwrite')) . ' | '; echo '|
' . __('RSS','teachpress') . ' | ';
echo '||
| ' . __('RSS feed addresses','teachpress') . ' | '; echo '' . __('For all publications:','teachpress') . ' ' . __('Example for publications of a single user (id = WordPress user-ID):','teachpress') . ' ' . __('Example for publications of a single tag (tag = tag-id):','teachpress') . ' | ';
echo '|
' . __('Bibliography style','teachpress') . ' | ';
echo '||
| ' . __('Repeated citations','teachpress') . ' | '; echo '' . TP_Admin::get_checkbox('ref_grouped', __('Cite every reference only once','teachpress'), get_tp_option('ref_grouped')) . ' | '; echo '|
' . __('Misc','teachpress') . ' | ';
echo '||
| ' . __('Database','teachpress') . ' | '; echo ''; echo '' . __('Index status','teachpress') . ''; echo ' | '; echo '|
| ' . __('Uninstalling','teachpress') . ' | '; echo ''; echo '' . __('Remove teachPress from database','teachpress') . ''; echo ' | '; echo '|
| ' . __('Field name','teachpress') . ' | '; echo '' . __('Properties','teachpress') . ' | '; echo '
|---|---|
| ' . $field->variable . ' | ';
if ( isset( $data['title'] ) ) {
echo 'Label: ' . stripslashes($data['title']) . ' '; } if ( isset( $data['type'] ) ) { echo 'Type: ' . stripslashes($data['type']) . ' ';} if ( isset( $data['visibility'] ) ) { echo 'Visibility: ' . stripslashes($data['visibility']) . ' '; } if ( isset( $data['min'] ) ) { echo 'Min: ' . stripslashes($data['min']) . ' '; } if ( isset( $data['max'] ) ) { echo 'Max: ' . stripslashes($data['max']) . ' '; } if ( isset( $data['step'] ) ) { echo 'Step: ' . stripslashes($data['step']) . ' '; } if ( isset( $data['required'] ) ) { echo 'Required: ' . stripslashes($data['required']) . ''; } echo ' | ';
echo '
| '; echo '' . __('Add new','teachpress') . ''; echo ' | '; echo '|
| ' . __('Name') . ' | '; echo '' . __('Key') . ' | '; echo '' . __('Description') . ' | '; echo '
|---|
' . __('Version', 'teachpress') . ' ' . esc_html($settings['version']) . ' | ' . __('by', 'teachpress') . ' ' . esc_html($settings['author']) . '
| ' . __('Key_name','teachpress') . ' | '; echo '' . __('Type','teachpress') . ' | '; echo '' . __('Unique','teachpress') . ' | '; echo '' . __('Packed','teachpress') . ' | '; echo '' . __('Column','teachpress') . ' | '; echo '' . __('Cardinality','teachpress') . ' | '; echo '' . __('Collation','teachpress') . ' | '; echo 'NULL | '; echo '' . __('Seq index','teachpress') . ' | '; echo '
|---|---|---|---|---|---|---|---|---|
| ' . $row['Key_name'] . ' | '; echo '' . $row['Index_type'] . ' | '; echo '' . $unique . ' | '; echo '' . $row['Packed'] . ' | '; echo '' . $row['Column_name'] . ' | '; echo '' . $row['Cardinality'] . ' | '; echo '' . $row['Collation'] . ' | '; echo '' . $n . ''; echo ' | ' . $row['Seq_in_index'] . ' | '; echo '
' . __('Do you really want to delete the selected meta field?','teachpress') . '
' . ''. __('OK') . ' '. __('Cancel') . ''; get_tp_message($message,'orange'); } if ( isset($_GET['delete_field_ok']) ) { $option = TP_Options::get_option_by_id($_GET['delete_field_ok']); $options = get_tp_options($option['variable'], "`setting_id` DESC", ARRAY_A); foreach ( $options as $row ) { TP_Options::delete_option($row['setting_id']); } TP_Options::delete_option($_GET['delete_field_ok']); get_tp_message( __('Field deleted','teachpress') ); } } /** * Handles changing of general options * @access private * @since 5.0.0 */ private static function change_general_options () { // Just for administrators if ( !current_user_can( 'manage_options' ) ) { return; } $option_semester = isset( $_POST['semester'] ) ? htmlspecialchars($_POST['semester']) : ''; $option_rel_page_publications = isset( $_POST['rel_page_publications'] ) ? htmlspecialchars($_POST['rel_page_publications']) : ''; $option_stylesheet = isset( $_POST['stylesheet'] ) ? intval($_POST['stylesheet']) : ''; $option_userrole_publications = isset( $_POST['userrole_publications'] ) ? $_POST['userrole_publications'] : ''; $checkbox_convert_bibtex = isset( $_POST['convert_bibtex'] ) ? 1 : ''; $checkbox_import_overwrite = isset( $_POST['import_overwrite'] ) ? 1 : ''; $checkbox_rel_content_auto = isset( $_POST['rel_content_auto'] ) ? 1 : ''; $checkbox_ref_grouped = isset( $_POST['ref_grouped'] ) ? 1 : ''; TP_Options::change_option('sem', $option_semester); TP_Options::change_option('rel_page_publications', $option_rel_page_publications); TP_Options::change_option('stylesheet', $option_stylesheet); TP_Options::change_option('convert_bibtex', $checkbox_convert_bibtex, 'checkbox'); TP_Options::change_option('import_overwrite', $checkbox_import_overwrite, 'checkbox'); TP_Options::change_option('rel_content_auto', $checkbox_rel_content_auto, 'checkbox'); TP_Options::change_option('rel_content_template', $_POST['rel_content_template']); TP_Options::change_option('rel_content_category', $_POST['rel_content_category']); tp_update_userrole($option_userrole_publications, 'use_teachpress'); TP_Options::change_option('ref_grouped', $checkbox_ref_grouped, 'checkbox'); get_tp_message( __('Settings are changed. Please note that access changes are visible, until you have reloaded this page a second time.','teachpress') ); } /** * Handles start of database updates * @param string $site The current URL * @param boolean $with_structure_change Update database structure (true) or not (false), Default is true * @access private * @since 5.0.0 */ private static function update_database ($site, $with_structure_change = true) { if ( $with_structure_change === true ) { tp_db_update(); } $check_stud_meta = TP_Update::check_table_stud_meta(); $check_authors = TP_Update::check_table_authors(); if ( $check_authors === false && $check_stud_meta === false ) { return; } $sync = ( $check_authors === true ) ? 1 : 2; $table = ( $check_authors === true ) ? 'teachpress_authors' : 'teachpress_stud_meta'; $message = 'TABLE ' . $table . ': ' . __('teachPress wants to fill up the new database. This can take some time.','teachpress') . ' ' . __('Continue','teachpress') . ''; get_tp_message($message, 'orange'); } /** * Handles database deletion * @access private * @since 5.0.0 */ private static function delete_database () { // Just for administrators if ( !current_user_can( 'manage_options' ) ) { return; } // Form for delete database question if ( isset($_GET['drop_tp']) && ! isset($_POST['drop_tp_ok']) ) { echo ''; } // Delete if wp_nonce is ok if ( isset($_POST['drop_tp_ok']) ) { if ( ! wp_verify_nonce( $_POST['tp_nonce_del_db'], 'verify_teachpress_del_db' ) ) { wp_die('teachPress error: This request could not be verified!'); exit; } tp_uninstall(); get_tp_message( __('Database uninstalled','teachpress') ); } } /** * Checks the nonce field of the form. If the check fails wp_die() will be executed */ private static function check_nonce_field () { if ( ! isset( $_POST['tp_nonce'] ) || ! wp_verify_nonce( $_POST['tp_nonce'], 'verify_teachpress_settings' ) ) { wp_die('teachPress error: This request could not be verified!'); exit; } } }