function __construct($args = '') { global $mdjm, $clientzone_loaded, $mdjm_settings; // Must be authenticated if (!is_user_logged_in()) { parent::login(); } elseif (empty($mdjm_settings['templates']['online_enquiry'])) { parent::display_notice(4, sprintf(__('This option is disabled for your event. Please %scontact us%s for assistance', 'mobile-dj-manager'), '<a href="' . mdjm_get_formatted_url(MDJM_CONTACT_PAGE, false) . '">', '</a>')); } elseif (!$this->should_i_be_here()) { // do validation parent::display_notice(4, sprintf(__('An error is stopping your access to this quotation. Please %scontact us%s for assistance', 'mobile-dj-manager'), '<a href="' . mdjm_get_formatted_url(MDJM_CONTACT_PAGE, false) . '">', '</a>')); } else { if (isset($_GET['message'], $_GET['class'])) { parent::display_message($_GET['message'], $_GET['class']); } // Possible button settings $button_loc = array('before', 'after', 'both'); $button_align = array('left', 'center', 'right'); // Define button settings $this->book_button = !empty($args['book_button']) ? true : false; $this->button_loc = !empty($args['button_loc']) && in_array($button_loc) ? $args['button_loc'] : 'both'; $this->button_align = !empty($args['button_align']) && in_array($button_loc) ? $args['button_align'] : 'center'; $this->button_text = !empty($args['button_text']) ? $args['button_text'] : __('Book this Event', 'mobile-dj-manager'); $this->button_class = !empty($args['button_class']) ? $args['button_class'] : false; $this->display_quote($_GET['event_id']); } }
function add_song() { global $mdjm, $my_mdjm, $wpdb; // Firstly, our security check if (!isset($_POST['__mdjm_playlist']) || !wp_verify_nonce($_POST['__mdjm_playlist'], 'manage_playlist')) { MDJM()->debug->log_it('Security verification failed during playlist addition. No update occured', false); return parent::display_message(4, 4); } else { $when = !empty($_POST['playlist_when']) ? $_POST['playlist_when'] : 'General'; if (!is_user_logged_in()) { $when = 'Guest Added'; } $by = is_user_logged_in() ? $my_mdjm['me']->display_name : ucwords($_POST['first_name'] . ' ' . $_POST['last_name']); // Insert the record $update_id = $wpdb->insert(MDJM_PLAYLIST_TABLE, array('id' => '', 'event_id' => $this->event->ID, 'artist' => $_POST['playlist_artist'], 'song' => $_POST['playlist_song'], 'play_when' => $when, 'info' => isset($_POST['playlist_info']) ? $_POST['playlist_info'] : '', 'added_by' => $by, 'date_added' => date('Y-m-d'))); if (!empty($update_id)) { // Success // Journal Entry if (MDJM_JOURNAL == true) { mdjm_add_journal(array('user_id' => $this->eventinfo['client']->ID, 'event_id' => $this->event->ID, 'comment_content' => 'Song added to playlist by ' . $by), array('type' => 'update-event', 'visibility' => '2')); } if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Song added to Event ID: ' . $this->event->ID . ' Playlist by ' . $by, true); } // Create an array we can use to display the entries from this session $this->current_songs[] = $wpdb->insert_id; parent::display_notice(2, __('The song was successfully added')); } else { // Failed if (MDJM_DEBUG == true) { MDJM()->debug->log_it('ERROR: Could not add song to playlist. ' . $wpdb->print_error(), true); } parent::display_notice(4, __('An error occurred. Please try again.')); } } }
function update_profile() { global $mdjm, $current_user; MDJM()->debug->log_it('Starting user profile update for user ' . $current_user->display_name, true); // Firstly, our security check if (!isset($_POST['__mdjm_user']) || !wp_verify_nonce($_POST['__mdjm_user'], 'manage_client_profile')) { MDJM()->debug->log_it('Security verification failed during update. No update occured', false); return parent::display_message(4, 4); } else { // Set our variables for updating $update_fields = array('ID' => $current_user->ID); $update_meta = array(); // Process the standard fields $update_fields['first_name'] = sanitize_text_field(ucfirst($_POST['first_name'])); $update_fields['last_name'] = sanitize_text_field(ucfirst($_POST['last_name'])); $update_fields['user_email'] = sanitize_email($_POST['user_email']); // Now the custom fields foreach ($this->fields as $field) { if (!isset($field['required']) || empty($field['display'])) { continue; } if ($field['type'] == 'text' || $field['type'] == 'dropdown') { $update_meta[$field['id']] = !empty($_POST[$field['id']]) ? sanitize_text_field($_POST[$field['id']]) : ''; } if ($field['type'] == 'checkbox') { $update_meta[$field['id']] = !empty($_POST[$field['id']]) ? $_POST[$field['id']] : '0'; } } // Password Reset Validation if required if (!empty($_POST['new_password']) && $_POST['new_password'] != $_POST['new_password_confirm']) { $pass_error = true; } if (!empty($_POST['new_password']) && $_POST['new_password'] == $_POST['new_password_confirm']) { $update_fields['user_pass'] = $_POST['new_password']; } // Process field updates starting with custom fields foreach ($update_meta as $meta_key => $meta_value) { if (update_user_meta($current_user->ID, $meta_key, $meta_value)) { MDJM()->debug->log_it('Success: User profile field ' . $meta_key . ' updated with value ' . $meta_value, false); } else { MDJM()->debug->log_it('Failure: User profile field ' . $meta_key . ' could not be updated with value ' . $meta_value, false); } } // And now built-in fields $user_id = wp_update_user($update_fields); // If we changed the password, we need to logout if (isset($update_fields['user_pass'])) { MDJM()->debug->log_it('User password was changed. Logging user out', false); wp_logout(); ?> <script type="text/javascript"> window.location.replace("<?php echo mdjm_get_formatted_url(mdjm_get_option('profile_page')); ?> "); </script> <?php exit; } // We're done if (is_wp_error($user_id)) { parent::display_notice(4, 'Unable to update your profile. ' . $user_id->get_error_message()); } else { parent::display_notice(2, 'Your profile has been updated successfully'); } if (isset($pass_error) && $pass_error == true) { parent::display_notice(4, 'Unable to change your password. Check the password\'s you entered match!'); } } }