Skip to content

Commit

Permalink
enable error log by default but show only if admin enable it
Browse files Browse the repository at this point in the history
  • Loading branch information
randhirexpresstech committed May 16, 2024
1 parent e538f97 commit 8359efe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public function qsm_admin_notices() {

// Get failed alter table query list.
$failed_queries = $this->get_failed_alter_table_queries();
if ( ! empty( $failed_queries ) && is_array( $failed_queries ) && 0 < count( $failed_queries ) ) {
if ( ! empty( $failed_queries ) && 0 < count( $failed_queries ) ) {
?>
<div class="notice notice-warning is-dismissible qmn-database-user-incorrect-permission">
<p><?php esc_html_e( "It seems your database user doesn't have permission to ALTER TABLE. Please ensure the necessary permissions are in place or contact your hosting provider.", "quiz-master-next" ); ?></p>
Expand Down
9 changes: 5 additions & 4 deletions php/admin/class-failed-submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,20 @@ public function prepare_items() {
array(
'post_type' => 'qmn_log',
'meta_key' => $this->meta_key,
'post_status' => 'publish',
'fields' => 'ids',
'posts_per_page' => -1,
)
);

$posts = empty( $posts ) ? array() : $posts;
$per_page = 20;
// Total rows.
$this->total_rows = count( $posts );
if ( ! empty( $posts ) ) {
$current_page = intval( $this->get_pagenum() ) - 1;
$post_start_postion = $per_page * $current_page;

foreach ( $posts as $index => $postID ) {
if ( $post_start_postion > $index || $index > ( $post_start_postion + $per_page ) ) {
if ( $post_start_postion > $index || $index >= ( $post_start_postion + $per_page ) ) {
continue;
}
$data = get_post_meta( $postID, $this->meta_key, true );
Expand All @@ -89,7 +88,7 @@ public function prepare_items() {
// pagination.
$this->set_pagination_args(
array(
'total_items' => $this->total_rows,
'total_items' => count( $posts ),
'per_page' => $per_page,
)
);
Expand All @@ -101,6 +100,8 @@ public function prepare_items() {
$this->_column_headers = array(
$this->get_columns(),
$this->get_hidden_columns(),
array(), // Sortable column
'cb', // Primary column
);
}

Expand Down
5 changes: 1 addition & 4 deletions php/classes/class-qmn-log-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ public function add( $title = '', $message = '', $parent = 0, $type = null, $log
'log_type' => $type,
);
$settings = (array) get_option( 'qmn-settings' );
if ( ! empty( $settings['enable_qsm_log'] ) && $settings['enable_qsm_log'] ) {
return $this->insert_log( $log_data, $log_meta );
}
return false;
return $this->insert_log( $log_data, $log_meta );
}

/**
Expand Down
9 changes: 7 additions & 2 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public function process_action_failed_submission_table() {
if ( ! empty( $_REQUEST['post_id'] ) && ! empty( $_REQUEST['action'] ) && function_exists('is_admin') && is_admin() && ! empty( $_REQUEST['qmnnonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['qmnnonce'] ), 'qmn_failed_submission' ) ) {

$post_ids = wp_unslash( $_REQUEST['post_id'] );
$post_ids = is_array( $post_ids ) ? array_map( 'sanitize_key', $post_ids ) : sanitize_key( $post_ids );
$post_ids = is_array( $post_ids ) ? array_map( 'sanitize_key', $post_ids ) : array( sanitize_key( $post_ids ) );
$action = wp_unslash( sanitize_key( $_REQUEST['action'] ) );
if ( ! empty( $post_ids ) ) {
foreach ( $post_ids as $postID) {

$postID = intval( $postID );

// Continue if postID not valid
Expand Down Expand Up @@ -175,6 +175,11 @@ private function delete_failed_submission( $postID, $data = null ) {
$data['deleted'] = 1;
// Delete submission data
update_post_meta( $postID, $this->meta_key, maybe_serialize( $data ) );
// Change Error log post status to trash
wp_update_post( array(
'ID' => $postID,
'post_status' => 'trash',
) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
* Bug: Fixed display shortcode php buffer due to invalid quiz id
* Feature: Added Failed submission list in QSM menu
* Feature: Added retrieve or delete failed submission
* Enhancement: Added admin notification if database user does not has proper permission.
* Enhancement: Added admin notification if database user does not have proper permission.

= 9.0.1 (April 25, 2024) =
* Bug: Fixed date format in %ANSWER_X% variable
Expand Down

0 comments on commit 8359efe

Please sign in to comment.