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;
}
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;
}
    function get_media()
    {
        global $user_ID, $wpdb;
        $page = 1;
        if (isset($_POST['page'])) {
            $page = intval($_POST['page']);
        }
        if ($user_ID) {
            $where = $wpdb->prepare("WHERE post_author='%d' AND post_type='attachment' AND post_mime_type LIKE '%s'", $user_ID, 'image%');
            $cnt = $wpdb->get_var("SELECT COUNT(ID) FROM " . $wpdb->prefix . "posts {$where}");
            $rclnavi = new RCL_navi(20, $cnt, false, $page);
            $limit_us = $rclnavi->limit();
            $medias = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "posts {$where} ORDER BY ID DESC LIMIT {$limit_us}");
            $custom_url = '<div id="custom-image-url" style="padding: 10px;">
                                        <h3>' . __('The URL to the image', 'wp-recall') . ':</h3>
                                        <input type="text" id="custom-url" name="custom-url" value="">

                                        <input type="button" onclick="add_custom_image_url();return false;" class="recall-button" value="' . __('Insert image', 'wp-recall') . '">
                                        <script type="text/javascript">
                                            function add_custom_image_url(){
                                                var url = jQuery("#custom-url").val();
                                                var image = "<img class=alignleft src="+url+">";
                                                var ifr = jQuery("#contentarea_ifr").contents().find("#tinymce").html();
                                                jQuery("#contentarea").insertAtCaret(image+"&nbsp;");
                                                jQuery("#contentarea_ifr").contents().find("#tinymce").focus().html(ifr+image+"&nbsp;");
                                                return false;
                                            }
                                        </script>
                                    </div>';
            if ($medias) {
                $fls .= '<div id="user-media-list">';
                $fls = '<span class="close-popup"></span>
                                    ' . $custom_url . '
                                    <div id="user-medias" style="padding: 10px;">
                                        <h3>' . __('Media library user', 'wp-recall') . ':</h3>
					<ul class="media-list">';
                foreach ($medias as $m) {
                    $fls .= '<li>' . rcl_get_insert_image($m->ID) . '</li>';
                }
                $fls .= '</ul>' . '</div>';
                $fls .= $rclnavi->navi();
                $fls .= '</div>';
                $log['result'] = 100;
                $log['content'] = $fls;
            } else {
                $log['result'] = 100;
                $log['content'] = $custom_url . '<div class="clear"><h3 align="center">' . __('Images in the media library is not found!', 'wp-recall') . '</h3>
				<p class="aligncenter">' . __('Upload to your image and you will be able to use them in future from your media library.', 'wp-recall') . '</p></div>';
            }
        }
        echo json_encode($log);
        exit;
    }
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 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;
}