コード例 #1
0
ファイル: properties.php プロジェクト: dongchpp/BIPHP
/**
 * Processing of submission page
 * Takes care of permission
 * Takes care of performing appropriate action
 * @return string: Redirect identifier
 */
function aviators_submission_process_page()
{
    // most basic security check
    if (!is_user_logged_in()) {
        aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('You need to login to access this page.', 'aviators'));
        wp_redirect(home_url());
        return true;
    }
    if ($_GET['id']) {
        // our precious permission check failed
        if (!aviators_property_action_access($_GET['id'], get_current_user_id(), $_GET['action'])) {
            $page = _aviators_properties_get_submission_page();
            wp_redirect(get_permalink($page));
            return true;
        }
    }
    // Edit action
    if (isset($_GET['action'])) {
        $id = null;
        if (isset($_GET['id'])) {
            $id = $_GET['id'];
        }
        switch ($_GET['action']) {
            case 'add':
            case 'edit':
                _aviators_property_form_enqueue_js();
                if (isset($_POST['post_title'])) {
                    return aviators_properties_property_edit($id, $_POST);
                }
                break;
            case 'delete':
                return aviators_properties_property_delete($id);
                break;
            case 'delete-confirm':
                return aviators_properties_property_delete_confirm($id);
                break;
            case 'delete-thumbnail':
                return aviators_properties_property_thumbnail_delete($id);
                break;
            case 'unpublish':
                return aviators_properties_property_status($id, 'unpublish');
                break;
            case 'publish':
                return aviators_properties_property_status($id, 'publish');
                break;
            case 'pending':
                return aviators_properties_property_status($id, 'pending');
                break;
            default:
                break;
        }
    }
}
コード例 #2
0
ファイル: utils.php プロジェクト: dongchpp/BIPHP
/**
 * Users submissions
 *
 * @param null $user_id
 *
 * @return array|bool
 */
function aviators_submission_get_user_submissions($user_id = NULL, $return_wp_query = FALSE)
{
    if ($user_id == NULL) {
        $user = wp_get_current_user();
    } else {
        $user = get_user_by('id', $user_id);
    }
    $type = aviators_settings_get_value('submission', 'common', 'post_type');
    $posts_per_page = aviators_settings_get_value('submission', 'common', 'posts_per_page');
    if (empty($type)) {
        aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('There are no defined custom post types for submission system.', 'aviators'));
        return wp_redirect(home_url());
    }
    $query = new WP_Query(array('post_type' => $type, 'posts_per_page' => $posts_per_page, 'post_status' => 'any', 'author' => $user->ID, 'paged' => get_query_var('paged')));
    if ($return_wp_query) {
        return $query;
    }
    return $query->posts;
}
コード例 #3
0
ファイル: renderers.php プロジェクト: dongchpp/BIPHP
/**
 * Add new post
 *
 * @return string
 */
function aviators_submission_render_add()
{
    if (!is_user_logged_in()) {
        aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('You must be logged in to access this page.', 'aviators'));
        return wp_redirect(home_url());
    }
    $type = aviators_settings_get_value('submission', 'common', 'post_type');
    if (empty($type)) {
        aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('There are no defined custom post types for submission system.', 'aviators'));
        return wp_redirect(home_url());
    }
    $form = call_user_func('aviators_' . $type . '_form');
    $tos = aviators_settings_get_value('submission', 'tos', 'enable_tos');
    if ($tos) {
        $tos_content = __('No Legal Agreement selected!', 'aviators');
        if ($tos_id = aviators_settings_get_value('submission', 'tos', 'tos_page')) {
            $tos_page = get_post($tos_id);
            $tos_content = do_shortcode($tos_page->post_content);
        }
    }
    return View::render('submission/add.twig', array('form' => $form, 'tos' => $tos, 'tos_page' => $tos_page, 'tos_content' => $tos_content));
}
コード例 #4
0
ファイル: page-login.php プロジェクト: dongchpp/BIPHP
<?php

/**
 * Template Name: Login Template
 */
if (is_user_logged_in()) {
    aviators_flash_add_message(AVIATORS_FLASH_INFO, __('You are already logged in.', 'aviators'));
    return header('Location: ' . site_url());
} else {
    global $wp_query;
    echo View::render('page-login.twig', array('wp_query' => $wp_query, 'posts' => $wp_query->posts, 'active' => 'login'));
}
コード例 #5
0
<?php

/**
 * Template Name: Submission Index
 */
if (is_user_logged_in()) {
    $redirect = aviators_submission_process_page();
    if ($redirect) {
        return;
    }
    $content = aviators_submission_render_page();
    echo View::render('page-submission-index.twig', array('content' => $content));
} else {
    aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('You must be logged in to access this page.', 'aviators'));
    $pages = get_posts(array('post_type' => 'page', 'meta_key' => '_wp_page_template', 'meta_value' => 'page-login.php'));
    if (is_array($pages) && count($pages) > 0) {
        $login_page = $pages[0];
        $login_page_permalink = get_post_permalink($login_page->ID);
        return wp_redirect($login_page_permalink);
    }
    return wp_redirect(home_url());
}
コード例 #6
0
ファイル: properties.php プロジェクト: dongchpp/BIPHP
/**
 * Change status for post
 * @param $id
 * @param $status
 */
function aviators_properties_property_status($id, $status)
{
    $post = get_post($id);
    if ($status == 'unpublish') {
        $post->post_status = 'draft';
        aviators_flash_add_message(AVIATORS_FLASH_SUCCESS, __('Post has been successfully unpublished.', 'aviators'));
    }
    if ($status == 'pending') {
        $post->post_status = 'pending';
        aviators_flash_add_message(AVIATORS_FLASH_SUCCESS, __('Post is pending admin review.', 'aviators'));
    }
    if ($status == 'publish') {
        $post->post_status = 'publish';
        aviators_flash_add_message(AVIATORS_FLASH_SUCCESS, __('Post has been successfully published.', 'aviators'));
    }
    wp_update_post($post);
    $submission_page = _aviators_properties_get_submission_page();
    wp_redirect(get_permalink($submission_page->ID));
    return TRUE;
}
コード例 #7
0
ファイル: return.php プロジェクト: dongchpp/BIPHP
<?php

require_once '../../../../../../wp-load.php';
$post = get_post($_GET['post_id']);
$post->post_status = 'publish';
switch ($_GET['paypal']) {
    case 'paid':
        wp_update_post($post);
        $transaction_id = wp_insert_post(array('post_title' => 'Transaction ' . mysql2date(get_option('date_format'), date("Y-m-d H:i:s")), 'post_type' => 'transaction', 'post_status' => 'publish'));
        global $current_user;
        $purchase = aviators_submission_create_paypal_purchase($_GET['post_id']);
        $purchase->process_payment();
        $price = aviators_settings_get_value('submission', 'pay_per_post', 'price') + aviators_settings_get_value('submission', 'pay_per_post', 'tax');
        $formatted_price = aviators_price_format($price);
        update_post_meta($transaction_id, '_transaction_user_id', $current_user->ID);
        update_post_meta($transaction_id, '_transaction_cost', $formatted_price);
        update_post_meta($transaction_id, '_transaction_status', $_GET['paypal']);
        update_post_meta($transaction_id, '_transaction_post_id', $_GET['post_id']);
        update_post_meta($transaction_id, '_transaction_token', $_GET['token']);
        update_post_meta($transaction_id, '_transaction_payer_id', $_GET['PayerID']);
        update_post_meta($transaction_id, '_transaction_meta_fields', array('_transaction_user_id', '_transaction_cost', '_transaction_status', '_transaction_post_id', '_transaction_token', '_transaction_payer_id'));
        aviators_flash_add_message(AVIATORS_FLASH_SUCCESS, __('Submission has been successfully published. Thanks!', 'aviators'));
        return wp_redirect(home_url());
        break;
    default:
        aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('Submission has not been paid yet.', 'aviators'));
        return wp_redirect(home_url());
        break;
}
コード例 #8
0
ファイル: header.php プロジェクト: dongchpp/BIPHP
<?php

$color_class = 'blue';
if (isset($_GET['action'])) {
    if ($_GET['action'] == 'register') {
        aviators_flash_add_message('AVIATORS_FLASH_SUCCESS', __('Registration complete. Please check your e-mail.'));
    }
}
if (get_theme_mod('general_variant') != '') {
    $general_variant = get_theme_mod('general_variant');
    $name = explode('-', $general_variant);
    $classes = explode('.', end($name));
    if (!empty($classes[0])) {
        $color_class = $classes[0];
    }
}
$locations = get_nav_menu_locations();
$main_menu_settings = array('theme_location' => 'main', 'menu_class' => 'nav', 'echo' => FALSE);
if (!empty($locations['main']) && $locations['main'] == 0) {
    $main_menu_settings['menu'] = 'Main';
}
$anonymous_menu_settings = array('theme_location' => 'anonymous', 'menu_class' => 'nav nav-pills', 'echo' => FALSE);
if (!empty($locations['anonymous']) && $locations['anonymous'] == 0) {
    $anonymous_menu_settings['menu'] = 'Anonymous';
}
$authenticated_menu_settings = array('theme_location' => 'authenticated', 'menu_class' => 'nav nav-pills', 'echo' => FALSE);
if (!empty($locations['authenticated']) && $locations['authenticated'] == 0) {
    $authenticated_menu_settings['menu'] = 'Authenticated';
}
require_once get_template_directory() . '/aviators/plugins/properties/enquire.php';
do_action('aviators_before_page_render');
コード例 #9
0
ファイル: enquire.php プロジェクト: dongchpp/BIPHP
        // send to agents
        if (aviators_settings_get_value('properties', 'enquire_form_receive', 'agent') && is_array($agents)) {
            foreach ($agents as $agent_id) {
                $email = get_post_meta($agent_id, '_agent_email', TRUE);
                $is_sent = wp_mail($email, aviators_settings_get_value('properties', 'enquire_form', 'subject'), $message, $headers);
            }
        }
        // send to admin
        if (aviators_settings_get_value('properties', 'enquire_form_receive', 'admin')) {
            $is_sent = wp_mail(get_option('admin_email'), aviators_settings_get_value('properties', 'enquire_form', 'subject'), $message, $headers);
        }
        // send to custom address
        $send_to_custom = aviators_settings_get_value('properties', 'enquire_form_receive', 'custom');
        if (!empty($send_to_custom)) {
            $emails = explode(',', $send_to_custom);
            foreach ($emails as $email) {
                $is_sent = wp_mail(trim($email), aviators_settings_get_value('properties', 'enquire_form', 'subject'), $message, $headers);
            }
        }
        if ($is_sent) {
            aviators_flash_add_message(AVIATORS_FLASH_SUCCESS, __('Your enquire was successfully sent.', 'aviators'));
        } else {
            aviators_flash_add_message(AVIATORS_FLASH_ERROR, __('An error occured. Your enquire can not be sent.', 'aviators'));
        }
    }
    if (!empty($_SERVER['HTTP_REFERER'])) {
        header('Location: ' . $_SERVER['HTTP_REFERER']);
    } else {
        header('Location: ' . site_url());
    }
}