Пример #1
0
function ProjectTheme_get_users_links()
{
    global $current_user, $wpdb;
    get_currentuserinfo();
    $rd = projectTheme_get_unread_number_messages($current_user->ID);
    if ($rd > 0) {
        $ssk = "<span class='notif_a'>" . $rd . "</span>";
    } else {
        $ssk = '';
    }
    $uid = $current_user->ID;
    //-----------------------
    $query = "select id from " . $wpdb->prefix . "project_ratings where fromuser='******' AND awarded='0'";
    $r = $wpdb->get_results($query);
    $ttl_fdbks = count($r);
    if ($ttl_fdbks > 0) {
        $ttl_fdbks2 = "<span class='notif_a'>" . $ttl_fdbks . "</span>";
    }
    $ProjectTheme_enable_2_user_tp = get_option('ProjectTheme_enable_2_user_tp');
    $user_tp = get_user_meta($uid, 'user_tp', true);
    ?>

    

	<div id="right-sidebar" class="account-sidebar">

			<ul class="xoxo">

			

			<li class="widget-container widget_text"> 

			<p>

			

            <ul id="my-account-admin-menu">

            	<li><a href="<?php 
    echo projectTheme_my_account_link();
    ?>
" <?php 
    echo $current_page == "home" ? "class='active'" : "";
    ?>
><?php 
    _e("MyAccount Home", 'ProjectTheme');
    ?>
</a></li>

                

                <?php 
    $pmnts_lnk = get_permalink(get_option('ProjectTheme_my_account_payments_id'));
    $pmnts_lnk = apply_filters('ProjectTheme_my_account_payments_id_link', $pmnts_lnk);
    $ProjectTheme_enable_credits_wallet = get_option('ProjectTheme_enable_credits_wallet');
    if ($ProjectTheme_enable_credits_wallet != 'no') {
        ?>
             

                <li><a href="<?php 
        echo $pmnts_lnk;
        ?>
"><?php 
        _e("Finances", 'ProjectTheme');
        ?>
</a></li>    

                <?php 
    }
    ?>

                            

                <li><a href="<?php 
    echo get_permalink(get_option('ProjectTheme_my_account_private_messages_id'));
    ?>
"><?php 
    echo sprintf(__("Private Messages %s", 'ProjectTheme'), $ssk);
    ?>
</a></li>

               	<li><a href="<?php 
    echo get_permalink(get_option('ProjectTheme_my_account_personal_info_id'));
    ?>
"><?php 
    _e("Personal Info", 'ProjectTheme');
    ?>
</a></li>

                <li><a href="<?php 
    echo get_permalink(get_option('ProjectTheme_my_account_feedback_id'));
    ?>
"><?php 
    printf(__("Feedback/Reviews %s", 'ProjectTheme'), $ttl_fdbks2);
    ?>
</a></li>

                

                

                <?php 
    do_action('ProjectTheme_my_account_main_menu');
    ?>

                

            </ul>

            

            </p>

			</li>

            

            <!-- ###### -->

			<?php 
    if (ProjectTheme_is_user_business($uid)) {
        ?>

            <li class="widget-container widget_text"><h3 class="widget-title"><?php 
        _e("Project Owner Menu", 'ProjectTheme');
        ?>
</h3>

			<p>

			<?php 
        global $wpdb;
        //				 $querystr = "
        //
        //					SELECT distinct wposts.ID
        //
        //					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta2, $wpdb->postmeta wpostmeta3
        //
        //					WHERE wposts.post_author='$uid' AND wposts.ID = wpostmeta2.post_id
        //
        //					AND wpostmeta2.meta_key='paid_user' AND wpostmeta2.meta_value='0'
        //
        //
        //
        //					AND wposts.ID = wpostmeta3.post_id AND
        //
        //					wpostmeta3.meta_key='delivered' AND wpostmeta3.meta_value='1'
        //
        //
        //
        //					 AND wposts.post_type = 'project' ";
        $querystr = "\n\n\t\t\t\t\tSELECT distinct p.ID \n                    \n                    FROM {$wpdb->posts} AS p\n                        \n                    LEFT JOIN " . $wpdb->prefix . "project_bids AS pb ON p.ID = pb.pid\n                        \n                    WHERE   p.post_author = '{$uid}'\n                        AND pb.winner = '1'\n                        AND pb.paid = '0'\n                        AND pb.delivered = '1'\n                        AND p.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj = count($pageposts);
        if ($ttl_prj > 0) {
            $scn = "<span class='notif_a'>" . $ttl_prj . "</span>";
        }
        //------------------------------------------------
        /*$querystr = "
        
        					SELECT distinct wposts.ID 
        
        					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta2
        
        					WHERE wposts.post_author='$uid' AND wposts.ID = wpostmeta2.post_id AND
        
        					wpostmeta2.meta_key='paid' AND wpostmeta2.meta_value='0' AND wposts.post_type = 'project' AND wposts.post_status = 'draft' ";*/
        $querystr = "\n\n\t\t\t\t\tSELECT distinct wposts.ID \n\n\t\t\t\t\tFROM {$wpdb->posts} wposts\n\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND  wposts.post_type = 'project' AND wposts.post_status = 'draft' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj2 = count($pageposts);
        if ($ttl_prj2 > 0) {
            $scn2 = "<span class='notif_a'>" . $ttl_prj2 . "</span>";
        }
        //------------------------------------------------
        $querystr = "\n\n\t\t\t\t\tSELECT distinct wposts.ID \n\n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2, {$wpdb->postmeta} wpostmeta3\n\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND wposts.ID = wpostmeta2.post_id AND wposts.ID = wpostmeta3.post_id AND\n\n\t\t\t\t\twpostmeta2.meta_key='outstanding' AND wpostmeta2.meta_value='1' AND wposts.post_type = 'project' AND wposts.post_status= 'publish' " . " AND wpostmeta3.meta_key='mark_coder_delivered' AND wpostmeta3.meta_value = '1'";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj2 = count($pageposts);
        if ($ttl_prj2 > 0) {
            $compl = "<span class='notif_a'>" . $ttl_prj2 . "</span>";
        }
        $querystr = "\n\n\t\t\t\t\tSELECT distinct wposts.ID \n\n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2\n\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND wposts.ID = wpostmeta2.post_id AND\n\n\t\t\t\t\twpostmeta2.meta_key='closed' AND wpostmeta2.meta_value='1' AND wposts.post_type = 'project' AND wposts.post_status = 'publish'";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj2 = count($pageposts);
        if ($ttl_prj2 > 0) {
            $closed_number = "<span class='notif_a'>" . $ttl_prj2 . "</span>";
        }
        $querystr = "\n\n\t\t\t\t\tSELECT distinct wposts.ID \n\n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2\n\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND wposts.ID = wpostmeta2.post_id AND\n\n\t\t\t\t\twpostmeta2.meta_key='closed' AND wpostmeta2.meta_value='0' AND wposts.post_type = 'project' AND wposts.post_status = 'publish'";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj2 = count($pageposts);
        if ($ttl_prj2 > 0) {
            $active_number = "<span class='notif_a'>" . $ttl_prj2 . "</span>";
        }
        //				$querystr = "
        //
        //					SELECT distinct wposts.ID
        //
        //					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta3, $wpdb->postmeta wpostmeta4
        //
        //					WHERE
        //
        //					wposts.ID = wpostmeta4.post_id AND
        //
        //					wpostmeta4.meta_key='paid_user' AND wpostmeta4.meta_value='1'
        //
        //					AND wposts.post_type = 'project' AND wposts.post_author='$uid'";
        $querystr = "\n                        SELECT pb.ID \n                        FROM {$wpdb->posts} AS p\n                        LEFT JOIN {$wpdb->prefix}project_bids AS pb ON p.ID = pb.pid\n                        WHERE   p.post_author = '{$uid}'\n                            AND pb.winner = '1'\n                            AND pb.paid = '1'\n                            AND p.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $paid = count($pageposts);
        if ($paid > 0) {
            $paid = "<span class='notif_a'>" . $paid . "</span>";
        } else {
            $paid = '';
        }
        ?>

            <ul id="my-account-admin-menu_seller">

            	 <li><a href="<?php 
        echo projectTheme_post_new_link();
        ?>
" ><?php 
        _e("Post New Project", 'ProjectTheme');
        ?>
</a></li>  

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_active_projects_id'));
        ?>
"><?php 
        printf(__("Active Projects %s", 'ProjectTheme'), $active_number);
        /*_e("Active Projects",'ProjectTheme');*/
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_closed_projects_id'));
        ?>
"><?php 
        printf(__("Closed Projects %s", 'ProjectTheme'), $closed_number);
        /*_e("Closed Projects",'ProjectTheme');*/
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_unpublished_projects_id'));
        ?>
"><?php 
        printf(__("Unpublished Projects %s", 'ProjectTheme'), $scn2);
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_awaiting_completion_id'));
        ?>
"><?php 
        printf(__("Awaiting Completion %s", 'ProjectTheme'), $compl);
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_outstanding_payments_id'));
        ?>
"><?php 
        printf(__("Outstanding Payments %s", 'ProjectTheme'), $scn);
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_completed_payments_id'));
        ?>
"><?php 
        printf(__("Completed Payments %s", 'ProjectTheme'), $paid);
        /*_e("Completed Payments",'ProjectTheme');*/
        ?>
</a></li>

                 

                 <?php 
        do_action('ProjectTheme_my_account_service_contractor_menu');
        ?>

                 

            </ul>

            

            </p>

			</li>

            

            <!-- ###### -->

			<?php 
    }
    if (ProjectTheme_is_user_provider($uid)) {
        ?>

            <li class="widget-container widget_text"><h3 class="widget-title"><?php 
        _e("QA Engineer Menu", 'ProjectTheme');
        ?>
</h3>

			<p>

			<?php 
        $querystr = "\n\n\t\t\t\t\tSELECT distinct wposts.ID \n\n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2\n\n\t\t\t\t\tWHERE wposts.ID = wpostmeta2.post_id AND\n\n\t\t\t\t\twpostmeta2.meta_key='winner' AND wpostmeta2.meta_value='{$uid}'\n\n\t\t\t\t\tAND wposts.post_type = 'project' AND wposts.post_status = 'publish' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $won = count($pageposts);
        if ($won > 0) {
            $won = "<span class='notif_a'>" . $won . "</span>";
        } else {
            $won = '';
        }
        $querystr = "\n\t\t\t\t\tSELECT p.ID\n                    FROM {$wpdb->posts} AS p\n                    LEFT JOIN {$wpdb->prefix}project_bids AS b ON p.ID = b.pid\n                    LEFT JOIN {$wpdb->prefix}postmeta AS wpostmeta2 ON p.ID = wpostmeta2.post_id\n                    LEFT JOIN {$wpdb->prefix}postmeta AS wpostmeta3 ON p.ID = wpostmeta3.post_id\n                    WHERE \n                    b.uid = '916' AND b.outstanding = '1'\n                    AND wpostmeta2.meta_key='winner' AND wpostmeta2.meta_value='916'\n                    AND wpostmeta3.meta_key='outstanding' AND wpostmeta3.meta_value='1' \n                    AND p.post_type = 'project' AND p.post_status = 'publish' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $outsnr = count($pageposts);
        if ($outsnr > 0) {
            $outsnr = "<span class='notif_a'>" . $outsnr . "</span>";
        } else {
            $outsnr = '';
        }
        //---------------------------------------
        //					$querystr = "
        //
        //					SELECT distinct wposts.ID
        //
        //					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta2, $wpdb->postmeta wpostmeta3, $wpdb->postmeta wpostmeta4
        //
        //					WHERE wposts.ID = wpostmeta2.post_id AND
        //
        //					wpostmeta2.meta_key='winner' AND wpostmeta2.meta_value='$uid' AND
        //
        //
        //
        //
        //
        //					wposts.ID = wpostmeta3.post_id AND
        //
        //					wpostmeta3.meta_key='delivered' AND wpostmeta3.meta_value='1' AND
        //
        //
        //
        //					wposts.ID = wpostmeta4.post_id AND
        //
        //					wpostmeta4.meta_key='paid_user' AND wpostmeta4.meta_value='0'
        //
        //
        //
        //					AND wposts.post_type = 'project' ";
        $querystr = "\n                        SELECT distinct p.ID \n                        FROM {$wpdb->posts} AS p\n                        LEFT JOIN {$wpdb->prefix}project_bids AS pb ON p.ID = pb.pid\n                        WHERE   pb.uid = '{$uid}'\n                            AND pb.winner = '1'\n                            AND pb.paid = '0'\n                            AND pb.delivered = '1'\n                            AND p.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $awnr = count($pageposts);
        if ($awnr > 0) {
            $awnr = "<span class='notif_a'>" . $awnr . "</span>";
        } else {
            $awnr = '';
        }
        //				$querystr = "
        //
        //					SELECT distinct wposts.ID
        //
        //					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta2, $wpdb->postmeta wpostmeta3, $wpdb->postmeta wpostmeta4
        //
        //					WHERE wposts.ID = wpostmeta2.post_id AND
        //
        //					wpostmeta2.meta_key='winner' AND wpostmeta2.meta_value='$uid' AND
        //
        //
        //					wposts.ID = wpostmeta3.post_id AND
        //
        //					wpostmeta3.meta_key='delivered' AND wpostmeta3.meta_value='1' AND
        //
        //
        //					wposts.ID = wpostmeta4.post_id AND
        //
        //					wpostmeta4.meta_key='paid_user' AND wpostmeta4.meta_value='1'
        //
        //					AND wposts.post_type = 'project' ";
        $querystr = "\n                        SELECT distinct p.ID \n                        FROM {$wpdb->posts} AS p\n                        LEFT JOIN {$wpdb->prefix}project_bids AS pb ON p.ID = pb.pid\n                        WHERE   pb.uid = '{$uid}'\n                            AND pb.winner = '1'\n                            AND pb.paid = '1'\n                            AND pb.delivered = '1'\n                            AND p.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $deliv = count($pageposts);
        if ($deliv > 0) {
            $deliv = "<span class='notif_a'>" . $deliv . "</span>";
        } else {
            $deliv = '';
        }
        $s = "select * from " . $wpdb->prefix . "project_bids where uid='{$uid}'";
        $r = $wpdb->get_results($s);
        $pids = array();
        foreach ($r as $k => $rr) {
            $pids[] = $rr->pid;
        }
        $pids = implode(',', $pids);
        $querystr = "\n\n\t\t\t\t\tSELECT distinct wposts.ID \n\n\t\t\t\t\tFROM {$wpdb->posts} wposts\n\n\t\t\t\t\tWHERE wposts.ID IN ({$pids})\n\n\t\t\t\t\t\n\n\t\t\t\t\tAND wposts.post_type = 'project' AND wposts.post_status = 'publish'";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $prop = count($pageposts);
        if ($prop > 0) {
            $prop = "<span class='notif_a'>" . $prop . "</span>";
        } else {
            $prop = '';
        }
        ?>

            <ul id="my-account-admin-menu_buyer">

                   

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_won_projects_id'));
        ?>
"><?php 
        printf(__("Projects I’ve Won %s", 'ProjectTheme'), $won);
        /*_e("Projects I’ve Won",'ProjectTheme');*/
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_outstanding_projects_id'));
        ?>
"><?php 
        printf(__("Projects in progress %s", 'ProjectTheme'), $outsnr);
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_awaiting_payments_id'));
        ?>
"><?php 
        printf(__("Awaiting Payments %s", 'ProjectTheme'), $awnr);
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_delivered_projects_id'));
        ?>
"><?php 
        printf(__("Delivered & Paid Projects %s", 'ProjectTheme'), $deliv);
        /*_e("Delivered & Paid Projects",'ProjectTheme');*/
        ?>
</a></li>

                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_bid_projects_id'));
        ?>
"><?php 
        printf(__("My Proposals %s", 'ProjectTheme'), $prop);
        /*_e("My Proposals",'ProjectTheme');*/
        ?>
</a></li>

                 

                 <?php 
        do_action('ProjectTheme_my_account_service_provider_menu');
        ?>

                 

            </ul>

             

            </p>

			</li>

            <?php 
    }
    ?>

            

			</ul>

		</div>

		<?php 
}
Пример #2
0
function ProjectTheme_get_users_links()
{
    global $current_user, $wpdb;
    get_currentuserinfo();
    $rd = projectTheme_get_unread_number_messages($current_user->ID);
    if ($rd > 0) {
        $ssk = "<span class='notif_a'>" . $rd . "</span>";
    } else {
        $ssk = '';
    }
    $uid = $current_user->ID;
    //-----------------------
    $query = "select id from " . $wpdb->prefix . "project_ratings where fromuser='******' AND awarded='0'";
    $r = $wpdb->get_results($query);
    $ttl_fdbks = count($r);
    if ($ttl_fdbks > 0) {
        $ttl_fdbks2 = "<span class='notif_a'>" . $ttl_fdbks . "</span>";
    }
    $ProjectTheme_enable_2_user_tp = get_option('ProjectTheme_enable_2_user_tp');
    $user_tp = get_user_meta($uid, 'user_tp', true);
    ?>
    
	<div id="right-sidebar" class="account-sidebar">
			<ul class="xoxo">
			
			<li class="widget-container widget_text"> 
			<p>
			
            <ul id="my-account-admin-menu">
            	<li><a href="<?php 
    echo projectTheme_my_account_link();
    ?>
" <?php 
    echo $current_page == "home" ? "class='active'" : "";
    ?>
><?php 
    _e("MyAccount Home", 'ProjectTheme');
    ?>
</a></li>
                
                <?php 
    $pmnts_lnk = get_permalink(get_option('ProjectTheme_my_account_payments_id'));
    $pmnts_lnk = apply_filters('ProjectTheme_my_account_payments_id_link', $pmnts_lnk);
    $ProjectTheme_enable_credits_wallet = get_option('ProjectTheme_enable_credits_wallet');
    if ($ProjectTheme_enable_credits_wallet != 'no') {
        ?>
             
                <li><a href="<?php 
        echo $pmnts_lnk;
        ?>
"><?php 
        _e("Finances", 'ProjectTheme');
        ?>
</a></li>    
                <?php 
    }
    ?>
                            
                <li><a href="<?php 
    echo get_permalink(get_option('ProjectTheme_my_account_private_messages_id'));
    ?>
"><?php 
    echo sprintf(__("Private Messages %s", 'ProjectTheme'), $ssk);
    ?>
</a></li>
               	<li><a href="<?php 
    echo get_permalink(get_option('ProjectTheme_my_account_personal_info_id'));
    ?>
"><?php 
    _e("Personal Info", 'ProjectTheme');
    ?>
</a></li>
                <li><a href="<?php 
    echo get_permalink(get_option('ProjectTheme_my_account_feedback_id'));
    ?>
"><?php 
    printf(__("Reviews/Feedback %s", 'ProjectTheme'), $ttl_fdbks2);
    ?>
</a></li>
                
                
                <?php 
    do_action('ProjectTheme_my_account_main_menu');
    ?>
                
            </ul>
            
            </p>
			</li>
            
            <!-- ###### -->
			<?php 
    if (ProjectTheme_is_user_business($uid)) {
        ?>
            <li class="widget-container widget_text"><h3 class="widget-title"><?php 
        _e("Service Contractor Menu", 'ProjectTheme');
        ?>
</h3>
			<p>
			<?php 
        global $wpdb;
        $querystr = "\n\t\t\t\t\tSELECT distinct wposts.ID \n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2, {$wpdb->postmeta} wpostmeta3\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND wposts.ID = wpostmeta2.post_id AND\n\t\t\t\t\twpostmeta2.meta_key='paid_user' AND wpostmeta2.meta_value='0'\n\t\t\t\t\t\n\t\t\t\t\tAND wposts.ID = wpostmeta3.post_id AND\n\t\t\t\t\twpostmeta3.meta_key='delivered' AND wpostmeta3.meta_value='1'\n\t\t\t\t\t\n\t\t\t\t\t AND wposts.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj = count($pageposts);
        if ($ttl_prj > 0) {
            $scn = "<span class='notif_a'>" . $ttl_prj . "</span>";
        }
        //------------------------------------------------
        $querystr = "\n\t\t\t\t\tSELECT distinct wposts.ID \n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND wposts.ID = wpostmeta2.post_id AND\n\t\t\t\t\twpostmeta2.meta_key='paid' AND wpostmeta2.meta_value='0' AND wposts.post_type = 'project' AND wposts.post_status = 'draft' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj2 = count($pageposts);
        if ($ttl_prj2 > 0) {
            $scn2 = "<span class='notif_a'>" . $ttl_prj2 . "</span>";
        }
        //------------------------------------------------
        $querystr = "\n\t\t\t\t\tSELECT distinct wposts.ID \n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2\n\t\t\t\t\tWHERE wposts.post_author='{$uid}' AND wposts.ID = wpostmeta2.post_id AND\n\t\t\t\t\twpostmeta2.meta_key='outstanding' AND wpostmeta2.meta_value='1' AND wposts.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $ttl_prj2 = count($pageposts);
        if ($ttl_prj2 > 0) {
            $compl = "<span class='notif_a'>" . $ttl_prj2 . "</span>";
        }
        ?>
            <ul id="my-account-admin-menu_seller">
            	 <li><a href="<?php 
        echo projectTheme_post_new_link();
        ?>
" ><?php 
        _e("Post New Project", 'ProjectTheme');
        ?>
</a></li>  
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_active_projects_id'));
        ?>
"><?php 
        _e("Active Projects", 'ProjectTheme');
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_closed_projects_id'));
        ?>
"><?php 
        _e("Closed Projects", 'ProjectTheme');
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_unpublished_projects_id'));
        ?>
"><?php 
        printf(__("Unpublished Projects %s", 'ProjectTheme'), $scn2);
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_awaiting_completion_id'));
        ?>
"><?php 
        printf(__("Awaiting Completion %s", 'ProjectTheme'), $compl);
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_outstanding_payments_id'));
        ?>
"><?php 
        printf(__("Outstanding Payments %s", 'ProjectTheme'), $scn);
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_completed_payments_id'));
        ?>
"><?php 
        _e("Completed Payments", 'ProjectTheme');
        ?>
</a></li>
                 
                 <?php 
        do_action('ProjectTheme_my_account_service_contractor_menu');
        ?>
                 
            </ul>
            
            </p>
			</li>
            
            <!-- ###### -->
			<?php 
    }
    if (ProjectTheme_is_user_provider($uid)) {
        ?>
            <li class="widget-container widget_text"><h3 class="widget-title"><?php 
        _e("Freelancer Menu", 'ProjectTheme');
        ?>
</h3>
			<p>
			<?php 
        $querystr = "\n\t\t\t\t\tSELECT distinct wposts.ID \n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2, {$wpdb->postmeta} wpostmeta3\n\t\t\t\t\tWHERE wposts.ID = wpostmeta2.post_id AND\n\t\t\t\t\twpostmeta2.meta_key='winner' AND wpostmeta2.meta_value='{$uid}' AND\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\twposts.ID = wpostmeta3.post_id AND\n\t\t\t\t\twpostmeta3.meta_key='outstanding' AND wpostmeta3.meta_value='1' \n\t\t\t\t\t\n\t\t\t\t\tAND wposts.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $outsnr = count($pageposts);
        if ($outsnr > 0) {
            $outsnr = "<span class='notif_a'>" . $outsnr . "</span>";
        } else {
            $outsnr = '';
        }
        //---------------------------------------
        $querystr = "\n\t\t\t\t\tSELECT distinct wposts.ID \n\t\t\t\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta2, {$wpdb->postmeta} wpostmeta3, {$wpdb->postmeta} wpostmeta4\n\t\t\t\t\tWHERE wposts.ID = wpostmeta2.post_id AND\n\t\t\t\t\twpostmeta2.meta_key='winner' AND wpostmeta2.meta_value='{$uid}' AND\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\twposts.ID = wpostmeta3.post_id AND\n\t\t\t\t\twpostmeta3.meta_key='delivered' AND wpostmeta3.meta_value='1' AND\n\t\t\t\t\t\n\t\t\t\t\twposts.ID = wpostmeta4.post_id AND\n\t\t\t\t\twpostmeta4.meta_key='paid_user' AND wpostmeta4.meta_value='0' \n\t\t\t\t\t\n\t\t\t\t\tAND wposts.post_type = 'project' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $awnr = count($pageposts);
        if ($awnr > 0) {
            $awnr = "<span class='notif_a'>" . $awnr . "</span>";
        } else {
            $awnr = '';
        }
        ?>
            <ul id="my-account-admin-menu_buyer">
                   
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_won_projects_id'));
        ?>
"><?php 
        _e("Won Projects", 'ProjectTheme');
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_outstanding_projects_id'));
        ?>
"><?php 
        printf(__("Outstanding Projects %s", 'ProjectTheme'), $outsnr);
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_awaiting_payments_id'));
        ?>
"><?php 
        printf(__("Awaiting Payments %s", 'ProjectTheme'), $awnr);
        ?>
</a></li>
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_delivered_projects_id'));
        ?>
"><?php 
        _e("Delivered & Paid Projects", 'ProjectTheme');
        ?>
</a></li>
                 
                 
                 <li><a href="<?php 
        echo get_permalink(get_option('ProjectTheme_my_account_bid_projects_id'));
        ?>
"><?php 
        _e("My Proposals", 'ProjectTheme');
        ?>
</a></li>
                 
                 <?php 
        do_action('ProjectTheme_my_account_service_provider_menu');
        ?>
                 
            </ul>
             
            </p>
			</li>
            <?php 
    }
    ?>
            
			</ul>
		</div>
		<?php 
}
Пример #3
0
function ProjectTheme_my_account_private_messages_area_function()
{
    global $current_user, $wpdb, $wp_query;
    get_currentuserinfo();
    $uid = $current_user->ID;
    $myuid = $uid;
    ?>
    	 
       <?php 
    global $wpdb, $wp_rewrite, $wp_query;
    $third_page = $wp_query->query_vars['pg'];
    if (empty($third_page)) {
        $third_page = 'home';
    }
    ?>
        <div class="clear10"></div>
      <div id="content" class="account-main-area mess_break">
        
        <div class="my_box3"><div class="padd10">
          <div class="clear10"></div>
          
            
                <ul class="cms_cms"> 
                <li><a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url();
    ?>
" class="green_btn"><?php 
    _e("Messaging Home", "ProjectTheme");
    ?>
</a></li>
               <li> <a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url('send');
    ?>
" class="green_btn"><?php 
    _e("Send New Message", "ProjectTheme");
    ?>
</a></li>
                <li><a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url('inbox');
    ?>
" class="green_btn"><?php 
    _e("Inbox", "ProjectTheme");
    global $current_user;
    get_currentuserinfo();
    $rd = projectTheme_get_unread_number_messages($current_user->ID);
    if ($rd > 0) {
        echo ' (' . $rd . ')';
    }
    ?>
</a></li>
                <li><a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url('sent-items');
    ?>
" class="green_btn"><?php 
    _e("Sent Items", "ProjectTheme");
    ?>
</a></li>
             	
                </ul>
                
        </div></div>
        <div class="clear10"></div>
        <?php 
    if ($third_page == 'home') {
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        ?>
        
        
		<!-- page content here -->	
			
            
            	
            	<div class="my_box3">
            	
            	<div class="box_title"><?php 
        _e("Latest Received Messages", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $uidsss = $current_user->ID;
        $s = "select * from " . $wpdb->prefix . "project_pm where user='******'  AND show_to_destination='1' and approved='1'  order by id desc limit 4";
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            echo '<table width="100%" class="privatemesg">';
            echo '<tr>';
            echo '<td>' . __('From User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                if ($row->rd == 0) {
                    $cls = 'bold_stuff';
                } else {
                    $cls = '';
                }
                $user = get_userdata($row->initiator);
                echo '<tr>';
                echo '<td class="' . $cls . '"><a href="' . get_bloginfo('siteurl') . '/?p_action=user_profile&post_author=' . $user->ID . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . substr($row->subject, 0, 30) . '</td>';
                //echo '<td class="'.$cls.'">'.date_i18n('d-M-Y H:i:s',$row->datemade).'</td>';
                echo '<td class="' . $cls . ' conv_time">' . $row->datemade . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
            
                </div>
                </div>
            
            <!--#######-->
            
            <div class="clear10"></div>
            
            	<div class="my_box3">
            	
            
            	<div class="box_title"><?php 
        _e("Latest Sent Items", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $uidss = $current_user->ID;
        $s = "select * from " . $wpdb->prefix . "project_pm where initiator='{$uidss}'  AND show_to_source='1' order by id desc limit 4";
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            echo '<table width="100%" class="privatemesg">';
            echo '<tr>';
            echo '<td>' . __('To User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                //if($row->rd == 0) $cls = 'bold_stuff';
                //else
                $cls = '';
                $user = get_userdata($row->user);
                echo '<tr>';
                echo '<td class="' . $cls . '"><a href="' . ProjectTheme_get_user_profile_link($row->user) . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . substr($row->subject, 0, 30) . '</td>';
                //echo '<td class="'.$cls.'">'.date_i18n('d-M-Y H:i:s',$row->datemade).'</td>';
                echo '<td class="' . $cls . ' conv_time">' . $row->datemade . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a id="privatedel"  href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
                 
               
                </div>
                </div>
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'inbox') {
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        //echo $myuid;
        ?>
        
        
		<!-- page content here -->	
			
            
            	<div class="my_box3">
           
            
            	<div class="box_title"><?php 
        _e("Private Messages: Inbox", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $page_rows = 20;
        $page_rows = apply_filters('ProjectTheme_nr_of_messages_priv_pagination', $page_rows);
        $pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
        $max = ' limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
        $s = "select count(id) tots from " . $wpdb->prefix . "project_pm where user='******' AND show_to_destination='1' and approved='1'";
        $r = $wpdb->get_results($s);
        $total = $r[0]->tots;
        $last = ceil($total / $page_rows);
        //-------------------------
        $s = "select * from " . $wpdb->prefix . "project_pm where user='******' AND show_to_destination='1' and approved='1' order by id desc " . $max;
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            ?>
                    
                    <script>
					
					$(document).ready(function() {
						//set initial state.

					 $('#privatedel').click(function(){ 
              
              var ss=$(this).parent().text();
             alert(ss);
             
           });
					
						$('#select_all_stuff').change(function() {
							if($(this).is(":checked")) {
								
								$('.message_select_bx').attr("checked", true);
							}
							else
							{
								$('.message_select_bx').attr("checked", false);	
							}
						});
					});
											
					
					</script>
                    
                    <?php 
            echo '<form method="post" action="' . ProjectTheme_get_priv_mess_page_url('delete-message', '', '&return=inbox') . '">';
            echo '<table width="100%">';
            echo '<tr>';
            echo '<td><input type="checkbox" name="" id="select_all_stuff" value="1" /> ' . __('Select All', 'ProjectTheme') . ' </td>';
            echo '<td>' . __('From User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                if ($row->rd == 0) {
                    $cls = 'bold_stuff';
                } else {
                    $cls = '';
                }
                $user = get_userdata($row->initiator);
                echo '<tr>';
                echo '<td><input type="checkbox" class="message_select_bx" name="message_ids[]" value="' . $row->id . '" /></td>';
                echo '<td class="' . $cls . '"><a href="' . get_bloginfo('siteurl') . '/?p_action=user_profile&post_author=' . $user->ID . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . substr($row->subject, 0, 30) . '</td>';
                //echo '<td class="'.$cls.'">'.date_i18n('d-M-Y H:i:s',$row->datemade).'</td>';
                echo '<td class="' . $cls . ' conv_time">' . $row->datemade . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '<tr><td colspan="5"><input type="submit" value="' . __('Delete Selected', 'ProjectTheme') . '" name="delete_sel" /></td></tr>';
            echo '<tr><td colspan="5">  ';
            echo ProjectTheme_get_my_pagination_main(get_bloginfo('siteurl') . "/?page_id=" . get_option('ProjectTheme_my_account_private_messages_id'), $pagenum, 'pagenum', $last, '&pg=inbox');
            echo ' </td></tr>';
            echo '</table></form>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
             
                </div>
                </div>
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'sent-items') {
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        ?>
        
        		<script>
					
					$(document).ready(function() {
						//set initial state.
					 
					
						$('#select_all_stuff').change(function() {
							if($(this).is(":checked")) {
								
								$('.message_select_bx').attr("checked", true);
							}
							else
							{
								$('.message_select_bx').attr("checked", false);	
							}
						});
					});
											
					
					</script>
		<!-- page content here -->	
			
            
            	<div class="my_box3">
            
            
            	<div class="box_title"><?php 
        _e("Private Messages: Sent Items", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $page_rows = 20;
        $page_rows = apply_filters('ProjectTheme_nr_of_messages_priv_pagination', $page_rows);
        $pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
        $max = ' limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
        //---------------------------------
        $s = "select count(id) tots from " . $wpdb->prefix . "project_pm where initiator='{$myuid}' AND show_to_source='1' and approved='1'";
        $r = $wpdb->get_results($s);
        $total = $r[0]->tots;
        $last = ceil($total / $page_rows);
        //---------------------------------
        $s = "select * from " . $wpdb->prefix . "project_pm where initiator='{$myuid}' AND show_to_source='1' and approved='1' order by id desc " . $max;
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            echo '<form method="post" action="' . ProjectTheme_get_priv_mess_page_url('delete-message', '', '&return=outbox') . '">';
            echo '<table width="100%">';
            echo '<tr>';
            echo '<td><input type="checkbox" name="" id="select_all_stuff" value="1" /> ' . __('Select All', 'ProjectTheme') . ' </td>';
            echo '<td>' . __('To User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                //if($row->rd == 0) $cls = 'bold_stuff';
                //else
                $cls = '';
                $user = get_userdata($row->user);
                echo '<tr>';
                echo '<td><input type="checkbox" class="message_select_bx" name="message_ids[]" value="' . $row->id . '" /></td>';
                echo '<td class="' . $cls . '"><a href="' . ProjectTheme_get_user_profile_link($row->user) . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . substr($row->subject, 0, 30) . '</td>';
                //echo '<td class="'.$cls.'">'.date_i18n('d-M-Y H:i:s',$row->datemade).'</td>';
                echo '<td class="' . $cls . ' conv_time">' . $row->datemade . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '<tr><td colspan="5"><input type="submit" value="' . __('Delete Selected', 'ProjectTheme') . '" name="delete_sel" /></td></tr>';
            echo '<tr><td colspan="5">  ';
            echo ProjectTheme_get_my_pagination_main(get_bloginfo('siteurl') . "/?page_id=" . get_option('ProjectTheme_my_account_private_messages_id'), $pagenum, 'pagenum', $last, '&pg=sent-items');
            echo ' </td></tr>';
            echo '</table></form>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
                </div>
                </div>
        
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'delete-message') {
        $id = $_GET['id'];
        $s = "select * from " . $wpdb->prefix . "project_pm where id='{$id}' AND (user='******' OR initiator='{$myuid}')";
        $r = $wpdb->get_results($s);
        $row = $r[0];
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        if ($myuid == $row->initiator) {
            $owner = true;
        } else {
            $owner = false;
        }
        //if(!$owner)
        //$wpdb->query("update_i18n ".$wpdb->prefix."auction_pm set rd='1' where id='{$row->id}'");
        ?>
        
        
		<!-- page content here -->	
			
            
            	<div class="my_box3">
            	<div class="padd10">
            
            	<div class="box_title"><?php 
        if (isset($_POST['delete_sel'])) {
            _e("Delete Selected Message: ", "ProjectTheme");
        } else {
            _e("Delete Message: ", "ProjectTheme");
            echo " " . substr($row->subject, 0, 30);
        }
        ?>
</div>
                <div class="box_content">  
                
                <?php 
        if (isset($_POST['message_ids'])) {
            $message_ids2 = $_POST['message_ids'];
            foreach ($message_ids2 as $message_id) {
                $ss1 = "select * from " . $wpdb->prefix . "project_pm where id='{$message_id}'";
                $rr1 = $wpdb->get_results($ss1);
                $rrow1 = $rr1[0];
                $user = get_userdata($rrow1->initiator);
                //							echo '#'.$rrow1->id." ".substr($rrow1->subject,0,30).'<br/>';
                echo 'Message from <b>' . $user->user_login . '</b>. Subject: ' . substr($rrow1->subject, 0, 30) . '<br/>';
            }
            echo '<br/>';
        }
        ?>
                
                <?php 
        //echo $row->content;
        ?>
      <br/> <br/>
      
      <?php 
        if (1) {
            //$owner == false):
            if (isset($_POST['delete_sel'])) {
                $message_ids = $_POST['message_ids'];
                if (count($message_ids) == 0) {
                    _e("No messsages selected.", "ProjectTheme");
                } else {
                    $attash = '';
                    foreach ($message_ids as $message_id) {
                        $attash .= '&message_id[]=' . $message_id;
                    }
                    ?>
					
                   <a href="javascript:history.go(-1)<?php 
                    //echo ($_GET['rdr']);
                    ?>
" class="nice_link"><?php 
                    _e("Cancel", 'ProjectTheme');
                    ?>
</a>
                    
                    <a href="<?php 
                    echo ProjectTheme_get_priv_mess_page_url('delete-message', '', '&confirm_message_deletion=yes&return=' . urlencode($_GET['rdr'])) . $attash;
                    ?>
" 
       				class="nice_link"  onclick="return privatedel()"><?php 
                    _e("Confirm Deletion", 'ProjectTheme');
                    ?>
</a>
                  
                <?php 
                }
            } else {
                ?>
      
      <a href="javascript:history.go(-1)<?php 
                //echo ($_GET['rdr']);
                ?>
" class="nice_link"><?php 
                _e("Cancel", 'ProjectTheme');
                ?>
</a>
      
       <a href="<?php 
                echo ProjectTheme_get_priv_mess_page_url('delete-message', $row->id, '&confirm_message_deletion=yes&return=' . urlencode($_GET['rdr']));
                ?>
" 
       class="nice_link"  onclick="return privatedel()"><?php 
                _e("Confirm Deletion", 'ProjectTheme');
                ?>
</a> <?php 
            }
        }
        ?>
                </div>
                </div>
                </div>
            
           <script type="text/javascript">
				   
					function privatedel()
					{
						var ms='Want To Delete <?php 
        echo $row->subject;
        ?>
';
						//alert(ms);
						if(confirm(ms))
						{return true;}
					else {return false;}
					}
					</script> 
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'read-message') {
        global $current_user, $wpdb;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        $id = $_GET['id'];
        $s = "select * from " . $wpdb->prefix . "project_pm where id='{$id}'  AND (user='******' OR initiator='{$myuid}')";
        $r = $wpdb->get_results($s);
        $row = $r[0];
        if ($myuid == $row->initiator) {
            $owner = true;
        } else {
            $owner = false;
        }
        // mark messags is read if user = myuid
        if ($myuid == $row->user) {
            $wpdb->query("update " . $wpdb->prefix . "project_pm set rd='1' where id='{$row->id}'");
        }
        ?>
        
        
		<!-- page content here -->	
			
            
            	<div class="my_box3">
           
            
            	<div class="box_title"><?php 
        _e("Read Message: ", "ProjectTheme");
        echo " " . $row->subject;
        ?>
</div>
                <div class="box_content">  
                <?php 
        echo $row->content;
        ?>
      <br/> <br/>
      
      <?php 
        if (!empty($row->file_attached)) {
            echo sprintf(__('File Attached: %s', 'ProjectTheme'), '<a href="' . wp_get_attachment_url($row->file_attached) . '">' . wp_get_attachment_url($row->file_attached) . "</a>");
        }
        ?>
      
      
      <?php 
        if ($owner == false) {
            ?>
       <br><a href="<?php 
            echo ProjectTheme_get_priv_mess_page_url('send', '', '&pid=' . $row->pid . '&uid=' . $row->initiator . '&in_reply_to=' . $row->id);
            ?>
" class="nice_link"><?php 
            _e("Reply", 'ProjectTheme');
            ?>
</a> <?php 
        }
        ?>
                </div>
                </div>
             
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'send') {
        ?>
        <?php 
        $pid = $_GET['pid'];
        $uid = $_GET['uid'];
        $user = get_userdata($uid);
        if (!empty($pid)) {
            $post = get_post($pid);
            $subject = "RE: " . $post->post_title;
        } elseif (!empty($_GET['in_reply_to'])) {
            global $wpdb;
            $ssp = "select * from " . $wpdb->prefix . "project_pm where id='" . $_GET['in_reply_to'] . "'";
            $sspq = $wpdb->get_results($ssp);
            if (strpos($sspq[0]->subject, 'RE:') !== false) {
                $subject = $sspq[0]->subject;
            } else {
                $subject = "RE: " . substr($sspq[0]->subject, 0, 30);
            }
            //$sspq[0]->subject;
        }
        if (isset($_POST['send_a'])) {
            require_once ABSPATH . "wp-admin" . '/includes/file.php';
            require_once ABSPATH . "wp-admin" . '/includes/image.php';
            if (!empty($_FILES['file_instant']['name'])) {
                $pids = 0;
                $upload_overrides = array('test_form' => true);
                $uploaded_file = wp_handle_upload($_FILES['file_instant'], $upload_overrides);
                $file_name_and_location = $uploaded_file['file'];
                $file_title_for_media_library = $_FILES['file_instant']['name'];
                $arr_file_type = wp_check_filetype(basename($_FILES['file_instant']['name']));
                $uploaded_file_type = $arr_file_type['type'];
                if ($uploaded_file_type == "application/zip" or $uploaded_file_type == "application/pdf" or $uploaded_file_type == "application/msword" or $uploaded_file_type == "application/msexcel" or $uploaded_file_type == "application/doc" or $uploaded_file_type == "application/docx" or $uploaded_file_type == "application/xls" or $uploaded_file_type == "application/xlsx" or $uploaded_file_type == "application/csv" or $uploaded_file_type == "application/ppt" or $uploaded_file_type == "application/pptx" or $uploaded_file_type == "application/vnd.ms-excel" or $uploaded_file_type == "application/txt" or $uploaded_file_type == "text/plain" or $uploaded_file_type == "application/vnd.ms-powerpoint" or $uploaded_file_type == "application/vnd.openxmlformats-officedocument.presentationml.presentation" or $uploaded_file_type == "application/octet-stream" or $uploaded_file_type == "image/png" or $uploaded_file_type == "image/jpg" or $uploaded_file_type == "image/jpeg" or $uploaded_file_type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" or $uploaded_file_type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
                    $attachment = array('post_mime_type' => $uploaded_file_type, 'post_title' => 'Uploaded ZIP ' . addslashes($file_title_for_media_library), 'post_content' => '', 'post_status' => 'inherit', 'post_parent' => 0, 'post_author' => $uid);
                    $attach_id = wp_insert_attachment($attachment, $file_name_and_location, $pids);
                    $attach_data = wp_generate_attachment_metadata($attach_id, $file_name_and_location);
                    wp_update_attachment_metadata($attach_id, $attach_data);
                } else {
                    $error_mm = '1';
                }
            }
            $subject = $_POST['subject_a'];
            $message = $_POST['message_a'];
            $uids = $_POST['to_as'];
            if (empty($uids)) {
                $uids = $_GET['uid'];
            }
            if (!empty($_POST['send-to-all']) && $_POST['send-to-all'] == 'on') {
                global $current_user;
                get_currentuserinfo();
                $users = get_users();
                foreach ($users as $one) {
                    $uids = $one->ID;
                    ProjectTheme_send_priv_mess_to_person($uids, $uid, $error_mm, $subject, $message, $pid, $attach_id, $user, $post, $cant_send, true);
                }
                ?>
                
                <div class="my_box3">
            	<div class="padd10">
                 <?php 
                echo sprintf(__('Your message has been sent to all users.', 'ProjectTheme'));
                ?>
                </div>
                </div>
                
                <?php 
            } elseif (!empty($_POST['to_as']) || !empty($_POST['projectss'])) {
                global $current_user;
                get_currentuserinfo();
                if (is_array($_POST['to_as']) || is_array($_POST['projectss'])) {
                    for ($index = 0; $index < count($_POST['projectss']); $index++) {
                        if ($_POST['projectss'][$index] !== "") {
                            $to_as = get_user_by('id', $_POST['projectss'][$index]);
                        } else {
                            $to_as = get_user_by('email', $_POST['to_as'][$index]);
                        }
                        $uids = projectTheme_get_userid_from_username($to_as->user_login);
                        ProjectTheme_send_priv_mess_to_person($uids, $uid, $error_mm, $subject, $message, $pid, $attach_id, $user, $post, $cant_send);
                    }
                } else {
                    // it isn't array
                    if ($_POST['projectss'] !== '') {
                        $to_as = get_user_by('id', $_POST['projectss']);
                    } else {
                        $to_as = get_user_by('email', $_POST['to_as']);
                    }
                    $uids = projectTheme_get_userid_from_username($to_as->user_login);
                    ProjectTheme_send_priv_mess_to_person($uids, $uid, $error_mm, $subject, $message, $pid, $attach_id, $user, $post, $cant_send);
                    //if($uids == $current_user->ID) { $uids = false; $error_mm = 1; $cant_send = 1; }
                }
            }
        } else {
            ?>
   
         <script>
		 function getdataoftextarea()
		 {
		 	 alert($(".message_content").val());
		 }
		 function validate_form()
			 {
				 
		var to = document.form5.to_as.value;
        if (to == null || to == "")
		{
        alert("Please enter email id");
		document.form5.to_as.focus();
		
        return false;
				
       }
	   var to = document.form5.to_as.value;
	   var email= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	   var em= email.test(to);
	   if(em==false)
		{
		alert("please enter valide email id");
		document.form5.to_as.focus();
		return false;
		}
       
				 
		var subj = document.form5.subject_a.value;
        if (subj == null || subj == "")
		{
        alert("Please fill the subject field");
		document.form5.subject_a.focus();
		
        return false;
				
       }
	 // var x1 = tinymce.get('jander').getContent();
	 // alert(x1);
	var x = tinymce.get('message_a').getContent();
    if (x == null || x == "")
		{
		alert("MESSAGE FIELD CANNOT BE BLANK");
		document.form5.message_a.focus();
		
        return false;
				
       }
	    
	   
}
		 </script>    
        <div class="my_box3">
            	
            
            	<div class="box_title"><?php 
            _e("Send Private Message to: ", "ProjectTheme");
            ?>
 <?php 
            echo $user->user_login;
            ?>
</div>
                <div class="box_content">  
                <form method="post" enctype="multipart/form-data" name="form5" id="form5" onsubmit="return validate_form();">
                <input type="hidden" name="tm" value="<?php 
            echo current_time('timestamp', 0);
            ?>
" />
                <table>
                <?php 
            if (empty($uid)) {
                $rtt = ProjectTheme_get_my_awarded_projects2($current_user->ID, true);
                ?>
                    <?php 
                if (current_user_can('manage_options')) {
                    ?>
                        
                    <tr>
                        <td width="140" class="no_wrap"><?php 
                    _e("Send To All", "ProjectTheme");
                    ?>
&nbsp;:</td>
                        <td>
                            <input type="checkbox" id="send-to-all" name="send-to-all" />
                            <span>Send message to ALL users on site</span>
                        </td>
                    </tr>
                    
                    <script>
                        jQuery(document).ready(function(){
                            
                            jQuery('#send-to-all').on('change', function(){
                                
                                var inputs = jQuery('.send-to-raw').children('td').children('input,select');

                                if ($(this).attr('checked')) {
                                    inputs.attr('disabled', true);
                                } else {
                                    inputs.removeAttr('disabled');
                                }
                            });
                        
                        });
                    </script>
                    
                    <?php 
                }
                ?>
                <tr class="send-to-raw">
                    <td width="140" class="no_wrap"><?php 
                _e("Send To (e-mail)", "ProjectTheme");
                ?>
<font style="color:red;">*</font>&nbsp;:</td>
                    <td width="200"><input size="20" name="to_as[]" class="to_as" type="text" value="" /> <?php 
                if ($rtt) {
                    _e('or', 'ProjectTheme');
                    echo " " . $rtt;
                }
                ?>
</td>
                    <td><input type="button" class="add_email" value="+" onclick="add_raw()"/></td>
                </tr>
                <?php 
            }
            ?>
                
                <tr>
                <td width="140" class="no_wrap"><?php 
            _e("Subject", "ProjectTheme");
            ?>
<font style="color:red;">*</font>&nbsp;:</td>
                <td><input size="50" name="subject_a" id="subject_a" type="text" value="<?php 
            echo $subject;
            ?>
" /></td>
                </tr>
                
                 <script>
                     
                     function add_raw(){
                         var html = jQuery('.send-to-raw:first').html();
                         var btn_remove = '<td><input type="button" class="remove_email" value="X" onclick="remove_raw(this)"/></td>'
                         html = '<tr class="send-to-raw">' + html +btn_remove  +'</tr>';
                         jQuery('.send-to-raw:last').after(html);
                     }
                     
                     function remove_raw(el){
                         jQuery(el).parent('td').parent('tr').remove();
                     }
                     
			
			jQuery(document).ready(function(){
			tinyMCE.init({
					mode : "specific_textareas",
					theme : "modern", 
					/*plugins : "autolink, lists, spellchecker, style, layer, table, advhr, advimage, advlink, emotions, iespell, inlinepopups, insertdatetime, preview, media, searchreplace, print, contextmenu, paste, 

directionality, fullscreen, noneditable, visualchars, nonbreaking, xhtmlxtras, template",*/
					editor_selector :"tinymce-enabled"
				});
			});
						
			</script>
                
                <tr>
                <td valign="top" class="no_wrap"><?php 
            _e("Message", "ProjectTheme");
            ?>
<font style="color:red;">*</font>&nbsp;:</td>
                <td><textarea name="message_a" class="tinymce-enabled" id="message_a"  rows="6" cols="50" ></textarea></td>
                </tr>
                
                
                <tr>
                <td valign="top" class="no_wrap"><?php 
            _e("Attach File", "ProjectTheme");
            ?>
:</td>
                <td>
                	<div style="display: block;">
                		<span style="display:inline-block;"><input type="file" id="file_instant" name="file_instant" class="" multiple=""/></span>
                		<span class="del21" style="float:right;cursor:pointer;" value="clear" onclick="file_clear(); textarea_instant();">Delete</span>
                	</div>
                	<div style="display: block;">
                		<?php 
            _e('Only PDF, TXT, ZIP, Office files and Images.', 'ProjectTheme');
            ?>
                	</div>
                </td>
                </tr>
                
                
                 <tr>
                <td width="140">&nbsp;</td>
                <td></td>
                </tr>
                
                 <tr>
                <td width="140">&nbsp;</td>
                <td><input name="send_a" class="submit_bottom2" type="submit"  value="<?php 
            _e("Send Message", 'ProjectTheme');
            ?>
" /></td>
                </tr>
                
                </table>
      			</form>
                
                </div>
                </div>
             
        
        <?php 
        }
    }
    ?>
        
             
        </div> <!-- end dif content -->
        <script type="text/javascript">
		


        	$(document).ready(function(){
        		
        		$('.conv_time').each(function(){
        			var tm = parseInt($(this).text())*1000;
        			console.log(tm);
        			var time = new Date(tm);
        			$(this).text(time.toLocaleString());
        		});
        	
});

         
        	function file_clear(){
       			$('#file_instant').val('');
    		}
			
		 
			
		  
   
   </script>
        
        <?php 
    ProjectTheme_get_users_links();
    ?>
        
    
	
<?php 
}
Пример #4
0
function ProjectTheme_my_account_private_messages_area_function()
{
    global $current_user, $wpdb, $wp_query;
    get_currentuserinfo();
    $uid = $current_user->ID;
    $myuid = $uid;
    ?>
    	 
       <?php 
    global $wpdb, $wp_rewrite, $wp_query;
    $third_page = $wp_query->query_vars['pg'];
    if (empty($third_page)) {
        $third_page = 'home';
    }
    ?>
        <div class="clear10"></div>
      <div id="content" class="account-main-area">
        
        <div class="my_box3"><div class="padd10">
          <div class="clear10"></div>
          
            
                <ul class="cms_cms"> 
                <li><a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url();
    ?>
" class="green_btn"><?php 
    _e("Messaging Home", "ProjectTheme");
    ?>
</a></li>
               <li> <a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url('send');
    ?>
" class="green_btn"><?php 
    _e("Send New Message", "ProjectTheme");
    ?>
</a></li>
                <li><a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url('inbox');
    ?>
" class="green_btn"><?php 
    _e("Inbox", "ProjectTheme");
    global $current_user;
    get_currentuserinfo();
    $rd = projectTheme_get_unread_number_messages($current_user->ID);
    if ($rd > 0) {
        echo ' (' . $rd . ')';
    }
    ?>
</a></li>
                <li><a href="<?php 
    echo ProjectTheme_get_priv_mess_page_url('sent-items');
    ?>
" class="green_btn"><?php 
    _e("Sent Items", "ProjectTheme");
    ?>
</a></li>
             	
                </ul>
                
        </div></div>
        <div class="clear10"></div>
        <?php 
    if ($third_page == 'home') {
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        ?>
        
        
		<!-- page content here -->	
			
            
            	
            	<div class="my_box3">
            	
            	<div class="box_title"><?php 
        _e("Latest Received Messages", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $uidsss = $current_user->ID;
        $s = "select * from " . $wpdb->prefix . "project_pm where user='******'  AND show_to_destination='1' and approved='1'  order by id desc limit 4";
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            echo '<table width="100%">';
            echo '<tr>';
            echo '<td>' . __('From User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                if ($row->rd == 0) {
                    $cls = 'bold_stuff';
                } else {
                    $cls = '';
                }
                $user = get_userdata($row->initiator);
                echo '<tr>';
                echo '<td class="' . $cls . '"><a href="' . get_bloginfo('siteurl') . '/?p_action=user_profile&post_author=' . $user->ID . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . $row->subject . '</td>';
                echo '<td class="' . $cls . '">' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
            
                </div>
                </div>
            
            <!--#######-->
            
            <div class="clear10"></div>
            
            	<div class="my_box3">
            	
            
            	<div class="box_title"><?php 
        _e("Latest Sent Items", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $uidss = $current_user->ID;
        $s = "select * from " . $wpdb->prefix . "project_pm where initiator='{$uidss}'  AND show_to_source='1' order by id desc limit 4";
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            echo '<table width="100%">';
            echo '<tr>';
            echo '<td>' . __('To User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                //if($row->rd == 0) $cls = 'bold_stuff';
                //else
                $cls = '';
                $user = get_userdata($row->user);
                echo '<tr>';
                echo '<td class="' . $cls . '"><a href="' . ProjectTheme_get_user_profile_link($row->user) . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . $row->subject . '</td>';
                echo '<td class="' . $cls . '">' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
               
                </div>
                </div>
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'inbox') {
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        //echo $myuid;
        ?>
        
        
		<!-- page content here -->	
			
            
            	<div class="my_box3">
           
            
            	<div class="box_title"><?php 
        _e("Private Messages: Inbox", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $page_rows = 20;
        $page_rows = apply_filters('ProjectTheme_nr_of_messages_priv_pagination', $page_rows);
        $pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
        $max = ' limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
        $s = "select count(id) tots from " . $wpdb->prefix . "project_pm where user='******' AND show_to_destination='1' and approved='1'";
        $r = $wpdb->get_results($s);
        $total = $r[0]->tots;
        $last = ceil($total / $page_rows);
        //-------------------------
        $s = "select * from " . $wpdb->prefix . "project_pm where user='******' AND show_to_destination='1' and approved='1' order by id desc " . $max;
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            ?>
                    
                    <script>
					
					$(document).ready(function() {
						//set initial state.
					 
					
						$('#select_all_stuff').change(function() {
							if($(this).is(":checked")) {
								
								$('.message_select_bx').attr("checked", true);
							}
							else
							{
								$('.message_select_bx').attr("checked", false);	
							}
						});
					});
											
					
					</script>
                    
                    <?php 
            echo '<form method="post" action="' . ProjectTheme_get_priv_mess_page_url('delete-message', '', '&return=inbox') . '">';
            echo '<table width="100%">';
            echo '<tr>';
            echo '<td><input type="checkbox" name="" id="select_all_stuff" value="1" /> ' . __('Select All', 'ProjectTheme') . ' </td>';
            echo '<td>' . __('From User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                if ($row->rd == 0) {
                    $cls = 'bold_stuff';
                } else {
                    $cls = '';
                }
                $user = get_userdata($row->initiator);
                echo '<tr>';
                echo '<td><input type="checkbox" class="message_select_bx" name="message_ids[]" value="' . $row->id . '" /></td>';
                echo '<td class="' . $cls . '"><a href="' . get_bloginfo('siteurl') . '/?p_action=user_profile&post_author=' . $user->ID . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . substr($row->subject, 0, 30) . '</td>';
                echo '<td class="' . $cls . '">' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '<tr><td colspan="5"><input type="submit" value="' . __('Delete Selected', 'ProjectTheme') . '" name="delete_sel" /></td></tr>';
            echo '<tr><td colspan="5">  ';
            echo ProjectTheme_get_my_pagination_main(get_bloginfo('siteurl') . "/?page_id=" . get_option('ProjectTheme_my_account_private_messages_id'), $pagenum, 'pagenum', $last, '&pg=inbox');
            echo ' </td></tr>';
            echo '</table></form>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
             
                </div>
                </div>
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'sent-items') {
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        ?>
        
        		<script>
					
					$(document).ready(function() {
						//set initial state.
					 
					
						$('#select_all_stuff').change(function() {
							if($(this).is(":checked")) {
								
								$('.message_select_bx').attr("checked", true);
							}
							else
							{
								$('.message_select_bx').attr("checked", false);	
							}
						});
					});
											
					
					</script>
		<!-- page content here -->	
			
            
            	<div class="my_box3">
            
            
            	<div class="box_title"><?php 
        _e("Private Messages: Sent Items", "ProjectTheme");
        ?>
</div>
                <div class="box_content">  
                <?php 
        global $wpdb;
        $page_rows = 20;
        $page_rows = apply_filters('ProjectTheme_nr_of_messages_priv_pagination', $page_rows);
        $pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
        $max = ' limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
        //---------------------------------
        $s = "select count(id) tots from " . $wpdb->prefix . "project_pm where initiator='{$myuid}' AND show_to_source='1' and approved='1'";
        $r = $wpdb->get_results($s);
        $total = $r[0]->tots;
        $last = ceil($total / $page_rows);
        //---------------------------------
        $s = "select * from " . $wpdb->prefix . "project_pm where initiator='{$myuid}' AND show_to_source='1' and approved='1' order by id desc " . $max;
        $r = $wpdb->get_results($s);
        if (count($r) > 0) {
            echo '<form method="post" action="' . ProjectTheme_get_priv_mess_page_url('delete-message', '', '&return=outbox') . '">';
            echo '<table width="100%">';
            echo '<tr>';
            echo '<td><input type="checkbox" name="" id="select_all_stuff" value="1" /> ' . __('Select All', 'ProjectTheme') . ' </td>';
            echo '<td>' . __('To User', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Subject', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Date', 'ProjectTheme') . '</td>';
            echo '<td>' . __('Options', 'ProjectTheme') . '</td>';
            echo '</tr>';
            foreach ($r as $row) {
                //if($row->rd == 0) $cls = 'bold_stuff';
                //else
                $cls = '';
                $user = get_userdata($row->user);
                echo '<tr>';
                echo '<td><input type="checkbox" class="message_select_bx" name="message_ids[]" value="' . $row->id . '" /></td>';
                echo '<td class="' . $cls . '"><a href="' . ProjectTheme_get_user_profile_link($row->user) . '">' . $user->user_login . '</a></td>';
                echo '<td class="' . $cls . '">' . substr($row->subject, 0, 30) . '</td>';
                echo '<td class="' . $cls . '">' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                echo '<td><a href="' . ProjectTheme_get_priv_mess_page_url('read-message', $row->id) . '">' . __('Read', 'ProjectTheme') . '</a> | 
						<a href="' . ProjectTheme_get_priv_mess_page_url('delete-message', $row->id) . '">' . __('Delete', 'ProjectTheme') . '</a></td>';
                echo '</tr>';
            }
            echo '<tr><td colspan="5"><input type="submit" value="' . __('Delete Selected', 'ProjectTheme') . '" name="delete_sel" /></td></tr>';
            echo '<tr><td colspan="5">  ';
            echo ProjectTheme_get_my_pagination_main(get_bloginfo('siteurl') . "/?page_id=" . get_option('ProjectTheme_my_account_private_messages_id'), $pagenum, 'pagenum', $last, '&pg=sent-items');
            echo ' </td></tr>';
            echo '</table></form>';
        } else {
            _e('No messages here.', 'ProjectTheme');
        }
        ?>
      
                </div>
                </div>
        
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'delete-message') {
        $id = $_GET['id'];
        $s = "select * from " . $wpdb->prefix . "project_pm where id='{$id}' AND (user='******' OR initiator='{$myuid}')";
        $r = $wpdb->get_results($s);
        $row = $r[0];
        global $current_user;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        if ($myuid == $row->initiator) {
            $owner = true;
        } else {
            $owner = false;
        }
        //if(!$owner)
        //$wpdb->query("update_i18n ".$wpdb->prefix."auction_pm set rd='1' where id='{$row->id}'");
        ?>
        
        
		<!-- page content here -->	
			
            
            	<div class="my_box3">
            	<div class="padd10">
            
            	<div class="box_title"><?php 
        if (isset($_POST['delete_sel'])) {
            _e("Delete Multiple Messages: ", "ProjectTheme");
        } else {
            _e("Delete Message: ", "ProjectTheme");
            echo " " . $row->subject;
        }
        ?>
</div>
                <div class="box_content">  
                
                <?php 
        if (isset($_POST['message_ids'])) {
            $message_ids2 = $_POST['message_ids'];
            foreach ($message_ids2 as $message_id) {
                $ss1 = "select * from " . $wpdb->prefix . "project_pm where id='{$message_id}'";
                $rr1 = $wpdb->get_results($ss1);
                $rrow1 = $rr1[0];
                echo '#' . $rrow1->id . " " . $rrow1->subject . '<br/>';
            }
            echo '<br/>';
        }
        ?>
                
                <?php 
        //echo $row->content;
        ?>
      <br/> <br/>
      
      <?php 
        if (1) {
            //$owner == false):
            if (isset($_POST['delete_sel'])) {
                $message_ids = $_POST['message_ids'];
                if (count($message_ids) == 0) {
                    _e("No messsages selected.", "ProjectTheme");
                } else {
                    $attash = '';
                    foreach ($message_ids as $message_id) {
                        $attash .= '&message_id[]=' . $message_id;
                    }
                    ?>
					
                   <a href="<?php 
                    echo $_GET['rdr'];
                    ?>
" class="nice_link"><?php 
                    _e("Cancel", 'ProjectTheme');
                    ?>
</a>
                    
                    <a href="<?php 
                    echo ProjectTheme_get_priv_mess_page_url('delete-message', '', '&confirm_message_deletion=yes&return=' . urlencode($_GET['rdr'])) . $attash;
                    ?>
" 
       				class="nice_link"><?php 
                    _e("Confirm Deletion", 'ProjectTheme');
                    ?>
</a>
                
                <?php 
                }
            } else {
                ?>
      
      <a href="<?php 
                echo $_GET['rdr'];
                ?>
" class="nice_link"><?php 
                _e("Cancel", 'ProjectTheme');
                ?>
</a>
      
       <a href="<?php 
                echo ProjectTheme_get_priv_mess_page_url('delete-message', $row->id, '&confirm_message_deletion=yes&return=' . urlencode($_GET['rdr']));
                ?>
" 
       class="nice_link"><?php 
                _e("Confirm Deletion", 'ProjectTheme');
                ?>
</a> <?php 
            }
        }
        ?>
                </div>
                </div>
                </div>
            
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'read-message') {
        global $current_user, $wpdb;
        get_currentuserinfo();
        $myuid = $current_user->ID;
        $id = $_GET['id'];
        $s = "select * from " . $wpdb->prefix . "project_pm where id='{$id}'  AND (user='******' OR initiator='{$myuid}')";
        $r = $wpdb->get_results($s);
        $row = $r[0];
        if ($myuid == $row->initiator) {
            $owner = true;
        } else {
            $owner = false;
        }
        if (!$owner) {
            $wpdb->query("update " . $wpdb->prefix . "project_pm set rd='1' where id='{$row->id}'");
        }
        ?>
        
        
		<!-- page content here -->	
			
            
            	<div class="my_box3">
           
            
            	<div class="box_title"><?php 
        _e("Read Message: ", "ProjectTheme");
        echo " " . $row->subject;
        ?>
</div>
                <div class="box_content">  
                <?php 
        echo $row->content;
        ?>
      <br/> <br/>
      
      <?php 
        if (!empty($row->file_attached)) {
            echo sprintf(__('File Attached: %s', 'ProjectTheme'), '<a href="' . wp_get_attachment_url($row->file_attached) . '">' . wp_get_attachment_url($row->file_attached) . "</a>");
        }
        ?>
      
      
      <?php 
        if ($owner == false) {
            ?>
       <a href="<?php 
            echo ProjectTheme_get_priv_mess_page_url('send', '', '&pid=' . $row->pid . '&uid=' . $row->initiator . '&in_reply_to=' . $row->id);
            ?>
" class="nice_link"><?php 
            _e("Reply", 'ProjectTheme');
            ?>
</a> <?php 
        }
        ?>
                </div>
                </div>
             
            
		<!-- page content here -->	
			
        <?php 
    } elseif ($third_page == 'send') {
        ?>
        <?php 
        $pid = $_GET['pid'];
        $uid = $_GET['uid'];
        $user = get_userdata($uid);
        if (!empty($pid)) {
            $post = get_post($pid);
            $subject = "RE: " . $post->post_title;
        } elseif (!empty($_GET['in_reply_to'])) {
            global $wpdb;
            $ssp = "select * from " . $wpdb->prefix . "project_pm where id='" . $_GET['in_reply_to'] . "'";
            $sspq = $wpdb->get_results($ssp);
            if (strpos($sspq[0]->subject, 'RE:') !== false) {
                $subject = $sspq[0]->subject;
            } else {
                $subject = "RE: " . $sspq[0]->subject;
            }
        }
        if (isset($_POST['send_a'])) {
            require_once ABSPATH . "wp-admin" . '/includes/file.php';
            require_once ABSPATH . "wp-admin" . '/includes/image.php';
            if (!empty($_FILES['file_instant']['name'])) {
                $pids = 0;
                $upload_overrides = array('test_form' => false);
                $uploaded_file = wp_handle_upload($_FILES['file_instant'], $upload_overrides);
                $file_name_and_location = $uploaded_file['file'];
                $file_title_for_media_library = $_FILES['file_instant']['name'];
                $arr_file_type = wp_check_filetype(basename($_FILES['file_instant']['name']));
                $uploaded_file_type = $arr_file_type['type'];
                if ($uploaded_file_type == "application/zip" or $uploaded_file_type == "application/pdf" or $uploaded_file_type == "application/msword" or $uploaded_file_type == "application/msexcel" or $uploaded_file_type == "application/doc" or $uploaded_file_type == "application/docx" or $uploaded_file_type == "application/xls" or $uploaded_file_type == "application/xlsx" or $uploaded_file_type == "application/csv" or $uploaded_file_type == "application/ppt" or $uploaded_file_type == "application/pptx" or $uploaded_file_type == "application/vnd.ms-excel" or $uploaded_file_type == "application/vnd.ms-powerpoint" or $uploaded_file_type == "application/vnd.openxmlformats-officedocument.presentationml.presentation" or $uploaded_file_type == "application/octet-stream" or $uploaded_file_type == "image/png" or $uploaded_file_type == "image/jpg" or $uploaded_file_type == "image/jpeg" or $uploaded_file_type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" or $uploaded_file_type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
                    $attachment = array('post_mime_type' => $uploaded_file_type, 'post_title' => 'Uploaded ZIP ' . addslashes($file_title_for_media_library), 'post_content' => '', 'post_status' => 'inherit', 'post_parent' => 0, 'post_author' => $uid);
                    $attach_id = wp_insert_attachment($attachment, $file_name_and_location, $pids);
                    $attach_data = wp_generate_attachment_metadata($attach_id, $file_name_and_location);
                    wp_update_attachment_metadata($attach_id, $attach_data);
                } else {
                    $error_mm = '1';
                }
            }
            $subject = $_POST['subject_a'];
            $message = $_POST['message_a'];
            $uids = $_POST['to_a'];
            if (isset($_POST['projectss'])) {
                if (!empty($_POST['projectss'])) {
                    $uids = $_POST['projectss'];
                }
            }
            if (!empty($_POST['to_as'])) {
                global $current_user;
                get_currentuserinfo();
                $uids = projectTheme_get_userid_from_username($_POST['to_as']);
                if ($uids == $current_user->ID) {
                    $uids = false;
                    $error_mm = 1;
                    $cant_send = 1;
                }
            }
            if (empty($uids)) {
                $uids = $_GET['uid'];
            }
            if ($uids != false and $error_mm != "1") {
                global $current_user;
                get_currentuserinfo();
                $myuid = $current_user->ID;
                //echo $message;
                //*********************************************
                $ProjectTheme_moderate_private_messages = get_option('ProjectTheme_moderate_private_messages');
                if ($ProjectTheme_moderate_private_messages == "yes") {
                    $ProjectTheme_moderate_private_messages = true;
                } else {
                    $ProjectTheme_moderate_private_messages = false;
                }
                //--------------------------
                if ($ProjectTheme_moderate_private_messages == true) {
                    $approved = '0';
                    $show_to_destination = '0';
                } else {
                    $approved = '1';
                    $show_to_destination = '1';
                }
                //*********************************************
                global $wpdb;
                $wpdb->show_errors = true;
                $tm = $_POST['tm'];
                //current_time('timestamp',0);
                $sr = "select * from " . $wpdb->prefix . "project_pm where initiator='{$myuid}' and user='******' and datemade='{$tm}'";
                $rr = $wpdb->get_results($sr);
                if (count($rr) == 0) {
                    if (empty($pid)) {
                        $pid = 0;
                    }
                    $s = "insert into " . $wpdb->prefix . "project_pm \n\t\t\t\t\t(approved, subject, content, datemade, pid, initiator, user, file_attached, show_to_destination) \n\t\t\t\t\tvalues('{$approved}','{$subject}','{$message}','{$tm}','{$pid}','{$myuid}','{$uids}', '{$attach_id}', '{$show_to_destination}')";
                    $wpdb->query($s);
                    //echo $s;
                    //echo $wpdb->last_error;
                    //-----------------------
                    $user = get_userdata($uid);
                    $message = sprintf(__("You have just received a private message regarding your project: <a href='%s'>%s</a><br/>\n\t\t\t\t\t<a href='%s'>Click here to read the message</a>.", "ProjectTheme"), get_permalink($pid), $post->post_title, get_bloginfo('siteurl') . "/my-account/private-messages");
                    //sitemile_send_email($user->user_email, __('Private Message Received','ProjectTheme') , $message);
                    if ($ProjectTheme_moderate_private_messages == false) {
                        ProjectTheme_send_email_on_priv_mess_received($myuid, $uids);
                    } else {
                        //send message to admin to moderate
                    }
                }
                //-----------------------
                ?>
                
                <div class="my_box3">
            	<div class="padd10">
                 <?php 
                if ($ProjectTheme_moderate_private_messages == false) {
                    _e('Your message has been sent.', 'ProjectTheme');
                } else {
                    _e('Your message has been sent but the receiver will receive it only after moderation.', 'ProjectTheme');
                }
                ?>
                </div>
                </div>
                
                <?php 
            } else {
                if ($error_mm == "1") {
                    if ($cant_send == 1) {
                        echo __('You cannot send a message to yourself.', 'ProjectTheme');
                    } else {
                        echo sprintf(__('Wrong File format: %s', 'ProjectTheme'), $uploaded_file_type);
                    }
                } else {
                    _e('ERROR! wrong username provided.', 'ProjectTheme');
                }
            }
        } else {
            ?>
   
             
        <div class="my_box3">
            	
            
            	<div class="box_title"><?php 
            _e("Send Private Message to: ", "ProjectTheme");
            ?>
 <?php 
            echo $user->user_login;
            ?>
</div>
                <div class="box_content">  
                <form method="post" enctype="multipart/form-data">
                <input type="hidden" name="tm" value="<?php 
            echo current_time('timestamp', 0);
            ?>
" />
                <table>
                <?php 
            if (empty($uid)) {
                $rtt = ProjectTheme_get_my_awarded_projects2($current_user->ID);
                ?>
                <tr>
                <td width="140"><?php 
                _e("Send To", "ProjectTheme");
                ?>
:</td>
                <td><input size="20" name="to_as" type="text" value="" /> <?php 
                if ($rtt) {
                    _e('or', 'ProjectTheme');
                    echo " " . $rtt;
                }
                ?>
</td>
                </tr>
                <?php 
            }
            ?>
                
                <tr>
                <td width="140"><?php 
            _e("Subject", "ProjectTheme");
            ?>
:</td>
                <td><input size="50" name="subject_a" type="text" value="<?php 
            echo $subject;
            ?>
" /></td>
                </tr>
                
                 <script>
			
			jQuery(document).ready(function(){
			tinyMCE.init({
					mode : "specific_textareas",
					theme : "modern", 
					/*plugins : "autolink, lists, spellchecker, style, layer, table, advhr, advimage, advlink, emotions, iespell, inlinepopups, insertdatetime, preview, media, searchreplace, print, contextmenu, paste, directionality, fullscreen, noneditable, visualchars, nonbreaking, xhtmlxtras, template",*/
					editor_selector :"tinymce-enabled"
				});
			});
						
			</script>
                
                <tr>
                <td valign="top"><?php 
            _e("Message", "ProjectTheme");
            ?>
:</td>
                <td><textarea name="message_a" class="tinymce-enabled" rows="6" cols="50"></textarea></td>
                </tr>
                
                
                <tr>
                <td valign="top"><?php 
            _e("Attach File", "ProjectTheme");
            ?>
:</td>
                <td><input type="file" name="file_instant" class="" /> <?php 
            _e('Only PDF, ZIP, Office files and Images.', 'ProjectTheme');
            ?>
</td>
                </tr>
                
                
                 <tr>
                <td width="140">&nbsp;</td>
                <td></td>
                </tr>
                
                 <tr>
                <td width="140">&nbsp;</td>
                <td><input name="send_a" class="submit_bottom2" type="submit" value="<?php 
            _e("Send Message", 'ProjectTheme');
            ?>
" /></td>
                </tr>
                
                </table>
      			</form>
                
                </div>
                </div>
             
        
        <?php 
        }
    }
    ?>
        
             
        </div> <!-- end dif content -->
        
        <?php 
    ProjectTheme_get_users_links();
    ?>
        
    
	
<?php 
}