Пример #1
0
function rcl_get_userlist($atts, $content = null)
{
    global $rcl_user, $rcl_users_set;
    require_once 'class-rcl-users.php';
    $users = new Rcl_Users($atts);
    $count_users = false;
    if (!$users->number) {
        $rqst = $users->search_request();
        $search_string = $rqst ? '&' . implode('&', $rqst) : '';
        $count_users = $users->count_users();
        $rclnavi = new RCL_navi($users->inpage, $count_users, $search_string, $users->paged);
        $users->offset = $rclnavi->offset;
        $users->number = $rclnavi->inpage;
    }
    $usersdata = $users->get_users();
    $userlist = $users->get_filters($count_users);
    if (!$usersdata) {
        $userlist .= '<p align="center">' . __('Users not found', 'wp-recall') . '</p>';
        $users->remove_data();
        return $userlist;
    }
    $userlist .= '<div class="userlist ' . $users->template . '-list">';
    $rcl_users_set = $users;
    foreach ($usersdata as $rcl_user) {
        $users->setup_userdata($rcl_user);
        $userlist .= rcl_get_include_template('user-' . $users->template . '.php');
    }
    $userlist .= '</div>';
    if (isset($rclnavi->inpage) && $rclnavi->inpage) {
        $userlist .= $rclnavi->navi();
    }
    $users->remove_data();
    return $userlist;
}
Пример #2
0
function rcl_get_grouplist($atts)
{
    include_once 'classes/rcl-groups.php';
    $list = new Rcl_Groups($atts);
    $count = false;
    if (!$list->number) {
        $rqst = $list->search_request();
        $search_string = $rqst ? '&' . implode('&', $rqst) : '';
        $count = $list->count_groups();
        $rclnavi = new RCL_navi($list->inpage, $count, $search_string, $list->paged);
        $list->offset = $rclnavi->offset;
        $list->number = $rclnavi->inpage;
    }
    $groupsdata = $list->get_groups();
    $content = $list->get_filters($count);
    if (!$groupsdata) {
        $content .= '<p align="center">' . __('Groups not found', 'wp-recall') . '</p>';
        return $content;
    }
    $content .= '<div class="rcl-grouplist">';
    foreach ($groupsdata as $rcl_group) {
        $list->setup_groupdata($rcl_group);
        $content .= rcl_get_include_template('group-list.php', __FILE__);
    }
    $content .= '</div>';
    if ($rclnavi->inpage) {
        $content .= $rclnavi->navi();
    }
    $list->remove_data();
    return $content;
}
Пример #3
0
function rcl_related_products($content)
{
    global $rmag_options, $post;
    if ($rmag_options['sistem_related_products'] != 1) {
        return $content;
    }
    if ($post->post_type != 'products') {
        return $content;
    }
    $related_prodcat = get_post_meta($post->ID, 'related_products_recall', 1);
    if (!$related_prodcat) {
        return $content;
    }
    $args = array('numberposts' => $rmag_options['size_related_products'], 'orderby' => 'rand', 'post_type' => 'products', 'exclude' => $post->ID, 'tax_query' => array(array('taxonomy' => 'prodcat', 'field' => 'id', 'terms' => $related_prodcat)));
    $related_products = get_posts($args);
    if (!$related_products) {
        return $content;
    }
    $content .= '<div class="related-products prodlist">';
    $title_related = $rmag_options['title_related_products_recall'];
    if ($title_related) {
        $content .= '<h3>' . $title_related . '</h3>';
    }
    foreach ($related_products as $post) {
        setup_postdata($post);
        $content .= rcl_get_include_template('product-slab.php', __FILE__);
    }
    wp_reset_query();
    $content .= '</div>';
    return $content;
}
Пример #4
0
function rcl_repository_page()
{
    global $addon, $active_addons;
    $paths = array(RCL_PATH . 'add-on', RCL_TAKEPATH . 'add-on');
    foreach ($paths as $path) {
        if (file_exists($path)) {
            $installs = scandir($path, 1);
            $a = 0;
            foreach ($installs as $namedir) {
                $install_addons[$namedir] = 1;
            }
        }
    }
    $url = 'http://wppost.ru/products-files/api/add-ons.php' . '?rcl-addon-info=get-add-ons&number=20';
    $data = array('rcl-key' => get_option('rcl-key'), 'rcl-version' => VER_RCL, 'host' => $_SERVER['SERVER_NAME']);
    $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    $result = json_decode($result);
    //print_r($result);exit;
    if (!$result) {
        echo '<h2>Не удалось получить данные.</h2>';
        exit;
    }
    if (is_array($result) && isset($result['error'])) {
        echo '<h2>Ошибка! ' . $result['error'] . '</h2>';
        exit;
    }
    $content = '<div class="wp-list-table widefat plugin-install">
	<div id="the-list">';
    foreach ($result as $add) {
        if (!$add || isset($install_addons[$add->slug])) {
            continue;
        }
        (object) $addon;
        foreach ($add as $k => $v) {
            $key = str_replace('-', '_', $k);
            $v = isset($v) ? $v : '';
            $addon->{$key} = $v;
        }
        $content .= rcl_get_include_template('add-on-card.php');
    }
    $content .= '</div>' . '</div>';
    echo '<h1>Репозиторий дополнений Wp-Recall</h1>';
    echo '<p>На этой странице отображаются доступные на данный момент дополнения, но не установленные на вашем сайте.</p>';
    echo $content;
}
Пример #5
0
function rcl_orders($author_lk)
{
    global $wpdb, $user_ID, $rmag_options, $rcl_options, $order;
    if ($user_ID != $author_lk) {
        return false;
    }
    $block = apply_filters('content_order_tab', '');
    if (isset($_GET['order-id'])) {
        $order = rcl_get_order($_GET['order-id']);
        if ($order->order_author != $user_ID) {
            return false;
        }
        $status = $order->order_status;
        $order_id = $order->order_id;
        $price = $order->order_price;
        $block .= '<a class="recall-button view-orders" href="' . rcl_format_url(get_author_posts_url($author_lk), 'orders') . '">Смотреть все заказы</a>';
        $block .= '<h3>Заказ №' . $order_id . '</h3>';
        $block .= '<div id="manage-order">';
        if ($status == 1 || $status == 5) {
            $block .= '<input class="remove_order recall-button" onclick="rcl_trash_order(this);return false;" type="button" name="remove_order" data-order="' . $order_id . '" value="Удалить">';
        }
        if ($status == 1 && function_exists('rcl_payform')) {
            $type_pay = $rmag_options['type_order_payment'];
            if ($type_pay == 1 || $type_pay == 2) {
                $block .= rcl_payform(array('id_pay' => $order_id, 'summ' => $price, 'type' => 2));
            } else {
                $block .= '<input class="pay_order recall-button" onclick="rcl_pay_order_private_account(this);return false;" type="button" name="pay_order" data-order="' . $order_id . '" value="Оплатить">';
            }
        }
        $block .= '</div>';
        $block .= '<div class="redirectform"></div>';
        $block .= rcl_get_include_template('order.php', __FILE__);
    } else {
        global $orders;
        $orders = rcl_get_orders(array('user_id' => $user_ID, 'status_not_in' => 6));
        if (!$orders) {
            $block .= '<p>У вас пока не оформлено ни одного заказа.</p>';
        } else {
            $block .= rcl_get_include_template('orders-history.php', __FILE__);
        }
    }
    return $block;
}
Пример #6
0
function rcl_feed_shortcode($atts)
{
    global $wpdb, $user_ID, $rcl_feed;
    if (!$user_ID) {
        return '<p class="aligncenter">' . __('Login or register to view the latest publications and comments from users on which you will you subscribed.', 'wp-recall') . '</p>';
    }
    include_once 'classes/class-rcl-feed.php';
    $list = new Rcl_Feed($atts);
    $count = false;
    if (!$list->number) {
        $rqst = $list->search_request();
        $search_string = $rqst ? '&' . implode('&', $rqst) : '';
        $count = $list->count_feed_posts();
        $rclnavi = new RCL_navi($list->inpage, $count, $search_string, $list->paged);
        $list->offset = $rclnavi->offset;
        $list->number = $rclnavi->inpage;
    }
    $feedsdata = $list->get_feed();
    $content = $list->get_filters($count);
    if (!$feedsdata) {
        $content .= '<p align="center">' . __('News not found', 'wp-recall') . '</p>';
        return $content;
    }
    $load = $rclnavi->inpage ? 'data-load="' . $list->load . '"' : '';
    $content .= '<div id="rcl-feed" data-feed="' . $list->content . '" ' . $load . '>';
    foreach ($feedsdata as $rcl_feed) {
        $list->setup_data($rcl_feed);
        $content .= '<div id="feed-' . $rcl_feed->feed_type . '-' . $rcl_feed->feed_ID . '" class="feed-box feed-user-' . $rcl_feed->feed_author . ' feed-' . $rcl_feed->feed_type . '">';
        $content .= rcl_get_include_template('feed-post.php', __FILE__);
        $content .= '</div>';
    }
    if ($list->load == 'ajax' && $rclnavi->inpage) {
        $content .= '<div id="feed-preloader"><div></div></div>' . '<div id="feed-bottom"></div>';
    }
    $content .= '</div>';
    if ($list->load == 'pagenavi' && $rclnavi->inpage) {
        $content .= $rclnavi->navi();
    }
    $list->remove_data();
    return $content;
}
 function get_postslist_table($author_lk)
 {
     global $wpdb, $post, $posts, $ratings;
     $ratings = array();
     $posts = array();
     //print_r($_POST);
     //exit;
     $start = $this->start . ',';
     $posts[] = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . "posts WHERE post_author='%d' AND post_type='%s' AND post_status NOT IN ('draft','auto-draft') ORDER BY post_date DESC LIMIT {$start} 20", $author_lk, $this->posttype));
     if (is_multisite()) {
         $blog_list = get_blog_list(0, 'all');
         foreach ($blog_list as $blog) {
             $pref = $wpdb->base_prefix . $blog['blog_id'] . '_posts';
             $posts[] = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $pref . " WHERE post_author='%d' AND post_type='%s' AND post_status NOT IN ('draft','auto-draft') ORDER BY post_date DESC LIMIT {$start} 20", $author_lk, $this->posttype));
         }
     }
     if ($posts[0]) {
         $p_list = array();
         if (function_exists('rcl_format_rating')) {
             foreach ($posts as $postdata) {
                 foreach ($postdata as $p) {
                     $p_list[] = $p->ID;
                 }
             }
             $rayt_p = rcl_get_ratings(array('object_id' => $p_list, 'rating_type' => array($this->posttype)));
             foreach ((array) $rayt_p as $r) {
                 if (!isset($r->object_id)) {
                     continue;
                 }
                 $ratings[$r->object_id] = $r->rating_total;
             }
         }
         $posts_block = rcl_get_include_template('posts-list.php', __FILE__);
         wp_reset_postdata();
     } else {
         $posts_block = '<p>' . $this->name . ' ' . __('has not yet been published', 'wp-recall') . '</p>';
     }
     return $posts_block;
 }
Пример #8
0
    function cart()
    {
        global $user_ID, $products;
        $products = $this->get_products();
        if (!$products) {
            return '<p>В вашей корзине пусто.</p>';
        }
        if (!$user_ID) {
            $basket .= '<h3 class="title-data">Корзина <span class="weight-normal">(цены указаны в рублях)</span></h3>';
        }
        $basket .= rcl_get_include_template('cart.php', __FILE__);
        $basket = apply_filters('cart_rcl', $basket);
        if ($this->cnt_products) {
            $basket .= '<div class="confirm">';
            $get_fields_order = get_option('custom_orders_field');
            if ($get_fields_order) {
                $order_field = $this->cart_fields($get_fields_order, 'order');
            }
            if ($user_ID) {
                if ($order_field) {
                    $basket .= '<h3 align="center">Для оформления заказа заполните форму ниже:</h3>
                                                <div id="regnewuser"  style="display:none;"></div>
                    <table class="form-table">' . $order_field . '</table>';
                }
                $basket .= rcl_get_button('Оформить заказ', '#', array('icon' => false, 'class' => 'confirm_order')) . '</div>';
                $basket .= "<script>\r\n                    jQuery(function(){\r\n                    jQuery('#rcl-cart').on('click','.confirm_order',function(){";
                $basket .= $this->script_request('order');
                $basket .= "var dataString_count = 'action=rcl_confirm_order'" . $this->request . ";\r\n                            jQuery.ajax({\r\n                            type: 'POST',\r\n                            data: dataString_count,\r\n                            dataType: 'json',\r\n                            url: wpurl+'wp-admin/admin-ajax.php',\r\n                            success: function(data){\r\n                                    if(data['otvet']==100){\r\n                                            jQuery('.redirectform').html(data['redirectform']);\r\n                                            jQuery('.confirm').remove();\r\n                                            jQuery('.add_remove').empty();\r\n                                    } else if(data['otvet']==10){\r\n                                       jQuery('.redirectform').html(data['amount']);\r\n                                    } else if(data['otvet']==5){\r\n                                            jQuery('#regnewuser').html(data['recall']);\r\n                                            jQuery('#regnewuser').slideDown(500).delay(5000).slideUp(500);\r\n                                    }else {\r\n                                       alert('Ошибка проверки данных.');\r\n                                    }\r\n                            }\r\n                            });\r\n                            return false;\r\n                    });\r\n                });\r\n                </script>";
            } else {
                $get_fields = get_option('custom_profile_field');
                if ($get_fields) {
                    $order_field .= $this->cart_fields($get_fields, 'profile');
                }
                $basket .= '<h3 align="center">Для оформления заказа заполните форму ниже:</h3>
						<div id="regnewuser"  style="display:none;"></div>
                        <table class="form-table">
                            <tr>
                                <td><label>Укажите ваш E-mail <span class="required">*</span>:</label></td>
                                <td><input required type="text" class="email_new_user" name="email_new_user" value=""></td>
                            </tr>
                             <tr>
                                <td><label>Ваше Имя</label></td>
                                <td><input type="text" class="fio_new_user" name="fio_new_user" value=""></td>
                            </tr>
                            ' . $order_field . '
                        </table>
                        <p align="right">' . rcl_get_button('Оформить заказ', '#', array('icon' => false, 'class' => 'rcl_register_user_order', 'id' => false)) . '</p>

                        </div>';
                $basket .= "<script>\r\n                        jQuery(function(){\r\n                                jQuery('#rcl-cart').on('click','.rcl_register_user_order',function(){";
                $basket .= $this->script_request('order');
                $basket .= $this->script_request('profile');
                $basket .= "\r\n                                    var fio = jQuery('.confirm .fio_new_user').attr('value');\r\n                                    var email = jQuery('.confirm .email_new_user').attr('value');\r\n                                    var dataString = 'action=rcl_confirm_order&action=rcl_register_user_order&fio_new_user='******'&email_new_user='******'POST',\r\n                                            data: dataString,\r\n                                            dataType: 'json',\r\n                                            url: wpurl+'wp-admin/admin-ajax.php',\r\n                                            success: function(data){\r\n                                                    if(data['int']==100){\r\n                                                            jQuery('#regnewuser').html(data['recall']);\r\n                                                            jQuery('#regnewuser').slideDown(500);\r\n                                                            if(data['redirect']!=0){\r\n                                                                    location.replace(data['redirect']);\r\n                                                            }else{\r\n                                                                    jQuery('.form-table').remove();\r\n                                                                    jQuery('.rcl_register_user_order').remove();\r\n                                                            }\r\n                                                    } else {\r\n                                                            jQuery('#regnewuser').html(data['recall']);\r\n                                                            jQuery('#regnewuser').slideDown(500).delay(5000).slideUp(500);\r\n                                                    }\r\n                                            }\r\n                                    });\r\n                                    return false;\r\n                            });\r\n                    });\r\n                    </script>";
            }
        }
        return '<form id="rcl-cart" method="post">' . $basket . '</form>' . '<div class="redirectform" style="text-align:center;"></div>';
    }
Пример #9
0
function rmag_manage_orders()
{
    global $wpdb;
    echo '<h2>Управление заказами</h2>
			<div style="width:1050px">';
    //начало блока настроек профиля
    $n = 0;
    $s = 0;
    if ($_GET['remove-trash'] == 101 && wp_verify_nonce($_GET['_wpnonce'], 'delete-trash-rmag')) {
        $wpdb->query($wpdb->prepare("DELETE FROM " . RMAG_PREF . "orders_history WHERE order_status = '%d'", 6));
    }
    if ($_GET['order-id']) {
        global $order, $product;
        $order = rcl_get_order($_GET['order-id']);
        if ($_POST['submit_message']) {
            if ($_POST['email_author']) {
                $email_author = sanitize_email($_POST['email_author']);
            } else {
                $email_author = 'noreply@' . $_SERVER['HTTP_HOST'];
            }
            $user_email = get_the_author_meta('user_email', intval($_POST['address_message']));
            $result_mess = rcl_mail($user_email, sanitize_text_field($_POST['title_message']), force_balance_tags($_POST['text_message']));
        }
        $header_tb = array('№ п/п', 'Наименование товара', 'Цена', 'Количество', 'Сумма', 'Статус');
        echo '<h3>ID заказа: ' . $_GET['order_id'] . '</h3>' . '<table class="widefat">' . '<tr>';
        foreach ($header_tb as $h) {
            echo '<th>' . $h . '</th>';
        }
        echo '</tr>';
        foreach ($order->products as $product) {
            $n++;
            $user_login = get_the_author_meta('user_login', $product->user_id);
            echo '<tr>' . '<td>' . $n . '</td>' . '<td>' . get_the_title($product->product_id) . '</td>' . '<td>' . $product->product_price . '</td>' . '<td>' . $product->numberproduct . '</td>' . '<td>' . $product->product_price . '</td>' . '<td>' . rcl_get_status_name_order($product->order_status) . '</td>' . '</tr>';
        }
        echo '<tr>
			<td colspan="4">Сумма заказа</td>
			<td colspan="2">' . $order->order_price . '</td>
		</tr>
	</table>';
        $get_fields = get_option('custom_profile_field');
        $cf = new Rcl_Custom_Fields();
        foreach ((array) $get_fields as $custom_field) {
            $meta = get_the_author_meta($custom_field['slug'], $order->order_author);
            $show_custom_field .= $cf->get_field_value($custom_field, $meta);
        }
        $details_order = rcl_get_order_details($order->order_id);
        echo '<form><input type="button" value="Назад" onClick="history.back()"></form><div style="text-align:right;"><a href="' . admin_url('admin.php?page=manage-rmag') . '">Показать все заказы</a></div>
	<h3>Все заказы пользователя: <a href="' . admin_url('admin.php?page=manage-rmag&user='******'">' . $user_login . '</a></h3>
	<h3>Информация о пользователе:</h3><p><b>Имя</b>: ' . get_the_author_meta('display_name', $order->order_author) . '</p><p><b>Email</b>: ' . get_the_author_meta('user_email', $order->order_author) . '</p>' . $show_custom_field;
        if ($details_order) {
            echo '<h3>Детали заказа:</h3>' . $details_order;
        }
        if ($result_mess) {
            echo '<h3 style="color:green;">Сообщение было отправлено!</h3>';
        }
        echo '<style>.form_message input[type="text"], .form_message textarea{width:450px;padding:5px;}</style>
	<h3>Написать пользователю сообщение на почту ' . get_the_author_meta('user_email', $order->order_author) . '</h3>
	<form method="post" action="" class="form_message" >
	<p><b>Почта отправителя</b> (по-умолчанию "noreply@' . $_SERVER['HTTP_HOST'] . '")</p>
	<input type="text" name="email_author" value="' . sanitize_email($_POST['email_author']) . '">
	<p><b>Тема письма</b></p>
	<input type="text" name="title_message" value="' . sanitize_text_field($_POST['title_message']) . '">
	<p><b>Текст сообщения</b></p>';
        $textmail = "<p>Добрый день!</p>\n\t<p>Вы или кто то другой оформил заказ на сайте " . get_bloginfo('name') . "</p>\n\t<h3>Детали заказа:</h3>\n\t" . rcl_get_include_template('order.php', __FILE__) . "\n\t<p>Ваш заказ ожидает оплаты. Вы можете произвести оплату своего заказа любым из предложенных способ из своего личного кабинета или просто пополнив свой личный счет на сайте <a href='" . get_bloginfo('wpurl') . "'>" . get_bloginfo('wpurl') . "<p>\n\t____________________________________________________________________________\n\tЭто письмо было сформировано автоматически не надо отвечать на него";
        if ($_POST['text_message']) {
            $textmail = force_balance_tags($_POST['text_message']);
        }
        $args = array('wpautop' => 1, 'media_buttons' => 1, 'textarea_name' => 'text_message', 'textarea_rows' => 15, 'tabindex' => null, 'editor_css' => '', 'editor_class' => 'contentarea', 'teeny' => 0, 'dfw' => 0, 'tinymce' => 1, 'quicktags' => 1);
        wp_editor($textmail, 'textmessage', $args);
        echo '<input type="hidden" name="address_message" value="' . $order->order_author . '">
	<p><input type="submit" name="submit_message" value="Отправить"></p>
	</form>';
        echo $table;
    } else {
        global $order, $product;
        $all_pr = 0;
        list($year, $month, $day, $hour, $minute, $second) = preg_split('([^0-9])', current_time('mysql'));
        $args = array();
        if ($_POST['filter-date']) {
            if ($_POST['year']) {
                $args['year'] = $_POST['year'];
                if ($_POST['month']) {
                    $args['month'] = sanitize_text_field($_POST['month']);
                }
            }
            if ($_POST['status']) {
                $args['order_status'] = intval($_POST['status']);
            }
            $orders = rcl_get_orders($args);
        } else {
            if ($_GET['status']) {
                $args['order_status'] = intval($_GET['status']);
            } elseif ($_GET['user']) {
                $args['user_id'] = intval($_GET['user']);
            } elseif ($_GET['search_order']) {
                $args['order_id'] = intval($_GET['search_order']);
                $args['user_id'] = intval($_GET['search_order']);
                $args['search'] = true;
            } else {
                $args['status_not_in'] = 6;
                $args['year'] = $year;
                $args['month'] = $month;
                $_POST['year'] = $year;
                $_POST['month'] = $month;
            }
            //$where = apply_filters('string_where_get_orders',$where);
        }
        $orders = rcl_get_orders($args);
        if ($orders) {
            foreach ($orders as $rdr) {
                $n++;
                foreach ($rdr as $prods) {
                    $all_pr += $prods->product_price * $prods->numberproduct;
                }
            }
        }
        //if(!isset($_GET['status'])||$_GET['status']!=6)
        $table .= rcl_get_chart_orders($orders);
        $table .= '<h3>Всего заказов: ' . $n . ' на ' . $all_pr . ' рублей</h3>';
        $table .= '<form method="get" action="' . admin_url('admin.php?page=manage-rmag') . '"><p class="search-box">
	<label class="screen-reader-text" for="order-search-input">Поиск заказов:</label>
	<input type="search" id="order-search-input" name="search_order" placeholder="ID заказа или покупателя" value="">
	<input type="submit" id="search-submit" class="button" value="Поиск заказов">
        <input type="hidden" name="page" value="manage-rmag">
        </p></form>';
        $table .= '<form action="" method="post">';
        $table .= '<select name="status">';
        $table .= '<option value="">Все заказы</option>';
        for ($a = 1; $a <= 6; $a++) {
            $table .= '<option value="' . $a . '" ' . selected($a, $_POST['status'], false) . '>' . rcl_get_status_name_order($a) . '</option>';
        }
        $table .= '</select>';
        $table .= '<select name="month">';
        $months = array('За все месяцы', 'январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь');
        foreach ($months as $k => $month) {
            if ($k) {
                $k = zeroise($k, 2);
            }
            $table .= '<option value="' . $k . '" ' . selected($k, $_POST['month'], false) . '>' . $month . '</option>';
        }
        $table .= '</select>';
        $table .= '<select name="year">';
        for ($a = 2013; $a <= $year + 1; $a++) {
            $table .= '<option value="' . $a . '" ' . selected($a, $_POST['year'], false) . '>' . $a . '</option>';
        }
        $table .= '</select>';
        $table .= '<input type="submit" value="Фильтровать" name="filter-date" class="button-secondary">';
        if ($_GET['status'] == 6) {
            $table .= '<a href="' . wp_nonce_url(admin_url('admin.php?page=manage-rmag&remove-trash=101'), 'delete-trash-rmag') . '">Очистить корзину</a>';
        }
        $table .= '</form>';
        if (!$orders) {
            echo $table;
            exit;
        }
        $cols = array('Заказ ID', 'Пользователь', 'Сумма заказа', 'Дата и время', 'Статус', 'Смена статуса', 'Действие');
        $cols = apply_filters('header_table_orders_rcl', $cols);
        $table .= '<table class="widefat"><tr>';
        foreach ($cols as $col) {
            $table .= '<th>' . $col . '</th>';
        }
        $table .= '</tr>';
        foreach ($orders as $order_id => $order) {
            rcl_setup_orderdata($order);
            $radioform .= '<select id="status-' . $order_id . '" name="status-' . $order_id . '">';
            for ($a = 1; $a < 7; $a++) {
                $radioform .= '<option ' . selected($a, $order->order_status, false) . ' value="' . $a . '">' . rcl_get_status_name_order($a) . '</option>';
            }
            $radioform .= '</select>';
            if ($order->order_status == 6) {
                $delete = '<input type="button" class="button-primary delete-order" id="' . $order_id . '" value="Удалить">';
            }
            $button = '<input type="button" class="button-secondary select_status" id="' . $order_id . '" value="Изменить статус"> ' . $delete;
            $user_id = $order->order_author;
            $pagelink = admin_url('admin.php?page=manage-rmag');
            $cols_content = array('<a href="' . $pagelink . '&order-id=' . $order_id . '">Заказ ' . $order_id . '</a>', '<a href="' . $pagelink . '&user='******'">' . get_the_author_meta('user_login', $user_id) . '</a>', $order->order_price, $order->order_date, '<a href="' . $pagelink . '&status=' . $order->order_status . '"><span class="change-' . $order_id . '">' . rcl_get_status_name_order($order->order_status) . '</span></a>', $radioform, $button);
            $cols_content = apply_filters('content_table_orders_rcl', $cols_content, $user_id);
            $table .= '<tr id="row-' . $order_id . '">';
            foreach ($cols_content as $content) {
                $table .= '<td>' . $content . '</td>';
            }
            $table .= '</tr>';
            $radioform = '';
            $delete = '';
        }
        $cnt_cols = count($cols);
        if ($_GET['status'] != 6) {
            $table .= '<tr><td align="right" colspan="' . $cnt_cols . '"><a href="' . admin_url('admin.php?page=manage-rmag&status=6') . '">Перейти в корзину</a></td></tr>';
        }
        $table .= '</table>';
        echo $table;
        if ($_GET['user'] || $_GET['status'] || $_GET['date']) {
            echo '<form><input type="button" value="Назад" onClick="history.back()"></form><div style="text-align:right;"><a href="' . admin_url('admin.php?page=manage-rmag') . '">Показать текущие заказы</a></div>';
        }
    }
    echo '</div>';
    //конец блока заказов
}
Пример #10
0
function rcl_payment_order($order_id, $user_id = false)
{
    global $wpdb, $order, $rmag_options;
    $order = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "rmag_orders_history WHERE order_id='%d'", $order_id));
    rcl_setup_orderdata($order);
    if (!$user_id) {
        $user_id = $order->order_author;
    }
    rcl_remove_reserve($order_id);
    rcl_update_status_order($order_id, 2);
    //Если работает реферальная система и партнеру начисляются проценты с покупок его реферала
    if (function_exists('add_referall_incentive_order')) {
        add_referall_incentive_order($user_id, $order->order_price);
    }
    $get_fields = get_option('custom_profile_field');
    if ($get_fields) {
        $cf = new Rcl_Custom_Fields();
        foreach ((array) $get_fields as $custom_field) {
            $slug = $custom_field['slug'];
            $meta = get_the_author_meta($slug, $user_id);
            $show_custom_field .= $cf->get_field_value($custom_field, $meta);
        }
    }
    $table_order = rcl_get_include_template('order.php', __FILE__);
    $args = array('role' => 'administrator');
    $users = get_users($args);
    $subject = 'Заказ №' . $order->order_id . ' оплачен!';
    $admin_email = $rmag_options['admin_email_magazin_recall'];
    $text = '';
    $text = apply_filters('payment_mail_text', $text);
    //print_r($text);exit;
    $textmail = '
    <p>Пользователь оплатил заказ в магазине "' . get_bloginfo('name') . '".</p>
    <h3>Информация о пользователе:</h3>
    <p><b>Имя</b>: ' . get_the_author_meta('display_name', $user_id) . '</p>
    <p><b>Email</b>: ' . get_the_author_meta('user_email', $user_id) . '</p>
    ' . $show_custom_field . '
    <p>Заказ №' . $order_id . ' получил статус "Оплачено".</p>
    <h3>Детали заказа:</h3>
    ' . $table_order . '
	' . $text . '
    <p>Ссылка для управления заказом в админке:</p>
    <p>' . admin_url('admin.php?page=manage-rmag&order-id=' . $order_id) . '</p>';
    if ($admin_email) {
        rcl_mail($admin_email, $subject, $textmail);
    } else {
        foreach ((array) $users as $userdata) {
            $email = $userdata->user_email;
            rcl_mail($email, $subject, $textmail);
        }
    }
    $email = get_the_author_meta('user_email', $user_id);
    $textmail = '
    <p>Вы оплатили заказ в магазине "' . get_bloginfo('name') . '" средствами со своего личного счета.</p>
    <h3>Информация о покупателе:</h3>
    <p><b>Имя</b>: ' . get_the_author_meta('display_name', $user_id) . '</p>
    <p><b>Email</b>: ' . get_the_author_meta('user_email', $user_id) . '</p>
    ' . $show_custom_field . '
    <p>Заказ №' . $order_id . ' получил статус "Оплачено".</p>
    <h3>Детали заказа:</h3>
    ' . $table_order . '
	' . $text . '
    <p>Ваш заказ оплачен и поступил в обработку. Вы можете следить за сменой его статуса из своего личного кабинета</p>';
    rcl_mail($email, $subject, $textmail);
    do_action('payorder_user_count_rcl', $user_id, $order->order_price, 'Оплата заказа №' . $order_id, 1);
}
function rcl_get_chart($arr = false)
{
    global $chartData;
    if (!$arr) {
        return false;
    }
    if (count($arr) == 1) {
        foreach ($arr as $month => $data) {
            for ($a = 1; $a <= $data['days']; $a++) {
                $cnt = isset($data[$a]['cnt']) ? $data[$a]['cnt'] : 0;
                $summ = isset($data[$a]['summ']) ? $data[$a]['summ'] : 0;
                $chartData['data'][] = array($a, $cnt, $summ);
            }
        }
    } else {
        for ($a = 1; $a <= 12; $a++) {
            $cnt = isset($arr[$a]['cnt']) ? $arr[$a]['cnt'] : 0;
            $summ = isset($arr[$a]['summ']) ? $arr[$a]['summ'] : 0;
            $chartData['data'][] = array($a, $cnt, $summ);
        }
    }
    if (!$chartData) {
        return false;
    }
    return rcl_get_include_template('chart.php');
}
Пример #12
0
function rcl_rating_shortcode($atts)
{
    global $rating;
    extract(shortcode_atts(array('rating_type' => false, 'days' => false, 'number' => 10, 'offset' => 0, 'order' => 'ID', 'list_type' => 'row', 'group_by' => ''), $atts));
    $rcl_rating = new Rcl_Rating();
    $ratings = $rcl_rating->get_values($atts);
    //print_r($ratings);
    $userlist = '<div class="ratinglist ' . $list_type . '-list">';
    foreach ($ratings as $rating) {
        $rating = (object) $rating;
        $userlist .= rcl_get_include_template('rating-' . $list_type . '.php', __FILE__);
    }
    $userlist .= '</div>';
    return $userlist;
}
Пример #13
0
function rcl_feed_progress()
{
    global $rcl_feed;
    $content = $_POST['content'];
    $paged = $_POST['paged'];
    include_once 'classes/class-rcl-feed.php';
    $list = new Rcl_Feed(array('paged' => $paged, 'content' => $content, 'filters' => 0));
    $count = false;
    if (!$list->number) {
        $rqst = $list->search_request();
        $search_string = $rqst ? '&' . implode('&', $rqst) : '';
        $count = $list->count_feed_posts();
        $rclnavi = new RCL_navi($list->inpage, $count, $search_string, $list->paged);
        $list->offset = $rclnavi->offset;
        $list->number = $rclnavi->inpage;
    }
    $feedsdata = $list->get_feed();
    $content = '';
    if (!$feedsdata) {
        $content .= '<p align="center">' . __('News not found', 'wp-recall') . '</p>';
        $result['content'] = $content;
        $result['code'] = 0;
        echo json_encode($result);
        exit;
    }
    foreach ($feedsdata as $rcl_feed) {
        $list->setup_data($rcl_feed);
        $content .= '<div id="feed-' . $rcl_feed->feed_type . '-' . $rcl_feed->feed_ID . '" class="feed-box feed-user-' . $rcl_feed->feed_author . ' feed-' . $rcl_feed->feed_type . '">';
        $content .= rcl_get_include_template('feed-post.php', __FILE__);
        $content .= '</div>';
    }
    $list->remove_data();
    $result['content'] = $content;
    $result['code'] = 100;
    echo json_encode($result);
    exit;
}
Пример #14
0
function get_include_template_rcl($file_temp, $path = false)
{
    _deprecated_function('get_include_template_rcl', '4.2', 'rcl_get_include_template');
    return rcl_get_include_template($file_temp, $path);
}
Пример #15
0
function rcl_get_editor_content($post_content, $type = 'editor')
{
    global $rcl_box, $formFields;
    $formFields['upload'] = false;
    if ($post_content) {
        remove_filter('the_content', 'add_button_bmk_in_content', 20);
        remove_filter('the_content', 'get_notifi_bkms', 20);
        remove_filter('the_content', 'rcl_get_edit_post_button', 999);
        $content = apply_filters('the_content', $post_content);
        if ($type == 'preview') {
            return $content;
        }
        if (isset($rcl_box)) {
        } else {
            //return '<style>.rcl-public-editor{display:none}</style>'
            //.rcl_wp_editor(array('type_editor'=>3,'media_buttons'=>0),$post_content);
            //return rcl_box_shortcode(array('type'=>'html', 'content'=>str_replace('\'','"',$post_content)));
        }
        return $content;
    } else {
        return rcl_get_include_template('editor-text-box.php', __FILE__);
    }
}
 function public_form()
 {
     global $user_ID, $formFields;
     if (!$this->can_edit) {
         return '<p align="center">' . __('You can not edit this publication :(', 'wp-recall') . '</p>';
     }
     if (!$this->user_can()) {
         if ($this->post_type == 'post-group') {
             return '<div class="public-post-group">' . '<h3 >' . __('Sorry, but you have no rights to publish within groups :(', 'wp-recall') . '</h3>' . '</div>';
         } else {
             if (!$user_ID) {
                 return '<p align="center">' . __('You must be logged in to post. Login or register', 'wp-recall') . '</p>';
             }
             return '<h3 class="aligncenter">' . __('Sorry, but you have no right<br>to publish the records on this site :(', 'wp-recall') . '</h3>';
         }
     }
     $formfields = array('title' => true, 'termlist' => true, 'editor' => true, 'excerpt' => false, 'custom_fields' => true, 'upload' => true, 'tags' => true);
     $formFields = apply_filters('fields_public_form_rcl', $formfields, $this);
     if (!$formFields['tags']) {
         remove_filter('public_form_rcl', 'rcl_add_tags_input', 10);
     }
     $form = '<div class="public_block">';
     $id_form = $this->post_id ? $this->post_id : 0;
     if (!$id_form) {
         if (!isset($_SESSION['new-' . $this->post_type])) {
             $_SESSION['new-' . $this->post_type] = 1;
             $form .= '<script>Object.keys(localStorage)
                             .forEach(function(key){
                                  if (/^form-' . $this->post_type . '-0/.test(key)) {
                                      localStorage.removeItem(key);
                                  }
                          });</script>';
         }
     }
     $id_form = 'form-' . $this->post_type . '-' . $id_form;
     $form .= '<form id="' . $id_form . '" class="';
     $form .= $this->post_id ? 'edit-form' : 'public-form';
     $form .= '" onsubmit="document.getElementById(\'edit-post-rcl\').disabled=true;document.getElementById(\'edit-post-rcl\').value=\'' . __('Being sent, please wait...', 'wp-recall') . '\';"  action="" method="post" enctype="multipart/form-data">
             ' . wp_nonce_field('edit-post-rcl', '_wpnonce', true, false);
     if (!$user_ID) {
         $form .= '<div class="rcl-form-field">
                         <label>' . __('Your Name', 'wp-recall') . ' <span class="required">*</span></label>
                         <input required type="text" value="" name="name-user">
                 </div>
                 <div class="rcl-form-field">
                         <label>' . __('Your E-mail', 'wp-recall') . ' <span class="required">*</span></label>
                         <input required type="text" value="" name="email-user">
                 </div>';
     }
     if (rcl_get_template_path($this->post_type . '-form.php', __FILE__)) {
         $form .= rcl_get_include_template($this->post_type . '-form.php', __FILE__);
     } else {
         $form .= rcl_get_include_template('public-form.php', __FILE__);
     }
     $fields = '';
     $form .= apply_filters('rcl_public_form', $fields, $this);
     $form .= $this->submit_and_hidden() . '</form>';
     $form .= '<script type="text/javascript">
                 function addfile_content($file){
                     var ifr = jQuery("#contentarea_ifr").contents().find("#tinymce").html();
                     jQuery("#contentarea").insertAtCaret($file+"&nbsp;");
                     jQuery("#contentarea_ifr").contents().find("#tinymce").html(ifr+$file+"&nbsp;");
                     return false;
                 }
             </script>';
     $after = '';
     $form .= apply_filters('after_public_form_rcl', $after, $this);
     $form .= '</div>';
     return $form;
 }
Пример #17
0
function rcl_shortcode_productlist($atts, $content = null)
{
    global $post, $wpdb, $rmag_options, $desc;
    extract(shortcode_atts(array('num' => false, 'inpage' => 10, 'type' => 'list', 'inline' => 3, 'cat' => false, 'desc' => 200, 'tag' => false, 'include' => false, 'orderby' => 'post_date', 'order' => 'DESC', 'author' => false), $atts));
    if (!$num) {
        $count_prod = $wpdb->get_var($wpdb->prepare("SELECT COUNT(ID) FROM " . $wpdb->prefix . "posts WHERE post_type='%s' AND post_status='%s'", 'products', 'publish'));
    } else {
        $count_prod = false;
        $inpage = $num;
    }
    $rclnavi = new RCL_navi($inpage, $count_prod, '&filter=' . $orderby);
    if ($cat) {
        $args = array('numberposts' => $inpage, 'offset' => $rclnavi->offset, 'orderby' => $orderby, 'order' => $order, 'author' => $author, 'post_type' => 'products', 'tag' => $tag, 'include' => $include, 'tax_query' => array(array('taxonomy' => 'prodcat', 'field' => 'id', 'terms' => explode(',', $cat))));
    } else {
        $args = array('numberposts' => $inpage, 'offset' => $rclnavi->offset, 'category' => '', 'orderby' => $orderby, 'order' => $order, 'author' => $author, 'include' => $include, 'tag' => $tag, 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'products', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish');
    }
    $products = get_posts($args);
    if (!$products) {
        return false;
    }
    $n = 0;
    $block = $type == 'rows' ? 'table' : 'div';
    $prodlist .= '<' . $block . ' class="prodlist">';
    foreach ($products as $post) {
        setup_postdata($post);
        $n++;
        $prodlist .= rcl_get_include_template('product-' . $type . '.php', __FILE__);
        if ($type == 'slab') {
            $cnt = $n % $inline;
            if ($cnt == 0) {
                $prodlist .= '<div class="clear"></div>';
            }
        }
    }
    wp_reset_query();
    $prodlist .= '</' . $block . '>';
    if (!$num) {
        $prodlist .= $rclnavi->navi();
    }
    return $prodlist;
}
Пример #18
0
function rcl_register_user_order()
{
    global $rmag_options, $wpdb, $order, $rcl_options;
    $reg_user = $rmag_options['noreg_order'] ? false : true;
    $fio_new_user = sanitize_text_field($_POST['fio_new_user']);
    $email_new_user = sanitize_email($_POST['email_new_user']);
    include_once 'rcl_order.php';
    $ord = new Rcl_Order();
    $get_fields = get_option('custom_profile_field');
    $get_order_fields = get_option('custom_orders_field');
    $req_prof = $ord->chek_requared_fields($get_fields, 'profile');
    $req_order = $ord->chek_requared_fields($get_order_fields);
    if ($email_new_user && $req_prof && $req_order) {
        $res_email = email_exists($email_new_user);
        $res_login = username_exists($email_new_user);
        $correctemail = is_email($email_new_user);
        $valid = validate_username($email_new_user);
        if (!$reg_user && (!$correctemail || !$valid)) {
            if (!$valid || !$correctemail) {
                $log['int'] = 1;
                $log['recall'] = '<p style="text-align:center;color:red;">Вы ввели некорректный email!</p>';
                echo json_encode($res);
                exit;
            }
        }
        //var_dump($reg_user);exit;
        if ($reg_user && ($res_login || $res_email || !$correctemail || !$valid)) {
            if (!$valid || !$correctemail) {
                $log['int'] = 1;
                $log['recall'] .= '<p style="text-align:center;color:red;">Вы ввели некорректный email!</p>';
            }
            if ($res_login || $res_email) {
                $log['int'] = 1;
                $log['recall'] .= '<p style="text-align:center;color:red;">Этот email уже используется!<br>' . 'Если это ваш email, то авторизуйтесь и продолжите оформление заказа.</p>';
            }
        } else {
            $user_id = false;
            if (!$reg_user) {
                $user = get_user_by('email', $email_new_user);
                if ($user) {
                    $user_id = $user->ID;
                }
            }
            if (!$user_id) {
                $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
                $userdata = array('user_pass' => $random_password, 'user_login' => $email_new_user, 'user_email' => $email_new_user, 'display_name' => $fio_new_user);
                $user_id = rcl_insert_user($userdata);
            }
            if ($user_id) {
                if ($get_fields && $user_id) {
                    $cf = new Rcl_Custom_Fields();
                    $cf->register_user_metas($user_id);
                }
                //Сразу авторизуем пользователя
                if ($reg_user && !$rcl_options['confirm_register_recall']) {
                    $creds = array();
                    $creds['user_login'] = $email_new_user;
                    $creds['user_password'] = $random_password;
                    $creds['remember'] = true;
                    $user = wp_signon($creds, false);
                    $redirect_url = rcl_format_url(get_author_posts_url($user_id), 'orders');
                } else {
                    $redirect_url = false;
                }
                $order_id = $ord->get_order_id();
                $results = $ord->insert_order($order_id, $user_id);
                if (!$results) {
                    $log['int'] = 1;
                    $log['recall'] = '<p style="text-align:center;color:red;">Возникла ошибка, заказ не был создан!</p>';
                    echo json_encode($log);
                    exit;
                }
                $order_custom_field = $ord->insert_detail_order($get_order_fields);
                $order = rcl_get_order($order_id);
                $table_order = rcl_get_include_template('order.php', __FILE__);
                $ord->send_mail($order_custom_field, $table_order, $user_id, $creds);
                $notice = $rcl_options['confirm_register_recall'] == 1 ? '<p class=res_confirm style="color:orange;">Для отслеживания статуса заказа подтвердите указанный email!<br>' . 'Перейдите по ссылке в высланном письме.</p>' : '';
                if (!$order->order_price) {
                    //Если заказ бесплатный
                    $notice .= "<p class='res_confirm'>Ваш заказ был создан!<br />" . "Заказ содержал только бесплатные товары<br>" . "Заказу присвоен статус - \"Оплачено\"<br>" . "Заказ поступил в обработку. В своем личном кабинете вы можете узнать статус вашего заказа.</p>";
                    $log['recall'] = $notice;
                    $log['redirect'] = $redirect_url;
                    $log['int'] = 100;
                    echo json_encode($log);
                    exit;
                }
                if (function_exists('rcl_payform')) {
                    $type_order_payment = $rmag_options['type_order_payment'];
                    if ($type_order_payment == 1 || $type_order_payment == 2) {
                        $notice .= "<p class='res_confirm'>Ваш заказ был создан!<br />Заказу присвоен статус - \"Неоплачено\"<br />Вы можете оплатить его сейчас или из своего ЛК. Там же вы можете узнать статус вашего заказа.</p>";
                        if ($type_order_payment == 2) {
                            $notice .= "<p class='res_confirm'>Вы можете пополнить свой личный счет на сайте из своего личного кабинета и в будущем оплачивать свои заказы через него</p>";
                        }
                        if (!$rcl_options['confirm_register_recall']) {
                            $notice .= "<p align='center'><a href='" . $redirect_url . "'>Перейти в свой личный кабинет</a></p>";
                            $notice .= rcl_payform(array('id_pay' => $order_id, 'summ' => $order->order_price, 'user_id' => $user_id, 'type' => 2));
                        }
                        $log['recall'] = $notice;
                        $log['redirect'] = 0;
                        $log['int'] = 100;
                    } else {
                        $log['int'] = 100;
                        $log['redirect'] = $redirect_url;
                        $notice .= "<p class=res_confirm>Ваш заказ был создан!<br />Проверьте свою почту.</p>";
                        $log['recall'] = $notice;
                    }
                } else {
                    $log['int'] = 100;
                    $log['redirect'] = $redirect_url;
                    $notice .= '<p class=res_confirm>Ваш заказ был создан!<br />Проверьте свою почту.</p>';
                    $log['recall'] = $notice;
                }
            }
        }
    } else {
        $log['int'] = 1;
        $log['recall'] = '<p style="text-align:center;color:red;">Пожалуйста, заполните все обязательные поля!</p>';
    }
    echo json_encode($log);
    exit;
}