예제 #1
0
        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!');
                }
            }
        }
예제 #2
0
 function display_quote($event_id)
 {
     global $mdjm, $my_mdjm, $post;
     $online_template = MDJM()->events->retrieve_quote($event_id);
     if (empty($online_template) || !is_string(get_post_status($online_template))) {
         if (MDJM_DEBUG == true) {
             MDJM()->debug->log_it('The online template associated with event with ID ' . $event_id . ' could not be found in ' . __METHOD__, true);
         }
         parent::display_notice(4, sprintf(__('Unable to process request. Please %scontact us%s for assistance', 'mobile-dj-manager'), '<a href="' . mdjm_get_formatted_url(MDJM_CONTACT_PAGE, false) . '">', '</a>'));
         return;
     }
     if (!$this->update_event_quote($event_id, $online_template)) {
         if (MDJM_DEBUG == true) {
             MDJM()->debug->log_it('Unable to update quote post for event with ID ' . $event_id . ' in ' . __METHOD__, true);
         }
     }
     $post = get_post($online_template);
     // Make sure we have the template
     if (!is_object($post)) {
         if (MDJM_DEBUG == true) {
             MDJM()->debug->log_it('The online template with ID ' . $online_template . ' could not be retrieved in ' . __METHOD__, true);
         }
         parent::display_notice(4, sprintf(__('Unable to process request. Please %scontact us%s for assistance', 'mobile-dj-manager'), '<a href="' . mdjm_get_formatted_url(MDJM_CONTACT_PAGE, false) . '">', '</a>'));
         return;
     }
     $eventinfo = MDJM()->events->event_detail($event_id);
     // Make sure we have the event info
     if (empty($eventinfo)) {
         if (MDJM_DEBUG == true) {
             MDJM()->debug->log_it('Could not retrieve event information for event ' . $event_id . ' in ' . __METHOD__, true);
         }
         parent::display_notice(4, sprintf(__('Unable to process request. Please %scontact us%s for assistance', 'mobile-dj-manager'), '<a href="' . mdjm_get_formatted_url(MDJM_CONTACT_PAGE, false) . '">', '</a>'));
         return;
     }
     // Display the online quotation
     /* -- Retrieve the quote content -- */
     $content = $post->post_content;
     $content = apply_filters('the_content', $content);
     $content = str_replace(']]>', ']]&gt;', $content);
     /* -- Shortcode replacements -- */
     $content = $mdjm->filter_content($my_mdjm['me']->ID, $event_id, $content);
     if (!empty($content)) {
         if ($this->button_loc == 'before' || $this->button_loc == 'both') {
             $this->display_book_button($event_id);
         }
         print $content;
         if ($this->button_loc == 'after' || $this->button_loc == 'both') {
             $this->display_book_button($event_id);
         }
     } else {
         parent::display_notice(4, sprintf(__('An error has occured, please %scontact us%s for assistance', 'mobile-dj-manager'), '<a href="' . mdjm_get_formatted_url(MDJM_CONTACT_PAGE, false) . '">', '</a>'));
     }
 }
예제 #3
0
        function client_form()
        {
            global $my_mdjm, $mdjm, $mdjm_settings;
            /* -- Playlist Additions -- */
            if (isset($_POST['submit']) && $_POST['submit'] == 'Add Song') {
                $this->add_song();
            }
            /* -- Playlist Removal -- */
            if (isset($_GET['remove_song']) && !empty($_GET['remove_song'])) {
                $this->remove_song($_GET['remove_song']);
            }
            /* -- Enqueue jQuery validation -- */
            wp_enqueue_script('mdjm-validation');
            /* WELCOME TEXT */
            echo parent::__text('playlist_welcome', '<p>Welcome to the ' . MDJM_COMPANY . ' event playlist management system.</p>');
            /* INTRO TEXT */
            echo parent::__text('playlist_intro', '<p>Use this tool to let your DJ know the songs that you would like played (or perhaps not played) ' . 'during your event on <strong>' . date('l, jS F Y', $this->eventinfo['date']) . '</strong>.</p>');
            /* If client has more than one event, allow them to switch between events */
            if (count($my_mdjm['active']) > 1) {
                ?>
					<?php 
                /* EDITING PLAYLIST TEXT */
                echo parent::__text('playlist_edit', '<p>You are currently editing the playlist for your event on ' . date('l, jS F Y', $this->eventinfo['date']) . '. To edit the playlist for one of your other events, ' . 'return to the <a href="' . mdjm_get_formatted_url(MDJM_HOME, false) . '">' . MDJM_APP . ' home page</a> and select Edit Playlist from the drop down list displayed next to the event for ' . 'which you want to edit the playlist.</p>');
            }
            // if( count( $my_mdjm['active'] ) > 1 )
            $num_songs = MDJM()->events->count_playlist_entries($this->event->ID);
            /* Display the form to add songs to playlist */
            if (MDJM()->events->playlist_status($this->eventinfo['date'])) {
                // Display form
                echo '<hr />' . "\r\n";
                echo '<div id="mdjm-playlist-container">' . "\r\n";
                echo '<div id="mdjm-playlist-table">' . "\r\n";
                echo '<form action="' . mdjm_get_formatted_url(MDJM_PLAYLIST_PAGE) . 'event_id=' . $this->event->ID . '" method="post" enctype="multipart/form-data" name="client-playlist" id="client-playlist">' . "\r\n";
                wp_nonce_field('manage_playlist', '__mdjm_playlist') . "\r\n";
                echo '<table id="mdjm-playlist-display">' . "\r\n";
                echo '<tr>' . "\r\n";
                echo '<td><label for="playlist_song">' . __('Song Name') . '</label>:<br />' . '<input name="playlist_song" id="playlist_song" type="text" size="25" class="required" /></td>' . "\r\n";
                echo '<td><label for="playlist_artist">' . __('Artist') . '</label>?<br />' . '<input name="playlist_artist" id="playlist_artist" type="text" size="25" class="required" /></td>' . "\r\n";
                echo '<td><label for="playlist_when">' . __('When to Play') . '</label>:<br />' . '<select name="playlist_when" id="playlist_when">' . "\r\n";
                $pl_when = explode("\n", $mdjm_settings['playlist']['playlist_cats']);
                foreach ($pl_when as $when) {
                    echo '<option value="' . $when . '">' . $when . '</option>' . "\r\n";
                }
                // foreach( $pl_when as $when )
                echo '</select></td>' . "\r\n";
                echo '<td><label for="playlist_info">' . __('Info') . '</label>:<br />' . '<textarea name="playlist_info" id="playlist_info" placeholder="Optional: add information if you selected Other from the drop down list">' . '</textarea></td>' . "\r\n";
                echo '</tr>' . "\r\n";
                echo '<tr>' . "\r\n";
                echo '<td colspan="4" style="text-align: left;"><input name="submit" id="submit" type="submit" value="Add Song" /></td>' . "\r\n";
                echo '</tr>' . "\r\n";
                // End the table display
                echo '</table>' . "\r\n";
                echo '</form>' . "\r\n";
                echo '</div>' . "\r\n";
                // End div mdjm-playlist-table
                echo '</div>' . "\r\n";
                // End div mdjm-playlist-container
            } else {
                echo parent::display_notice(1, parent::__text('playlist_closed', '<p>Additions to your playlist are disabled to allow your 
												' . MDJM_DJ . ' to prepare for your event.</p>'));
                if ($num_songs > 0) {
                    echo '<p>' . __('Existing playlist entries are displayed below') . '.</p>';
                }
            }
            /* -- Display existing entries if we have them -- */
            if ($num_songs > 0) {
                // Songs to display
                $categories = MDJM()->events->get_playlist_by_cat($this->event->ID);
                echo '<div id="mdjm_song_container">' . "\r\n";
                foreach ($categories as $category => $songs) {
                    echo '<table class="mdjm_song_table">' . "\r\n";
                    echo '<tr>' . "\r\n";
                    echo '<th colspan="4">' . $category . '</th>' . "\r\n";
                    echo '</tr>' . "\r\n";
                    foreach ($songs as $song) {
                        echo '<tr>' . "\r\n";
                        echo '<td>' . $song->song . '</td>' . "\r\n";
                        echo '<td>' . $song->artist . '</td>' . "\r\n";
                        if ($category == 'Guest Added') {
                            echo '<td>' . $song->added_by . '</td>' . "\r\n";
                        } else {
                            echo '<td>' . (!empty($song->info) ? stripslashes($song->info) : '') . '</td>' . "\r\n";
                        }
                        echo '<td style="text-align: right;"><a href="' . mdjm_get_formatted_url(MDJM_PLAYLIST_PAGE) . 'remove_song=' . $song->id . '">' . __('Remove') . '</a></td>' . "\r\n";
                        echo '</tr>' . "\r\n";
                    }
                    echo '<tr>' . "\r\n";
                    echo '<td colspan="4" style="font-weight: bold; border-top: 2px solid;">' . count($songs) . _n(' Song', ' Songs', count($songs)) . '</td>' . "\r\n";
                    echo '</tr>' . "\r\n";
                    echo '</table>' . "\r\n";
                }
                // End foreach
                echo '</div>' . "\r\n";
                // End div mdjm_song_container
            }
            // if( $num_songs > 0 )
        }