Example #1
0
            ?>
" title="<?php 
            printf(esc_attr__('Permalink to %s', 'wpuf'), the_title_attribute('echo=0'));
            ?>
" rel="bookmark"><?php 
            the_title();
            ?>
</a>

                        <?php 
        }
        ?>
                    </td>
                    <td>
                        <?php 
        wpuf_show_post_status($post->post_status);
        ?>
                    </td>

                    <?php 
        do_action('wpuf_dashboard_row_col', $args, $post);
        ?>

                    <?php 
        if ($charging_enabled == 'yes') {
            $order_id = get_post_meta($post->ID, '_wpuf_order_id', true);
            ?>
                        <td>
                            <?php 
            if ($post->post_status == 'pending' && $order_id) {
                ?>
    /**
     * List's all the posts by the user
     *
     * @global object $wpdb
     * @global object $userdata
     */
    function post_listing($post_type)
    {
        global $wpdb, $userdata, $post;
        $userdata = get_userdata($userdata->ID);
        $pagenum = isset($_GET['pagenum']) ? intval($_GET['pagenum']) : 1;
        //delete post
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == "del") {
            $this->delete_post();
        }
        //show delete success message
        if (isset($_GET['msg']) && $_GET['msg'] == 'deleted') {
            echo '<div class="success">' . __('Post Deleted', 'wpuf') . '</div>';
        }
        $args = array('author' => get_current_user_id(), 'post_status' => array('draft', 'future', 'pending', 'publish'), 'post_type' => $post_type, 'posts_per_page' => wpuf_get_option('per_page', 'wpuf_dashboard', 10), 'paged' => $pagenum);
        $dashboard_query = new WP_Query($args);
        $post_type_obj = get_post_type_object($post_type);
        ?>

        <h2 class="page-head">
            <span class="colour"><?php 
        printf(__("%s's Dashboard", 'wpuf'), $userdata->user_login);
        ?>
</span>
        </h2>

        <?php 
        if (wpuf_get_option('show_post_count', 'wpuf_dashboard', 'on') == 'on') {
            ?>
            <div class="post_count"><?php 
            printf(__('You have created <span>%d</span> %s', 'wpuf'), $dashboard_query->found_posts, $post_type_obj->label);
            ?>
</div>
        <?php 
        }
        ?>

        <?php 
        do_action('wpuf_dashboard_top', $userdata->ID, $post_type_obj);
        ?>

        <?php 
        if ($dashboard_query->have_posts()) {
            ?>

            <?php 
            $featured_img = wpuf_get_option('show_ft_image', 'wpuf_dashboard');
            $featured_img_size = wpuf_get_option('ft_img_size', 'wpuf_dashboard');
            $charging_enabled = wpuf_get_option('charge_posting', 'wpuf_payment', 'no');
            ?>
            <table class="wpuf-table" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <?php 
            if ('on' == $featured_img) {
                echo '<th>' . __('Featured Image', 'wpuf') . '</th>';
            }
            ?>
                        <th><?php 
            _e('Title', 'wpuf');
            ?>
</th>
                        <th><?php 
            _e('Status', 'wpuf');
            ?>
</th>
                        <?php 
            if ('yes' == $charging_enabled) {
                echo '<th>' . __('Payment', 'wpuf') . '</th>';
            }
            ?>
                        <th><?php 
            _e('Options', 'wpuf');
            ?>
</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
            while ($dashboard_query->have_posts()) {
                $dashboard_query->the_post();
                ?>
                        <tr>
                            <?php 
                if ('on' == $featured_img) {
                    ?>
                                <td>
                                    <?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail($featured_img_size);
                    } else {
                        printf('<img src="%1$s" class="attachment-thumbnail wp-post-image" alt="%2$s" title="%2$s" />', apply_filters('wpuf_no_image', plugins_url('/images/no-image.png', __FILE__)), __('No Image', 'wpuf'));
                    }
                    ?>
                                </td>
                            <?php 
                }
                ?>
                            <td>
                                <?php 
                if (in_array($post->post_status, array('draft', 'future', 'pending'))) {
                    ?>

                                    <?php 
                    the_title();
                    ?>

                                <?php 
                } else {
                    ?>

                                    <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    printf(esc_attr__('Permalink to %s', 'wpuf'), the_title_attribute('echo=0'));
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a>

                                <?php 
                }
                ?>
                            </td>
                            <td>
                                <?php 
                wpuf_show_post_status($post->post_status);
                ?>
                            </td>

                            <?php 
                if ($charging_enabled == 'yes') {
                    $order_id = get_post_meta($post->ID, 'wpuf_order_id', true);
                    ?>
                                <td>
                                    <?php 
                    if ($post->post_status == 'pending' && $order_id) {
                        ?>
                                        <a href="<?php 
                        echo trailingslashit(get_permalink(wpuf_get_option('payment_page', 'wpuf_payment')));
                        ?>
?action=wpuf_pay&type=post&post_id=<?php 
                        echo $post->ID;
                        ?>
">Pay Now</a>
                                    <?php 
                    }
                    ?>
                                </td>
                            <?php 
                }
                ?>

                            <td>
                                <?php 
                if (wpuf_get_option('enable_post_edit', 'wpuf_others', 'yes') == 'yes') {
                    ?>
                                    <?php 
                    $edit_page = (int) wpuf_get_option('edit_page_id', 'wpuf_others');
                    $url = get_permalink($edit_page);
                    ?>
                                    <a href="<?php 
                    echo wp_nonce_url($url . '?pid=' . $post->ID, 'wpuf_edit');
                    ?>
"><?php 
                    _e('Edit', 'wpuf');
                    ?>
</a>
                                <?php 
                } else {
                    ?>
                                    &nbsp;
                                <?php 
                }
                ?>

                                <?php 
                if (wpuf_get_option('enable_post_del', 'wpuf_others', 'yes') == 'yes') {
                    ?>
                                    <a href="<?php 
                    echo wp_nonce_url("?action=del&pid=" . $post->ID, 'wpuf_del');
                    ?>
" onclick="return confirm('Are you sure to delete this post?');"><span style="color: red;"><?php 
                    _e('Delete', 'wpuf');
                    ?>
</span></a>
                                <?php 
                }
                ?>
                            </td>
                        </tr>
                    <?php 
            }
            ?>
                </tbody>
            </table>

            <div class="wpuf-pagination">
                <?php 
            $pagination = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'prev_text' => __('&laquo;', 'wpuf'), 'next_text' => __('&raquo;', 'wpuf'), 'total' => $dashboard_query->max_num_pages, 'current' => $pagenum));
            if ($pagination) {
                echo $pagination;
            }
            ?>
            </div>

            <?php 
        } else {
            printf(__('No %s found', 'wpuf'), $post_type_obj->label);
            do_action('wpuf_dashboard_nopost', $userdata->ID, $post_type_obj);
        }
        do_action('wpuf_dashboard_bottom', $userdata->ID, $post_type_obj);
        ?>

        <?php 
        $this->user_info();
    }
/**
 * List's all the posts by the user
 *
 * @since version 0.1
 * @author Tareq Hasan
 *
 * @global object $wpdb
 * @global object $userdata
 */
function wpuf_user_dashboard_attente_list($post_type)
{
    global $wpdb, $userdata;
    $userdata = get_userdata($userdata->ID);
    //delete post
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == "del") {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'wpuf_del')) {
            die("Security check");
        }
        //check, if the requested user is the post author
        $post = get_post($_REQUEST['pid']);
        if ($post->post_author == $userdata->ID) {
            wp_delete_post($_REQUEST['pid']);
            echo '<div class="success">' . __($post_type . ' Supprimé', 'wpuf') . '</div>';
        } else {
            echo '<div class="error">' . __('Vous n\'êtes propriétaire de ce projet. triche!! huh!', 'wpuf') . '</div>';
        }
    }
    //valider post
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == "val") {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'wpuf_val')) {
            die("Security check");
        }
        //check, if the requested user is the post author
        ////$post = get_post($_REQUEST['pid'] );
        $my_post = array();
        $my_post['ID'] = $_REQUEST['pid'];
        $my_post['post_status'] = 'publish';
        $res = wp_update_post($my_post);
        if ($res == $_REQUEST['pid']) {
            echo '<div class="success">' . __(utf8_encode($post_type . ' Validé(e)'), 'wpuf') . '</div>';
        } else {
            echo '<div class="error">' . __(utf8_encode('Vous n\'êtes propriétaire de ce projet. triche!! huh!'), 'wpuf') . '</div>';
        }
    }
    //get the posts count from db
    $sql = "SELECT count(ID) FROM {$wpdb->posts}\n            WHERE post_type = '{$post_type}'\n            AND  post_status = 'pending'";
    $total = $wpdb->get_var($sql);
    //setup the pagination variables
    $pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1;
    $limit = get_option('wpuf_list_post_range') ? get_option('wpuf_list_post_range') : 10;
    $offset = ($pagenum - 1) * $limit;
    $num_of_pages = $total > 0 ? ceil($total / $limit) : 0;
    $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'prev_text' => __('&laquo;', 'aag'), 'next_text' => __('&raquo;', 'aag'), 'total' => $num_of_pages, 'current' => $pagenum));
    //get the posts
    $sql = "SELECT ID, post_title, post_name, post_status, post_date,post_author FROM {$wpdb->posts}\n            WHERE  post_type = '{$post_type}'\n            AND  post_status = 'pending' ORDER BY post_date DESC LIMIT {$offset}, {$limit}";
    $posts = $wpdb->get_results($sql);
    ?>

    <h2 class="page-head">
        <span class="colour"><?php 
    printf(__('Les ' . $post_type . 's en attente', 'wpuf'));
    ?>
</span>
    </h2>
    <?php 
    if ($posts) {
        ?>

        <?php 
        if (get_option('wpuf_list_post_count') == 'yes') {
            ?>
            <div class="post_count"><?php 
            _e('Il y a  ', 'wpuf');
            ?>
 <?php 
            echo "<span>{$total}</span> {$post_type}";
            ?>
(s) en attente</div>
        <?php 
        }
        ?>
        
        <?php 
        do_action('wpuf_dashboard', $userdata->ID, $post_type);
        ?>

        <table class="wpuf-table" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th><?php 
        _e('Titre', 'wpuf');
        ?>
</th>
                    <th><?php 
        _e('Etat', 'wpuf');
        ?>
</th>
                     <?php 
        if (get_option('wpuf_sub_charge_posting') == 'yes') {
            echo '<th>' . __('Payment', 'wpuf') . '</th>';
        }
        ?>
                    <th><?php 
        _e('Options', 'wpuf');
        ?>
</th>
                    <th><?php 
        _e('Auteur', 'wpuf');
        ?>
</th>
                </tr>
            </thead>
            <tbody>
                <?php 
        wp_reset_query();
        ?>
                <?php 
        foreach ($posts as $p) {
            ?>
                    <tr>
                        <td>
                                <a href="<?php 
            echo get_permalink($p->ID);
            ?>
"><?php 
            echo wptexturize($p->post_title);
            ?>
</a>
                        </td>
                        <td>
                            <?php 
            wpuf_show_post_status($p->post_status);
            ?>
                         </td>
                        <?php 
            if (get_option('wpuf_sub_charge_posting') == 'yes') {
                $order_id = get_post_meta($p->ID, 'wpuf_order_id', true);
                ?>
                            <td>
                                <?php 
                if ($p->post_status == 'pending' && $order_id) {
                    ?>
                                    <a href="<?php 
                    echo get_permalink(get_option('wpuf_sub_pay_page'));
                    ?>
?action=wpuf_pay&type=post&post_id=<?php 
                    echo $p->ID;
                    ?>
">Pay Now</a>
                                <?php 
                }
                ?>
                            </td>
                        <?php 
            }
            ?>

                        <td>
                            <?php 
            if (get_option('wpuf_can_edit_post') == 'yes') {
                ?>
                                <?php 
                $edit_page = (int) get_option('wpuf_edit_page_url');
                $url = get_permalink($edit_page);
                ?>
                                 <a href="<?php 
                echo wp_nonce_url("?action=val&pid=" . $p->ID, 'wpuf_val');
                ?>
"> <?php 
                _e('Valider', 'wpuf');
                ?>
</a>

                            <?php 
            } else {
                ?>
                                &nbsp;
                            <?php 
            }
            ?>

                            <?php 
            if (get_option('wpuf_can_del_post') == 'yes') {
                ?>
                                <a href="<?php 
                echo wp_nonce_url("?action=del&pid=" . $p->ID, 'wpuf_del');
                ?>
" onclick="return confirm('Are you sure to delete this post?');"><span style="color: red;"><?php 
                _e('Supprimer', 'wpuf');
                ?>
</span></a>
                            <?php 
            }
            ?>
                        </td>
                        <td>
                             <?php 
            $userinf = get_userdata($p->post_author);
            $val = 'inconnu';
            if (isset($userinf->first_name)) {
                $val = $userinf->first_name;
            }
            if (isset($userinf->last_name)) {
                $val .= ' ' . $userinf->last_name;
            }
            if (isset($userinf->user_login)) {
                $val = $userinf->user_login;
            }
            if ($val == 'inconnu') {
                echo $val;
            } else {
                echo '<a href="mailto:' . $userinf->user_email . '" target="_blank">' . $val . '</a>';
            }
            ?>
                        </td>
                    </tr>
                <?php 
        }
        ?>
            </tbody>
        </table>

        <div class="wpuf-pagination">
            <?php 
        if ($page_links) {
            echo $page_links;
        }
        ?>
        </div>

    <?php 
    } else {
        ?>

        <h3><?php 
        _e(utf8_encode('Il n\'y a aucune proposition de ' . $post_type . ' en attente'), 'wpuf');
        ?>
</h3>

    <?php 
    }
    ?>


    <!--php if ( get_option( 'wpuf_list_user_info' ) == 'yes' ) { ?>
        <div class="wpuf-author">
            <h3><php _e( 'Author Info', 'wpuf' ); ?></h3>
            <div class="wpuf-author-inside odd">
                <div class="wpuf-user-image">php echo get_avatar( $userdata->user_email, 80 ); ?></div>
                <div class="wpuf-author-body">
                    <p class="wpuf-user-name"><a href="php echo get_author_posts_url( $userdata->ID ); ?>">php printf( esc_attr__( '%s', 'wpuf' ), $userdata->display_name ); ?></a></p>
                    <p class="wpuf-author-info">php echo $userdata->description; ?></p>
                </div>
            </div>
        </div> .author 
    php -->

    <?php 
}