validate(); $config_validator->save(); } $query = array( 'post' => $webinar_form ? $webinar_form->id() : 0, 'active-tab' => isset( $_POST['active-tab'] ) ? intval($_POST['active-tab']) : 0 ); $result = true; if ( ! $webinar_form ) { $result = false; $query['message'] = 'failed'; } elseif ( -1 == $id ) { $query['message'] = 'created'; } else { $query['message'] = 'saved'; } wp3cxw_delete_cache($id); return array('result'=>$result, 'query'=>$query, 'form'=>$webinar_form); } function wp3cxw_load_webinar_form_admin() { global $plugin_page; $action = wp3cxw_current_action(); if ( 'save' == $action ) { $reply=wp3cxw_save_webinar_action(); $redirect_to = add_query_arg( $reply['query'], menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'clear_cache' == $action ) { $id = isset( $_POST['post_ID'] ) ? intval($_POST['post_ID']) : '-1'; check_admin_referer( 'wp3cxw-save-webinar-form_' . $id ); if ( ! current_user_can( 'wp3cxw_edit_webinar_form', $id ) ) { wp_die( __( 'You are not allowed to edit this item.', '3cx-webinar' ) ); } wp3cxw_delete_cache($id); $query = array( 'post' => $id, 'active-tab' => isset( $_POST['active-tab'] ) ? intval($_POST['active-tab']) : 0 ); $query['message'] = 'cache cleared'; $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'test_api' == $action ) { $res=wp3cxw_save_webinar_action(); $webinar_form=$res['form']; $query = $res['query']; if ($res['result'] && $webinar_form) { $config_validator = new WP3CXW_ConfigValidator( $webinar_form ); if ($config_validator->validate()) { $properties = $webinar_form->get_properties(); $config = $properties['config']; $url = $config['portalfqdn'].'/webmeeting/api/v1/meetings?isWebinar=true&isScheduled=false'; if ($config['extension']!=''){ $url.='&extension='.$config['extension']; } if (!empty($config['subject'])) { $url.='&subjectContains='.$config['subject']; } if (!empty($config['days']) && intval($config['days'])>0) { $url.='&daysLimit='.intval($config['days']); } $reply = wp3cxw_send_api_request('get', $config['apitoken'], $url); } else { $reply['error']='One or more invalid parameters'; } $query['message'] = 'test api sent'; $query['apimessage'] = 'tcxwm_test_api_'.md5(mt_rand().time()); set_transient($query['apimessage'], $reply, 10); } else { $query['message'] = 'test api failed'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'copy' == $action ) { $id = empty( $_POST['post_ID'] ) ? intval( $_REQUEST['post'] ) : intval( $_POST['post_ID'] ); check_admin_referer( 'wp3cxw-copy-webinar-form_' . $id ); if ( ! current_user_can( 'wp3cxw_edit_webinar_form', $id ) ) { wp_die( __( 'You are not allowed to edit this item.', '3cx-webinar' ) ); } $query = array(); if ( $webinar_form = wp3cxw_webinar_form( $id ) ) { $new_webinar_form = $webinar_form->copy(); $new_webinar_form->save(); $query['post'] = $new_webinar_form->id(); $query['message'] = 'created'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } if ( 'delete' == $action ) { $rawposts = (array) $_REQUEST['post']; $posts = array(); foreach($rawposts as $v){ $v=intval($v); if (!empty($v)) { $posts[]=$v; } } $id = empty( $_POST['post_ID'] ) ? intval( $_REQUEST['post'] ) : intval( $_POST['post_ID'] ); check_admin_referer( 'wp3cxw-delete-webinar-form_' . $id ); $deleted = 0; foreach ( $posts as $id ) { $post = WP3CXW_WebinarForm::get_instance( $id ); if ( empty( $post ) ) { continue; } if ( ! current_user_can( 'wp3cxw_delete_webinar_form', $post->id() ) ) { wp_die( __( 'You are not allowed to delete this item.', '3cx-webinar' ) ); } if ( ! $post->delete() ) { wp_die( __( 'Error in deleting.', '3cx-webinar' ) ); } $deleted += 1; } $query = array(); if ( ! empty( $deleted ) ) { $query['message'] = 'deleted'; } $redirect_to = add_query_arg( $query, menu_page_url( 'wp3cxw', false ) ); wp_safe_redirect( $redirect_to ); exit(); } $_GET['post'] = isset( $_GET['post'] ) ? intval($_GET['post']) : ''; $post = null; if ( 'wp3cxw-new' == $plugin_page ) { // TODO: add support for multilanguage $post = WP3CXW_WebinarForm::get_template( array( 'locale' => null ) ); } elseif ( ! empty( $_GET['post'] ) ) { $post = WP3CXW_WebinarForm::get_instance( intval($_GET['post'])) ; } $current_screen = get_current_screen(); $help_tabs = new WP3CXW_Help_Tabs( $current_screen ); if ( $post && current_user_can( 'wp3cxw_edit_webinar_form', $post->id() ) ) { $help_tabs->set_help_tabs( 'edit' ); } else { $help_tabs->set_help_tabs( 'list' ); if ( ! class_exists( 'WP3CXW_Webinar_Form_List_Table' ) ) { require_once WP3CXW_PLUGIN_DIR . '/admin/includes/class-webinar-forms-list-table.php'; } add_filter( 'manage_' . $current_screen->id . '_columns', array( 'WP3CXW_Webinar_Form_List_Table', 'define_columns' ) ); add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'wp3cxw_webinar_forms_per_page', ) ); } } add_action( 'admin_enqueue_scripts', 'wp3cxw_admin_enqueue_scripts' ); function wp3cxw_admin_enqueue_scripts( $hook_suffix ) { if ( false === strpos( $hook_suffix, 'wp3cxw' ) ) { return; } wp_enqueue_style( '3cx-webinar-admin', wp3cxw_plugin_url( 'admin/css/styles.css' ), array(), WP3CXW_VERSION, 'all' ); wp_enqueue_style( '3cx-webinar-dd', wp3cxw_plugin_url( 'includes/css/dd.css' ), array(), WP3CXW_VERSION, 'all' ); wp_enqueue_style( '3cx-webinar-flags', wp3cxw_plugin_url( 'includes/css/flags.css' ), array(), WP3CXW_VERSION, 'all' ); if ( wp3cxw_is_rtl() ) { wp_enqueue_style( '3cx-webinar-admin-rtl', wp3cxw_plugin_url( 'admin/css/styles-rtl.css' ), array(), WP3CXW_VERSION, 'all' ); } wp_enqueue_script( 'wp3cxw-admin', wp3cxw_plugin_url( 'admin/js/scripts.js' ), array( 'jquery', 'jquery-ui-tabs' ), WP3CXW_VERSION, true ); wp_enqueue_script( 'wp3cxw-admin-dd', wp3cxw_plugin_url( 'includes/js/jquery.dd.js' ), array( 'jquery' ), WP3CXW_VERSION, false ); $args = array( 'apiSettings' => array( 'root' => esc_url_raw( rest_url( '3cx-webinar/v1' ) ), 'namespace' => '3cx-webinar/v1', 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), ), 'testApiUrl' => get_rest_url(null, '/3cx-webinar/testapi'), 'pluginUrl' => wp3cxw_plugin_url(), 'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", '3cx-webinar' ), 'activeTab' => isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : 0, 'configValidator' => array( 'errors' => array(), 'howToCorrect' => __( "How to resolve?", '3cx-webinar' ), 'oneError' => __( '1 configuration error detected', '3cx-webinar' ), 'manyErrors' => __( '%d configuration errors detected', '3cx-webinar' ), 'oneErrorInTab' => __( '1 configuration error detected in this tab panel', '3cx-webinar' ), 'manyErrorsInTab' => __( '%d configuration errors detected in this tab panel', '3cx-webinar' ), 'docUrl' => '', /* translators: screen reader text */ 'iconAlt' => __( '(configuration error)', '3cx-webinar' ), ), ); if ( ( $post = wp3cxw_get_current_webinar_form() ) && current_user_can( 'wp3cxw_edit_webinar_form', $post->id() ) ) { $config_validator = new WP3CXW_ConfigValidator( $post ); $config_validator->restore(); $args['configValidator']['errors'] = $config_validator->collect_error_messages(); } wp_localize_script( 'wp3cxw-admin', 'wp3cxw', $args ); } function wp3cxw_admin_management_page() { if ( $post = wp3cxw_get_current_webinar_form() ) { $post_id = $post->initial() ? -1 : $post->id(); require_once WP3CXW_PLUGIN_DIR . '/admin/includes/editor.php'; require_once WP3CXW_PLUGIN_DIR . '/admin/edit-webinar-form.php'; return; } $list_table = new WP3CXW_Webinar_Form_List_Table(); $list_table->prepare_items(); ?>

%2$s', esc_url( menu_page_url( 'wp3cxw-new', false ) ), esc_html( __( 'Add New', '3cx-webinar' ) ) ); } ?>
display(); ?>

%s

', esc_html( $updated_message ) ); } if ( 'failed' == $_REQUEST['message']) { $updated_message = __( "There was an error saving the webinar form.", '3cx-webinar' ); echo sprintf( '

%s

', esc_html( $updated_message ) ); return; } if ( 'test api failed' == $_REQUEST['message']) { $updated_message = __( "Test API Request error.", '3cx-webinar' ); echo sprintf( '

%s

', esc_html( $updated_message ) ); return; } } add_action( 'wp3cxw_admin_warnings', 'wp3cxw_old_wp_version_error' ); function wp3cxw_old_wp_version_error() { $wp_version = get_bloginfo( 'version' ); if ( ! version_compare( $wp_version, WP3CXW_REQUIRED_WP_VERSION, '<' ) ) { return; } ?>

'.sprintf( __( '3CX Webinars %1$s requires WordPress %2$s or higher.'), WP3CXW_VERSION, WP3CXW_REQUIRED_WP_VERSION).''; /* translators: "Please update Wordpress first" */ echo ' '.sprintf(__('Please %s first','3cx-webinar'), sprintf('', admin_url( 'update-core.php' )).__('update WordPress', '3cx-webinar').''); ?>

id(); if ( current_user_can( 'wp3cxw_edit_webinar_form', $post_id ) ) { return; } $message = __( "You are not allowed to edit this Webinar form.", '3cx-webinar' ); echo sprintf( '

%s

', esc_html( $message ) ); }