Exemplo n.º 1
0
    function index($params, $config)
    {
        $current_page = $current_page = 1;
        $post_params = $params;
        if (isset($post_params['id'])) {
            $paging_param = 'current_page' . crc32($post_params['id']);
            unset($post_params['id']);
        }
        $cat_from_url = url_param('category');
        $posts_parent_related = false;
        if (isset($params['current_page'])) {
            // $params['current_page'] = $params['current_page'];
        } elseif (isset($params['curent-page'])) {
            $params['current_page'] = $params['curent-page'];
        } elseif (isset($params['current-page'])) {
            $params['current_page'] = $params['current-page'];
        } elseif (isset($params['curent-page'])) {
            $params['current_page'] = $params['curent-page'];
        }
        if (isset($params['paging_param'])) {
            if (isset($params[$params['paging_param']])) {
                $current_page = $current_page = $params['current_page'] = $params[$params['paging_param']];
                $paging_param = $params['paging_param'];
            }
        }
        if (isset($params['current_page'])) {
            $current_page = $params['current_page'] = $params['current_page'];
        } else {
            $current_page_from_url = url_param($paging_param);
            if ($current_page_from_url != false) {
                $current_page = $current_page_from_url;
            }
        }
        if (isset($post_params['data-page-number'])) {
            $post_params['current_page'] = $post_params['data-page-number'];
            unset($post_params['data-page-number']);
        }
        if (isset($post_params['data-category-id'])) {
            $post_params['category'] = $post_params['data-category-id'];
            unset($post_params['data-category-id']);
        }
        if (isset($params['data-paging-param'])) {
            $paging_param = $params['data-paging-param'];
        }
        $show_fields = false;
        if (isset($post_params['data-show'])) {
            $show_fields = $post_params['data-show'];
        }
        if (isset($post_params['show'])) {
            $show_fields = $post_params['show'];
        }
        $set_content_type_from_opt = get_option('data-content-type', $params['id']);
        $show_fields1 = get_option('data-show', $params['id']);
        if ($show_fields1 != false and is_string($show_fields1) and trim($show_fields1) != '') {
            $show_fields = $show_fields1;
        }
        if ($show_fields != false and is_string($show_fields)) {
            $show_fields = explode(',', $show_fields);
        }
        if (isset($post_params['limit'])) {
            $post_params['limit'] = $post_params['limit'];
        }
        if (isset($post_params['data-limit'])) {
            $post_params['limit'] = $post_params['data-limit'];
        }
        if (!isset($post_params['data-limit'])) {
            $posts_limit = get_option('data-limit', $params['id']);
            if ($posts_limit != false) {
                $post_params['limit'] = $posts_limit;
            }
        }
        $posts_parent_category = $posts_parent_category_cfg = get_option('data-category-id', $params['id']);
        if ($posts_parent_category == '') {
            $posts_parent_category = false;
        }
        $set_category_for_posts = false;
        $posts_limit = get_option('data-limit', $params['id']);
        if ($posts_limit != false) {
            $post_params['data-limit'] = $post_params['limit'] = $posts_limit;
        }
        $cfg_page_id = $cfg_page_id_force = get_option('data-page-id', $params['id']);
        if ($cfg_page_id == false and isset($post_params['data-page-id'])) {
            $cfg_page_id = intval($post_params['data-page-id']);
        } else {
            if ($cfg_page_id == false and isset($post_params['content_id'])) {
                $cfg_page_id = intval($post_params['content_id']);
            } else {
                if ($cfg_page_id == false and isset($post_params['content-id'])) {
                    $cfg_page_id = intval($post_params['content-id']);
                } elseif ($cfg_page_id == false and isset($post_params['current_page'])) {
                    $cfg_page_id = 'current_page';
                }
            }
        }
        if ($posts_parent_category == false and isset($post_params['category_id'])) {
            $posts_parent_category = $post_params['category_id'];
        }
        if ($posts_parent_category == false and isset($post_params['related'])) {
            if (defined('CATEGORY_ID') and CATEGORY_ID > 0) {
                $posts_parent_category = $posts_parent_related = CATEGORY_ID;
            }
        }
        if ($posts_parent_category_cfg == 'related') {
            $posts_parent_related = true;
            $posts_parent_category = $posts_parent_related = CATEGORY_ID;
        }
        if ($posts_parent_category == false and $cfg_page_id == 'current_page') {
            if (defined('PAGE_ID') and PAGE_ID > 0) {
                $cfg_page_id = PAGE_ID;
            }
        }
        if ($posts_parent_category_cfg == false) {
            if (defined('CATEGORY_ID') and CATEGORY_ID > 0) {
                $posts_parent_category = CATEGORY_ID;
            }
        }
        if ($cfg_page_id == false and isset($post_params['related']) and $post_params['related'] != false and (!isset($post_params['parent']) or $post_params['parent'] == false)) {
            if (defined('PAGE_ID') and PAGE_ID > 0) {
                $cfg_page_id = PAGE_ID;
                $post_params['parent'] = $cfg_page_id;
            }
        }
        if (isset($post_params['most_ordered'])) {
            //
            $str0 = 'table=cart&limit=30&rel_type=content&fields=rel_id&order_by=id desc';
            $orders = db_get($str0);
            if (!empty($orders)) {
                $ids = array();
                foreach ($orders as $order) {
                    $ids[] = $order['rel_id'];
                }
                $post_params['ids'] = $ids;
            }
        }
        if (isset($post_params['recently_viewed'])) {
            if (defined("MAIN_PAGE_ID") and defined("CONTENT_ID")) {
                $str0 = 'table=stats_pageviews&limit=30&main_page_id=' . MAIN_PAGE_ID . '&page_id=[neq]' . CONTENT_ID . '&fields=page_id&order_by=id desc&no_cache=true';
                $orders = db_get($str0);
                if (!empty($orders)) {
                    $ids = array();
                    foreach ($orders as $order) {
                        $ids[] = $order['page_id'];
                    }
                    $post_params['ids'] = $ids;
                }
            }
        }
        if ($posts_parent_related == false) {
            if (intval($cfg_page_id_force) or !isset($params['global'])) {
                if ($cfg_page_id != false and intval($cfg_page_id) > 0) {
                    $sub_categories = array();
                    $page_categories = false;
                    if (intval($cfg_page_id) != 0 and $cat_from_url == false) {
                        $str0 = 'table=categories&limit=1000&data_type=category&what=categories&' . 'parent_id=0&rel_id=' . $cfg_page_id;
                        $page_categories = db_get($str0);
                        $str0 = 'table=categories&limit=1000&data_type=category&what=categories&' . 'parent_id=0&rel_id=' . $cfg_page_id;
                        $page_categories = db_get('table=categories&limit=1&data_type=category&' . 'parent_id=0&rel_id=' . $cfg_page_id);
                        if (is_array($page_categories)) {
                            foreach ($page_categories as $item_cat) {
                                $sub_categories[] = $item_cat['id'];
                                $more = get_category_children($item_cat['id']);
                                if ($more != false and is_array($more)) {
                                    foreach ($more as $item_more_subcat) {
                                        $sub_categories[] = $item_more_subcat;
                                    }
                                }
                            }
                        }
                    }
                    if ($posts_parent_category != false and intval($posts_parent_category) > 0 and $cat_from_url == false) {
                        if ($page_categories != false and is_array($page_categories) and !empty($page_categories)) {
                            // $sub_categories = array();
                            foreach ($page_categories as $item_cat) {
                                if (intval($item_cat['id']) == intval($posts_parent_category)) {
                                    $sub_categories[] = $item_cat['id'];
                                }
                            }
                        } elseif ($posts_parent_category_cfg != false) {
                            $post_params['category'] = $posts_parent_category_cfg;
                        }
                        if (is_array($sub_categories) and !empty($sub_categories) and isset($post_params['related']) and $post_params['related'] != false) {
                            $post_params['category'] = $sub_categories;
                        } elseif ($cfg_page_id != false) {
                            $post_params['parent'] = $cfg_page_id;
                        }
                    } else {
                        $post_params['parent'] = $cfg_page_id;
                        if (($cfg_page_id == PAGE_ID or $cfg_page_id == MAIN_PAGE_ID) and (!isset($post_params['category']) or $post_params['category'] == false) and $cat_from_url != false) {
                            $post_params['category'] = $cat_from_url;
                        }
                    }
                } elseif ($cat_from_url != false) {
                    $post_params['category'] = $cat_from_url;
                } elseif ($posts_parent_category != false and intval($posts_parent_category) > 0 and $cfg_page_id != false) {
                    $post_params['category'] = $posts_parent_category;
                }
            }
            if ($posts_parent_category_cfg != false and intval($posts_parent_category_cfg) > 0 and $cfg_page_id_force != false and intval($cfg_page_id_force) > 0) {
                $post_params['category'] = $posts_parent_category_cfg;
            }
        } else {
            $post_params['category'] = $posts_parent_related;
        }
        $tn_size = array('150');
        $tn = $tn_size;
        if (isset($post_params['data-thumbnail-size'])) {
            $temp = explode('x', strtolower($post_params['data-thumbnail-size']));
            if (!empty($temp)) {
                $tn_size = $temp;
            }
        } else {
            $cfg_page_item = get_option('data-thumbnail-size', $params['id']);
            if ($cfg_page_item != false) {
                $temp = explode('x', strtolower($cfg_page_item));
                if (!empty($temp)) {
                    $tn_size = $temp;
                }
            }
        }
        if (!isset($tn[0]) or $tn[0] == 150) {
            $tn[0] = 350;
        }
        if (!isset($tn[1])) {
            $tn[1] = $tn[0];
        }
        $character_limit = 120;
        $cfg_character_limit = get_option('data-character-limit', $params['id']);
        if ($cfg_character_limit != false and trim($cfg_character_limit) != '') {
            $character_limit = intval($cfg_character_limit);
        } else {
            if (isset($params['description-length'])) {
                $character_limit = intval($params['description-length']);
            }
        }
        $title_character_limit = 200;
        $cfg_character_limit1 = get_option('data-title-limit', $params['id']);
        if ($cfg_character_limit1 != false and trim($cfg_character_limit1) != '') {
            $title_character_limit = intval($cfg_character_limit1);
        } else {
            if (isset($params['title-length'])) {
                $title_character_limit = intval($params['title-length']);
            }
        }
        if ($show_fields == false) {
            //$show_fields = array('thumbnail', 'title', 'description', 'read_more');
        }
        if (is_array($show_fields)) {
            $show_fields = array_trim($show_fields);
        }
        if (isset($current_page) and intval($current_page) > 0) {
            $post_params['current_page'] = intval($current_page);
        }
        if (!isset($post_params['global'])) {
            if (!isset($post_params['content_type'])) {
                $post_params['content_type'] = 'post';
            }
        }
        if (isset($params['is_shop'])) {
            $post_params['content_type'] = 'product';
            unset($post_params['is_shop']);
        }
        if (!isset($post_params['content_type']) and !isset($post_params['global'])) {
            $post_params['content_type'] = 'post';
        }
        if (!isset($params['order_by']) and isset($params['order-by'])) {
            $params['orderby'] = $post_params['orderby'] = $params['order-by'];
        }
        if (isset($params['subtype_value'])) {
            $post_params['subtype_value'] = $params['subtype_value'];
        }
        $schema_org_item_type = false;
        $schema_org_item_type_tag = false;
        if (isset($post_params['content_type']) and $post_params['content_type'] == 'page') {
            $schema_org_item_type = 'WebPage';
        } else {
            if (isset($post_params['content_type']) and $post_params['content_type'] == 'post') {
                if (isset($post_params['subtype']) and $post_params['subtype'] != $post_params['content_type']) {
                    $schema_org_item_type = $post_params['subtype'];
                } else {
                    $schema_org_item_type = 'Article';
                }
            }
        }
        if ($schema_org_item_type != false) {
            $schema_org_item_type = ucfirst($schema_org_item_type);
            $schema_org_item_type_tag = ' itemtype="http://schema.org/' . $schema_org_item_type . '" ';
            $schema_org_item_type_tag = 'http://schema.org/' . $schema_org_item_type;
        }
        $ord_by = get_option('data-order-by', $params['id']);
        if ($ord_by != false and trim($ord_by) != '') {
            $post_params['orderby'] = $ord_by;
        }
        $date_format = get_option('date_format', 'website');
        if ($date_format == false) {
            $date_format = "Y-m-d H:i:s";
        }
        if (isset($params['title'])) {
            unset($post_params['title']);
        }
        $post_params['is_active'] = 1;
        $post_params['is_deleted'] = 0;
        if ((!isset($post_params['parent']) and !isset($post_params['category']) or isset($post_params['category']) and empty($post_params['category'])) and $cat_from_url != false and trim($cat_from_url) != '') {
            $post_params['category'] = $cat_from_url;
        }
        if (isset($params['content_type']) and $params['content_type'] == 'all') {
            unset($post_params['content_type']);
            unset($post_params['subtype']);
        }
        if (isset($params['search-parent'])) {
            $sub_content = get_content_children($params['search-parent']);
            if (!empty($sub_content)) {
                $post_params['ids'] = $sub_content;
                unset($post_params['parent']);
            }
        }
        if (isset($params['data-id'])) {
            unset($post_params['data-id']);
        }
        if ($posts_parent_related == false) {
            if (isset($post_params['category']) and is_string($post_params['category'])) {
                $sub_categories = array();
                $sub_categories[] = $post_params['category'];
                $more = get_category_children($post_params['category']);
                if ($more != false and is_array($more)) {
                    foreach ($more as $item_more_subcat) {
                        $sub_categories[] = $item_more_subcat;
                    }
                }
                //$post_params['category']
                $post_params['category'] = $sub_categories;
                //$post_params['category'] = $post_params['category'];
            } else {
                if (isset($post_params['category']) and is_array($post_params['category']) and empty($post_params['category']) and isset($post_params['related']) and $post_params['related'] != false) {
                    if (defined('CATEGORY_ID') and CATEGORY_ID > 0) {
                        $post_params['category'] = CATEGORY_ID;
                    }
                }
            }
        }
        if (defined('POST_ID') and isset($posts_parent_category) and $posts_parent_category != false or isset($post_params['related'])) {
            $post_params['exclude_ids'] = POST_ID;
        }
        if (!isset($params['order_by'])) {
            //            if(isset($post_params['content_type']) and $post_params['content_type'] == 'page'){
            //                $post_params['order_by'] = 'position asc';
            //            } else {
            //
            //            }
            $post_params['order_by'] = 'position desc';
        }
        if (isset($params['search_in_fields']) and $params['search_in_fields'] != false) {
            $post_params['search_in_fields'] = $params['search_in_fields'];
        }
        $content = get_content($post_params);
        if ($posts_parent_related != false and empty($content) and isset($post_params['category'])) {
            unset($post_params['category']);
            $content = get_content($post_params);
        }
        $data = array();
        if (!empty($content)) {
            foreach ($content as $item) {
                $iu = get_picture($item['id'], $for = 'post', $full = false);
                if ($iu != false) {
                    $item['image'] = $iu;
                } else {
                    $item['image'] = false;
                }
                if ($item['image'] != false) {
                    $item['tn_image'] = thumbnail($item['image'], $tn[0], $tn[1]);
                } else {
                    $item['tn_image'] = false;
                }
                $item['content'] = htmlspecialchars_decode($item['content']);
                if (isset($item['created_at']) and trim($item['created_at']) != '') {
                    $item['created_at'] = date($date_format, strtotime($item['created_at']));
                }
                if (isset($item['updated_at']) and trim($item['updated_at']) != '') {
                    $item['updated_at'] = date($date_format, strtotime($item['updated_at']));
                }
                $item['link'] = content_link($item['id']);
                $item['full_description'] = '';
                if (!isset($item['description']) or $item['description'] == '') {
                    if (isset($item['content']) and $item['content'] != '') {
                        $item['description'] = character_limiter(strip_tags($item['content']), $character_limit);
                        $item['full_description'] = strip_tags($item['content']);
                    } elseif (isset($item['content_body']) and $item['content_body'] != '') {
                        $item['full_description'] = strip_tags($item['content']);
                        $item['description'] = character_limiter(strip_tags($item['content_body']), $character_limit);
                    }
                } else {
                    $item['full_description'] = trim($item['description']);
                    $item['description'] = character_limiter(strip_tags($item['description']), $character_limit);
                }
                if (isset($item['title']) and $item['title'] != '') {
                    $item['full_title'] = $item['title'];
                    $item['title'] = character_limiter($item['title'], $title_character_limit);
                }
                if (isset($post_params['content_type']) and $post_params['content_type'] == 'product') {
                    $item['prices'] = get_custom_fields("field_type=price&for=content&for_id=" . $item['id']);
                } else {
                    $item['prices'] = false;
                }
                if (isset($item['prices']) and is_array($item['prices']) and !empty($item['prices'])) {
                    $vals2 = array_values($item['prices']);
                    $val1 = array_shift($vals2);
                    $item['price'] = $val1;
                } else {
                    $item['price'] = false;
                }
                if (isset($show_fields) and is_array($show_fields) and !empty($show_fields)) {
                    if (!in_array('title', $show_fields)) {
                        $item['title'] = false;
                    }
                    if (!in_array('description', $show_fields)) {
                        $item['description'] = false;
                    }
                    if (!in_array('created_at', $show_fields)) {
                        $item['created_at'] = false;
                    }
                    if (!in_array('read_more', $show_fields)) {
                        $item['read_more'] = false;
                    }
                    if (!in_array('thumbnail', $show_fields)) {
                        $item['thumbnail'] = false;
                    }
                }
                $data[] = $item;
            }
        } else {
            if (isset($params['is_shop'])) {
                print lnotif('Your products module is empty');
            } elseif (isset($params['global'])) {
                print lnotif('Your content module is empty');
            } else {
                print lnotif('Your posts module is empty');
            }
        }
        $post_params_paging = $post_params;
        $post_params_paging['page_count'] = true;
        $cfg_data_hide_paging = get_option('data-hide-paging', $params['id']);
        if ($cfg_data_hide_paging === false) {
            if (isset($post_params['hide_paging']) and trim($post_params['hide_paging']) != 'false') {
                $post_params['hide-paging'] = $post_params['hide_paging'];
                unset($post_params['hide_paging']);
            }
            if (isset($post_params['hide-paging']) and trim($post_params['hide-paging']) != 'false') {
                $cfg_data_hide_paging = 'y';
                unset($post_params['hide-paging']);
            }
        }
        if ($cfg_data_hide_paging != 'y') {
            $pages_of_posts = get_content($post_params_paging);
            $pages_count = intval($pages_of_posts);
        } else {
            $pages_count = 0;
        }
        $paging_links = false;
        if (intval($pages_count) > 1) {
            //$paging_links = mw()->content_manager->paging_links(false, $pages_count, $paging_param, $keyword_param = 'keyword');
        }
        $read_more_text = get_option('data-read-more-text', $params['id']);
        $add_cart_text = get_option('data-add-to-cart-text', $params['id']);
        if ($add_cart_text == false or $add_cart_text == "Add to cart") {
            $add_cart_text = _e("Add to cart", true);
        }
        if (!isset($params['return'])) {
            $module_template = get_option('data-template', $params['id']);
            if ($module_template == false and isset($params['template'])) {
                $module_template = $params['template'];
            }
            if ($module_template != false) {
                if (strtolower($module_template) == 'none') {
                    if (isset($params['template'])) {
                        $module_template = $params['template'];
                    }
                }
                $template_file = module_templates($config['module'], $module_template);
            } else {
                $template_file = module_templates($config['module'], 'default');
            }
            if ($template_file == false) {
                $template_file = module_templates($config['module'], 'default');
            }
            if (isset($template_file) and is_file($template_file) != false) {
                include $template_file;
                ?>
                <?php 
                if (isset($params['ajax_paging']) or isset($params['ajax-paging'])) {
                    ?>
                    <script type="text/javascript">
                        $(document).ready(function () {
                            mw.$('#<?php 
                    print $params['id'];
                    ?>
').find('a[data-page-number]').unbind('click');
                            mw.$('#<?php 
                    print $params['id'];
                    ?>
').find('a[data-page-number]').click(function (e) {
                                var pn = $(this).attr('data-page-number');
                                mw.$('#<?php 
                    print $params['id'];
                    ?>
').attr('paging_param', 'current_page');
                                mw.$('#<?php 
                    print $params['id'];
                    ?>
').attr('current_page', pn)
                                mw.reload_module('#<?php 
                    print $params['id'];
                    ?>
');
                                return false;
                            });
                        });
                    </script>
                <?php 
                }
                ?>
                <?php 
                if (isset($params['is_shop'])) {
                    ?>
                    <script type="text/javascript">
                        mw.require("shop.js");
                    </script>
                <?php 
                }
                ?>
            <?php 
            } else {
                print lnotif('No default template for ' . $config['module'] . ' is found');
            }
        }
    }
Exemplo n.º 2
0
 public function copy($data)
 {
     $new_cont_id = false;
     if (defined('MW_API_CALL')) {
         $to_trash = true;
         $adm = $this->app->user_manager->is_admin();
         if ($adm == false) {
             return array('error' => 'You must be admin to copy content!');
         }
     }
     if (isset($data['id'])) {
         $this->app->event_manager->trigger('content.before.copy', $data);
         $cont = get_content_by_id($data['id']);
         if ($cont != false and isset($cont['id'])) {
             $new_cont = $cont;
             if (isset($new_cont['title'])) {
                 $new_cont['title'] = $new_cont['title'] . ' copy';
             }
             $new_cont['id'] = 0;
             $content_cats = array();
             $cats = content_categories($cont['id']);
             if (!empty($cats)) {
                 foreach ($cats as $cat) {
                     if (isset($cat['id'])) {
                         $content_cats[] = $cat['id'];
                     }
                 }
             }
             if (!empty($content_cats)) {
                 $new_cont['categories'] = $content_cats;
             }
             $new_cont_id = $this->save($new_cont);
             $cust_fields = get_custom_fields('content', $data['id'], true);
             if (!empty($cust_fields)) {
                 foreach ($cust_fields as $cust_field) {
                     $new = $cust_field;
                     $new['id'] = 0;
                     $new['rel_id'] = $new_cont_id;
                     $new_item = save_custom_field($new);
                 }
             }
             $images = get_pictures($data['id']);
             if (!empty($images)) {
                 foreach ($images as $image) {
                     $new = $image;
                     $new['id'] = 0;
                     $new['rel_id'] = $new_cont_id;
                     $new['rel_type'] = 'content';
                     $new_item = save_media($new);
                 }
             }
         }
     }
     return $new_cont_id;
 }
Exemplo n.º 3
0
function get_user_info_func($xmlrpc_params)
{
    global $db, $user, $auth, $template, $config, $phpbb_root_path, $phpEx, $table_prefix;
    $user->setup(array('memberlist', 'groups'));
    if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
        if ($user->data['user_id'] != ANONYMOUS) {
            trigger_error('NO_VIEW_USERS');
        }
        trigger_error('LOGIN_EXPLAIN_VIEWPROFILE');
    }
    $params = php_xmlrpc_decode($xmlrpc_params);
    $username = $params[0];
    if (isset($params[1]) && !empty($params[1])) {
        $user_id = $params[1];
    } elseif (isset($params[0]) && !empty($params[0])) {
        $username = $params[0];
        $user_id = get_user_id_by_name($username);
    } else {
        $user_id = $user->data['user_id'];
    }
    $user_id = intval($user_id);
    // Display a profile
    if (!$user_id) {
        trigger_error('NO_USER');
    }
    // Get user...
    $sql = 'SELECT *
        FROM ' . USERS_TABLE . "\r\r\n        WHERE user_id = '{$user_id}'";
    $result = $db->sql_query($sql);
    $member = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if (!$member) {
        trigger_error('NO_USER');
    }
    // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
    // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
    if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER) {
        if ($member['user_type'] == USER_IGNORE) {
            trigger_error('NO_USER');
        } else {
            if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE) {
                trigger_error('NO_USER');
            }
        }
    }
    $user_id = (int) $member['user_id'];
    // Do the SQL thang
    $sql = 'SELECT g.group_id, g.group_name, g.group_type
        FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\r\r\n        WHERE ug.user_id = {$user_id}\r\r\n            AND g.group_id = ug.group_id" . (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
            AND ug.user_pending = 0
        ORDER BY g.group_type, g.group_name';
    $result = $db->sql_query($sql);
    $group_options = '';
    while ($row = $db->sql_fetchrow($result)) {
        if ($row['group_type'] == GROUP_SPECIAL) {
            // Lookup group name in language dictionary
            if (isset($user->lang['G_' . $row['group_name']])) {
                $row['group_name'] = $user->lang['G_' . $row['group_name']];
            }
        } else {
            if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) {
                // Skip over hidden groups the user cannot see
                continue;
            }
        }
        $group_options .= $row['group_id'] == $member['group_id'] ? $row['group_name'] . " *\n" : $row['group_name'] . "\n";
    }
    $group_options = trim($group_options);
    $db->sql_freeresult($result);
    // What colour is the zebra
    $sql = 'SELECT friend, foe
        FROM ' . ZEBRA_TABLE . "\r\r\n        WHERE zebra_id = {$user_id}\r\r\n            AND user_id = {$user->data['user_id']}";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $foe = $row['foe'] ? true : false;
    $friend = $row['friend'] ? true : false;
    $db->sql_freeresult($result);
    if ($config['load_onlinetrack']) {
        if ($config['version'] < '3.0.3') {
            $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page
            FROM ' . SESSIONS_TABLE . "\r\r\n            WHERE session_user_id = {$user_id}\r\r\n            GROUP BY session_page\r\r\n            ORDER BY session_time DESC";
        } else {
            $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page, session_forum_id
            FROM ' . SESSIONS_TABLE . "\r\r\n            WHERE session_user_id = {$user_id}\r\r\n            GROUP BY session_page, session_forum_id\r\r\n            ORDER BY session_time DESC";
        }
        $result = $db->sql_query_limit($sql, 1);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $member['session_time'] = isset($row['session_time']) ? $row['session_time'] : 0;
        $member['session_viewonline'] = isset($row['session_viewonline']) ? $row['session_viewonline'] : 0;
        $member['session_page'] = isset($row['session_page']) ? $row['session_page'] : 0;
        $member['session_forum_id'] = isset($row['session_forum_id']) ? $row['session_forum_id'] : 0;
        unset($row);
    }
    if ($config['load_user_activity']) {
        display_user_activity($member);
    }
    // Do the relevant calculations
    $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
    $posts_per_day = $member['user_posts'] / $memberdays;
    $percentage = $config['num_posts'] ? min(100, $member['user_posts'] / $config['num_posts'] * 100) : 0;
    if ($member['user_sig']) {
        $member['user_sig'] = censor_text($member['user_sig']);
        if ($member['user_sig_bbcode_bitfield']) {
            include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
            $bbcode = new bbcode();
            $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
        }
        $member['user_sig'] = bbcode_nl2br($member['user_sig']);
        $member['user_sig'] = smiley_text($member['user_sig']);
    }
    $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
    // We need to check if the modules 'zebra' ('friends' & 'foes' mode),  'notes' ('user_notes' mode) and  'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links
    $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false;
    // Only check if the user is logged in
    if ($user->data['is_registered']) {
        if (!class_exists('p_master')) {
            include $phpbb_root_path . 'includes/functions_module.' . $phpEx;
        }
        $module = new p_master();
        $module->list_modules('ucp');
        $module->list_modules('mcp');
        $user_notes_enabled = $module->loaded('notes', 'user_notes') ? true : false;
        $warn_user_enabled = $module->loaded('warn', 'warn_user') ? true : false;
        $zebra_enabled = $module->loaded('zebra') ? true : false;
        $friends_enabled = $module->loaded('zebra', 'friends') ? true : false;
        $foes_enabled = $module->loaded('zebra', 'foes') ? true : false;
        unset($module);
    }
    $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));
    // Custom Profile Fields
    $profile_fields = array();
    if ($config['load_cpf_viewprofile']) {
        include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
        $cp = new custom_profile();
        $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
        $profile_fields = isset($profile_fields[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
    }
    // If the user has m_approve permission or a_user permission, then list then display unapproved posts
    if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) {
        $sql = 'SELECT COUNT(post_id) as posts_in_queue
            FROM ' . POSTS_TABLE . '
            WHERE poster_id = ' . $user_id . '
                AND post_approved = 0';
        $result = $db->sql_query($sql);
        $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
        $db->sql_freeresult($result);
    } else {
        $member['posts_in_queue'] = 0;
    }
    $template->assign_vars(array('OCCUPATION' => !empty($member['user_occ']) ? censor_text($member['user_occ']) : '', 'INTERESTS' => !empty($member['user_interests']) ? censor_text($member['user_interests']) : '', 'SIGNATURE' => $member['user_sig'], 'POSTS_IN_QUEUE' => $member['posts_in_queue'], 'AVATAR_IMG' => $poster_avatar, 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=group'), 'S_GROUP_OPTIONS' => $group_options, 'S_CUSTOM_FIELDS' => isset($profile_fields['row']) && sizeof($profile_fields['row']) ? true : false, 'U_USER_ADMIN' => $auth->acl_get('a_user') ? append_sid("{$phpbb_root_path}adm/index.{$phpEx}", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '', 'U_USER_BAN' => $auth->acl_get('m_ban') && $user_id != $user->data['user_id'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '', 'U_MCP_QUEUE' => $auth->acl_getf_global('m_approve') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue', true, $user->session_id) : '', 'S_USER_NOTES' => $user_notes_enabled ? true : false, 'S_WARN_USER' => $warn_user_enabled ? true : false, 'S_ZEBRA' => $user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled ? true : false, 'U_ADD_FRIEND' => !$friend && !$foe && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_ADD_FOE' => !$friend && !$foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_REMOVE_FRIEND' => $friend && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '', 'U_REMOVE_FOE' => $foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : ''));
    if (!empty($profile_fields['row'])) {
        $template->assign_vars($profile_fields['row']);
    }
    if (!empty($profile_fields['blockrow'])) {
        foreach ($profile_fields['blockrow'] as $field_data) {
            $template->assign_block_vars('custom_fields', $field_data);
        }
    }
    // Inactive reason/account?
    if ($member['user_type'] == USER_INACTIVE) {
        $user->add_lang('acp/common');
        $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
        switch ($member['user_inactive_reason']) {
            case INACTIVE_REGISTER:
                $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
                break;
            case INACTIVE_PROFILE:
                $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
                break;
            case INACTIVE_MANUAL:
                $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
                break;
            case INACTIVE_REMIND:
                $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
                break;
        }
        $template->assign_vars(array('S_USER_INACTIVE' => true, 'USER_INACTIVE_REASON' => $inactive_reason));
    }
    $custom_fields_list = get_custom_fields();
    if (!empty($member['user_sig'])) {
        $custom_fields_list[] = new xmlrpcval(array('name' => new xmlrpcval($user->lang['SIGNATURE'], 'base64'), 'value' => new xmlrpcval(basic_clean($member['user_sig']), 'base64')), 'struct');
    }
    if ($member['user_id'] == $user->data['user_id'] && push_table_exists()) {
        $sql = "SELECT * FROM " . $table_prefix . "tapatalk_users WHERE userid = '" . $member['user_id'] . "'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        if (!empty($row)) {
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Message', 'base64'), 'value' => new xmlrpcval($row['pm'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Quoted', 'base64'), 'value' => new xmlrpcval($row['quote'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Mentioned', 'base64'), 'value' => new xmlrpcval($row['tag'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - New Topic', 'base64'), 'value' => new xmlrpcval($row['newtopic'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Replies', 'base64'), 'value' => new xmlrpcval($row['subscribe'] ? 'On' : 'Off', 'base64')), 'struct'));
        }
    }
    $user_avatar_url = get_user_avatar_url($member['user_avatar'], $member['user_avatar_type']);
    // Forum info
    $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
        FROM ' . FORUMS_TABLE . '
        ORDER BY left_id ASC';
    $result = $db->sql_query($sql, 600);
    $forum_data = array();
    while ($row = $db->sql_fetchrow($result)) {
        $forum_data[$row['forum_id']] = $row;
    }
    $db->sql_freeresult($result);
    // get user current activity
    preg_match('#^([a-z0-9/_-]+)#i', $member['session_page'], $on_page);
    if (!sizeof($on_page)) {
        $on_page[1] = '';
    }
    switch ($on_page[1]) {
        case 'index':
            $location = $user->lang['INDEX'];
            break;
        case 'adm/index':
            $location = $user->lang['ACP'];
            break;
        case 'posting':
        case 'viewforum':
        case 'viewtopic':
            $forum_id = $member['session_forum_id'];
            if ($forum_id && $auth->acl_get('f_list', $forum_id)) {
                $location = '';
                if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) {
                    $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']);
                    break;
                }
                switch ($on_page[1]) {
                    case 'posting':
                        preg_match('#mode=([a-z]+)#', $member['session_page'], $on_page);
                        $posting_mode = !empty($on_page[1]) ? $on_page[1] : '';
                        switch ($posting_mode) {
                            case 'reply':
                            case 'quote':
                                $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
                                break;
                            default:
                                $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
                                break;
                        }
                        break;
                    case 'viewtopic':
                        $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']);
                        break;
                    case 'viewforum':
                        $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']);
                        break;
                }
            } else {
                $location = $user->lang['INDEX'];
            }
            break;
        case 'search':
            $location = $user->lang['SEARCHING_FORUMS'];
            break;
        case 'faq':
            $location = $user->lang['VIEWING_FAQ'];
            break;
        case 'viewonline':
            $location = $user->lang['VIEWING_ONLINE'];
            break;
        case 'memberlist':
            $location = strpos($member['session_page'], 'mode=viewprofile') !== false ? $user->lang['VIEWING_MEMBER_PROFILE'] : $user->lang['VIEWING_MEMBERS'];
            break;
        case 'mcp':
            $location = $user->lang['VIEWING_MCP'];
            break;
        case 'ucp':
            $location = $user->lang['VIEWING_UCP'];
            // Grab some common modules
            $url_params = array('mode=register' => 'VIEWING_REGISTER', 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', 'i=profile&' => 'CHANGING_PROFILE', 'i=prefs&' => 'CHANGING_PREFERENCES');
            foreach ($url_params as $param => $lang) {
                if (strpos($member['session_page'], $param) !== false) {
                    $location = $user->lang[$lang];
                    break;
                }
            }
            break;
        case 'download/file':
            $location = $user->lang['DOWNLOADING_FILE'];
            break;
        case 'report':
            $location = $user->lang['REPORTING_POST'];
            break;
        case 'mobiquo/mobiquo':
            $location = 'On Tapatalk';
            break;
        default:
            $location = $user->lang['INDEX'];
            break;
    }
    $user_info = array('user_id' => new xmlrpcval($member['user_id']), 'username' => new xmlrpcval(basic_clean($member['username']), 'base64'), 'user_type' => check_return_user_type($member['username']), 'post_count' => new xmlrpcval($member['user_posts'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_iso8601_encode($member['user_regdate']), 'dateTime.iso8601'), 'timestamp_reg' => new xmlrpcval($member['user_regdate'], 'string'), 'last_activity_time' => new xmlrpcval(mobiquo_iso8601_encode($template->_rootref['VISITED']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($template->_rootref['VISITED'], 'string'), 'is_online' => new xmlrpcval($template->_rootref['S_ONLINE'], 'boolean'), 'accept_pm' => new xmlrpcval($template->_rootref['U_PM'] ? true : false, 'boolean'), 'display_text' => new xmlrpcval('', 'base64'), 'icon_url' => new xmlrpcval($user_avatar_url), 'current_activity' => new xmlrpcval($location, 'base64'), 'custom_fields_list' => new xmlrpcval($custom_fields_list, 'array'));
    $xmlrpc_user_info = new xmlrpcval($user_info, 'struct');
    return new xmlrpcresp($xmlrpc_user_info);
}
Exemplo n.º 4
0
function product_edit($event, $step, $message = '')
{
    global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs;
    extract($prefs);
    define("IMPATH", $path_to_site . '/' . $img_dir . '/');
    extract(gpsa(array('view', 'from_view', 'step')));
    if (!empty($GLOBALS['ID'])) {
        // newly-saved article
        $ID = $GLOBALS['ID'];
        $step = 'edit';
    } else {
        $ID = gps('ID');
    }
    //GET ARTICLE DATA FOR 'EDIT' & 'SAVE' STEP
    //==================================
    if ($step == "edit" || $step == "save" && !empty($ID)) {
        $pull = true;
        //-- it's an existing article - off we go to the db
        $ID = assert_int($ID);
        $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}");
        extract($rs);
        if ($AnnotateInvite != $comments_default_invite) {
            $AnnotateInvite = $AnnotateInvite;
        } else {
            $AnnotateInvite = $comments_default_invite;
        }
        $custom_fields = safe_rows("*", "product_custom_fields", "articleID = {$ID} ORDER BY id DESC");
        $step = "save";
        //print_r($rs);
    } else {
        if (empty($step)) {
            $step = "create";
        }
    }
    $textile = new Textile();
    $textile_body = $use_textile;
    $textile_excerpt = $use_textile;
    $page_title = "Add a new product";
    $message = "";
    pagetop($page_title, $message);
    if (count($custom_fields) > 0) {
        $startFieldNum = $custom_fields[0]['id'] + 1;
    } else {
        $startFieldNum = 0;
    }
    //JS INCLUDES
    //==================================
    //print_r($prefs);
    echo '<script type="text/javascript" src="http://' . $siteurl . '/js/prototype.js"></script>';
    echo '<script type="text/javascript" src="http://' . $siteurl . '/js/scriptaculous.js"></script>';
    //CSS FOR PRODUCT DISPLAY
    //==================================
    echo n . '<style type="text/css">' . n . 'h4.productHeading{' . n . '	color:gray;' . n . '	margin-bottom:0px;' . n . '}' . n . 'h4.productHeading span{' . n . '	float:right;' . n . '	font-size:9px;' . n . '	font-style:italic;' . n . '	font-weight:normal;' . n . '}' . n . '.product-options-sub{' . n . '	padding: 10px;' . n . '}' . n . '.product-options-sub em{' . n . '	color:gray;' . n . '}' . n . '.product-options-sub legend{' . n . '	font-size:11px;' . n . '}' . n . '.product-options-sub label{' . n . '	font-size:11px;' . n . '	padding-bottom: 5px;' . n . '}' . n . '#images ul.plain-list li{' . n . '	float:left;' . n . '	margin-right:10px;' . n . '	margin-bottom:10px;' . n . '	width:375px;' . n . '}' . n . '#images ul.plain-list li img{' . n . '	border-width: 1px;' . n . '	border-color:#BBBBBB;' . n . '	border-style:solid;' . n . '	padding:3px;' . n . '	background-color: #E0E0E0;' . n . '	float:left;' . n . '}' . n . '#images ul.plain-list li .imageEdit{' . n . '	background-color:#E0E0E0;' . n . '	height: 15px;' . n . '	width: 250px;' . n . '	text-align:left;' . n . '	padding:3px 3px 3px 110px;' . n . '	margin-top:0px;' . n . '}' . n . '#images ul.plain-list li .imageUpload{' . n . '	margin-top: 5px;' . n . '	padding:3px;' . n . '	width: 275px;' . n . '	border-width: 1px;' . n . '	border-color:#E0E0E0;' . n . '	border-style:solid;' . n . '}' . n . '</style>';
    echo n . '<script type="text/javascript">' . n . ' <!--' . n . '	fieldNum = ' . $startFieldNum . ';' . n . '	function addCustomField(index){' . n . '		//$("custom_fields").innerHTML = $("custom_fields").innerHTML + getCustomField(fieldNum);' . n . '		$("custom_fields").appendChild(getCustomField(fieldNum))' . n . '		fieldNum = fieldNum+1;' . n . '	}' . n . '	function deleteCustomField(index){' . n . '		if(confirm("Are you sure?")){' . n . '		$("custom_field_"+index).style.display = "none";' . n . '		$("custom_fields["+index+"][value]").value = "delete";' . n . '		$("custom_fields["+index+"][label]").value = "delete";' . n . '		}else{ return false; }' . n . '	}' . n . '	function getCustomField(index){' . n . '		var span = document.createElement("span");' . n . '		span.setAttribute("id","custom_field_"+index);' . n . '		var label = document.createElement("label");' . n . '		label.setAttribute("for","custom_fields["+index+"][label]");' . n . '		labelText = document.createTextNode("Label ");' . n . '		var input = document.createElement("input");' . n . '		input.setAttribute("id","custom_fields["+index+"][label]");' . n . '		input.setAttribute("name","custom_fields["+index+"][label]");' . n . '		var labelValue = document.createElement("label");' . n . '		labelValue.setAttribute("for","custom_fields["+index+"][value]");' . n . '		labelTextValue = document.createTextNode(" Value ");' . n . '		var inputValue = document.createElement("input");' . n . '		inputValue.setAttribute("id","custom_fields["+index+"][value]");' . n . '		inputValue.setAttribute("name","custom_fields["+index+"][value]");' . n . '		var deleteLink = document.createElement("a");' . n . '		deleteLink.setAttribute("href","javascript:void(0)");' . n . '		deleteLink.setAttribute("onclick","deleteCustomField("+index+");");' . n . '		deleteLink.setAttribute("style","font-size: 11px;");' . n . '		deleteText = document.createTextNode("Delete");' . n . '		label.appendChild(labelText);' . n . '		span.appendChild(label);' . n . '		span.appendChild(input);' . n . '		labelValue.appendChild(labelTextValue);' . n . '		span.appendChild(labelValue);' . n . '		span.appendChild(inputValue);' . n . '		deleteLink.appendChild(deleteText);' . n . '		span.appendChild(deleteLink);' . n . '		span.appendChild(document.createElement("br"));' . n . '		span.appendChild(document.createElement("br"));' . n . '		return span;' . n . '	}' . n . '//-->' . n . '</script>';
    echo n . n . '<form name="product" method="post" action="index.php" enctype="multipart/form-data">';
    echo '<input type="hidden" name="textile_body" value="1"/>';
    echo '<input type="hidden" name="textile_excerpt" value="1"/>';
    echo '<input type="hidden" name="Section" value="store"/>';
    echo hInput('ID', $ID) . eInput('product') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n;
    //if ($view == 'text')
    //{
    //-- markup help --------------
    echo '<td id="article-main">';
    echo "<h4 class='productHeading'>Product name</h4>";
    echo '<p><input type="text" id="title" name="Title" value="' . cleanfInput($Title) . '" class="edit" size="40" tabindex="1" />';
    if (($Status == 4 or $Status == 5) and $step != 'create') {
        include_once txpath . '/publish/taghandlers.php';
        echo sp . sp . '<a href="' . permlinkurl_id($ID) . '">' . gTxt('view') . '</a>';
    }
    echo '</p>';
    echo "<h4 class='productHeading'><span>Textile &amp; HTML allowed</span> Describe the product</h4>";
    echo n . graf('<textarea id="body" name="Body" cols="55" rows="31" tabindex="2" style="height: 180px;">' . htmlspecialchars($Body) . '</textarea>');
    //PRODUCT OPTIONS
    //================================
    //echo '<div id="productOptions" style="border-width:1px; border-color:#E1E1E1; border-style:solid; padding:5px; background-color:#F3F4F4;">';
    //PRODUCT & PRICE
    //================================
    echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . '<div style="float:left; margin-right: 40px;">' . n . graf('<label for="price">Price</label> ' . br . n . '<input style="width: 50px;" type="text" name="custom_1" id="price" value="' . cleanfInput($custom_1) . '"/> <em>usd</em>') . n . '</div>' . n . graf('<label for="weight">Weight</label>' . br . n . '<input type="text" style="width: 50px;" name="custom_2" id="weight" value="' . cleanfInput($custom_2) . '"/> <em>lbs</em>');
    echo n . "</fieldset>";
    //CUSTOM FIELDS
    //================================
    if (isset($ID)) {
        $custom_fields = get_custom_fields($ID);
    } else {
        $custom_fields = '';
    }
    echo n . n . '<fieldset class="product-options-sub" style="background-color:white" id="custom_fields">' . n . '<legend>Custom Fields <span>[<a href="javascript:addCustomField(0);">Add a new custom field</a>]</span></legend>';
    echo $custom_fields;
    echo n . "</fieldset>";
    //CATEGORIES
    //================================
    //if(!is_callable("rss_admin_catlist")){
    echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Categorize <small>[<a href="?event=category">edit</a>]</small></legend>' . '<div style="float:left; margin-right: 10px;">' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . n . '<select name="Category1" id="category-1"><option></option>' . n . product_cateogry_option_list($Category1) . n . '</select>') . n . '</div>' . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . n . '<select name="Category2" id="category-2"><option></option>' . n . product_cateogry_option_list($Category2) . n . '</select>');
    echo n . "</fieldset>";
    //}
    //VENDORS
    //================================
    echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Vendor <em>The creator or manufacturer of the product. </em></legend>' . '<div style="float:left; width:50%;">' . n . '<label for="vendor">Select existing vendor </label> ' . br . n . build_list("vendor", "txp_category", "name", "title", $custom_5, "parent='Vendors'", true) . n . '</div>' . n . graf('<label for="new_vendor_name">Or create a new vendor</label>' . br . n . '<input id="new_vendor_name" type="text" name="new_vendor_name"/>');
    echo n . "</fieldset>";
    //INVENTORY
    //================================
    echo n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Inventory</legend>';
    echo n . '<label for="sku">SKU <em>Stock keeping unit</em></label>' . n . br . '<input type="text" name="custom_3" id="sku" value="' . $custom_3 . '"/>' . br . br;
    if (isset($custom_4) && !empty($custom_4)) {
        $showLevel = true;
        $levelSelected = "selected = 'true'";
        $levelStyle = 'display:block;';
    } else {
        $showLevel = false;
        $levelSelected = "";
        $levelStyle = 'display:none;';
    }
    echo n . '<select name="trackOptions" id="trackOptions" onchange="if(this.value == \'doTrack\'){$(\'stockLevel\').style.display = \'block\';}else{$(\'stockLevel\').style.display = \'none\';}">' . n . n . '<option value="dontTrack">Don\'t track stock level</option>' . n . '<option value="doTrack" ' . $levelSelected . '>Keep track of stock level</option>' . n . '</select>' . br . br;
    echo n . '<div id="stockLevel" style="' . $levelStyle . '">' . n . '<label for="items_in_stock">Number of items in stock:</label>' . n . '<input type="text" name="custom_4" id="items_in_stock" style="width: 20px;" value="' . cleanfInput($custom_4) . '"/>' . n . '</div><!--/stockLevel-->';
    echo n . "</fieldset>";
    //IMAGES
    //================================
    echo '

					<script type="text/javascript">
					<!--
						function deleteImage(id){
							if(confirm("Are you sure?")){
								if(id == "1"){
									$("image1").style.display = "none";
									$("imageField1").value = "delete";
								}else if(id == "2"){
									$("image2").style.display = "none";
									$("imageField2").value = "delete";
								}else if(id == "3"){
									$("image3").style.display = "none";
									$("imageField3").value = "delete";
								}else if(id == "4"){
									$("image4").style.display = "none";
									$("imageField4").value = "delete";
								}
								document.forms["product"].submit();
							}
						}
						function updateImage(id){
							if(id == "1"){

								new Effect.SlideDown($("imageUpload1"));
								$("updateImage1").value = $("imageField1").value;
								$("imageField1").value = "delete";

							}else if(id == "2"){

								new Effect.SlideDown($("imageUpload2"));
								$("updateImage2").value = $("imageField2").value;
								$("imageField2").value = "delete";

							}else if(id == "3"){

								new Effect.SlideDown($("imageUpload3"));
								$("updateImage3").value = $("imageField3").value;
								$("imageField3").value = "delete";
							}else if(id == "4"){

								new Effect.SlideDown($("imageUpload4"));
								$("updateImage4").value = $("imageField4").value;
								$("imageField4").value = "delete";
							}
						}
						function cancelUpload(id){
							if(id == "1"){
								new Effect.SlideUp($("imageUpload1"));
								$("imageField1").value = $("updateImage1").value;

							}else if(id == "2"){
								new Effect.SlideUp($("imageUpload2"));
								$("imageField2").value = $("updateImage2").value;

							}else if(id == "3"){
								new Effect.SlideUp($("imageUpload3"));
								$("imageField3").value = $("updateImage3").value;

							}else if(id == "4"){
								new Effect.SlideUp($("imageUpload4"));
								$("imageField4").value = $("updateImage4").value;

							}
						}
					-->
					</script>

				';
    if ($step == "create") {
        echo n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Product images</legend>';
        echo n . '<em>Allowed file types are JPG, GIF &amp; PNG</em>';
        echo n . '<input type="file" name="uploadFile"/>' . n;
        echo n . "</fieldset>";
    } else {
        if ($step == "edit" || $step == "save" || empty($step)) {
            echo n . '<fieldset class="product-options-sub" id="images" style="background-color:white">' . n . '<legend>Product images</legend>';
            echo n . '<ul class="plain-list" id="image_list">';
            if (isset($Image) && !empty($Image)) {
                echo n . '<li id="image1">
							<img src="' . product_image_display($Image, "small") . '" alt="Product Image"/> <div class="imageEdit" style="display:block;">
							<a href="javascript:deleteImage(\'1\')">Delete Image</a> | <a href="javascript:updateImage(\'1\')">Update Image</a>

							<div class="imageUpload" id="imageUpload1" style="display:none;">
								Browse for new image: <input type="file" name="uploadFile1"/> and <input type="submit" value="Save"/>&nbsp; <a href="javascript:cancelUpload(\'1\')">Cancel</a>
								<input type="hidden" name="updateImage1" id="updateImage1" value="0"/>
							</div>
							<input id="imageField1" type="hidden" name="Image" value="' . $Image . '"/>

							</div>

							</li>';
            }
            if (isset($custom_6) && !empty($custom_6)) {
                echo n . '<li id="image2"><img src="' . product_image_display($custom_6, "small") . '" alt="Product Image"/>
						<div class="imageEdit" id="image1Control" style="display:block;">
							<a href="javascript:deleteImage(\'2\')">Delete Image</a> | <a href="javascript:updateImage(\'2\')">Update Image</a>

							<div class="imageUpload" id="imageUpload2" style="display:none;">
								Browse for new image: <input type="file" name="uploadFile2"/> and <input type="submit" value="Save"/> &nbsp; <a href="javascript:cancelUpload(\'2\')">Cancel</a>
								<input type="hidden" name="updateImage2" id="updateImage2" value="0"/>
							</div>

						</div><input id="imageField2" type="hidden" name="custom_6" value="' . $custom_6 . '"/></li>';
            }
            if (isset($custom_7) && !empty($custom_7)) {
                echo n . '<li id="image3"><img src="' . product_image_display($custom_7, "small") . '" alt="Product Image"/>
						<div class="imageEdit" id="image1Control" style="display:block;">
							<a href="javascript:deleteImage(\'3\')">Delete Image</a> | <a href="javascript:updateImage(\'3\')">Update Image</a>

							<div class="imageUpload" id="imageUpload3" style="display:none;">
								Browse for new image: <input type="file" name="uploadFile3"/> and <input type="submit" value="Save"/> &nbsp; <a href="javascript:cancelUpload(\'3\')">Cancel</a>
								<input type="hidden" name="updateImage3" id="updateImage3" value="0"/>
							</div>

							</div>
							<input id="imageField3" type="hidden" name="custom_7" value="' . $custom_7 . '"/></li>';
            }
            if (isset($custom_8) && !empty($custom_8)) {
                echo n . '<li id="image4"><img src="' . product_image_display($custom_8, "small") . '" alt="Product Image"/>
						<div class="imageEdit" id="image1Control" style="display:block;">
						<a href="javascript:deleteImage(\'4\')">Delete Image</a> | <a href="javascript:updateImage(\'4\')">Update Image</a>

							<div class="imageUpload" id="imageUpload4" style="display:none;">
								Browse for new image: <input type="file" name="uploadFile4"/> and <input type="submit" value="Save"/> &nbsp; <a href="javascript:cancelUpload(\'4\')">Cancel</a>
								<input type="hidden" name="updateImage4" id="updateImage4" value="0"/>
							</div>

						</div><input id="imageField4" type="hidden" name="custom_8" value="' . $custom_8 . '"/></li>';
            }
            echo n . "</ul><br style='clear:both;'/>";
            echo n . '<a href="javascript:void(0);" onclick="document.getElementById(\'otherImageUpload\').style.display = \'block\'">Add an image</a>' . n;
            echo n . '<div id="otherImageUpload" style="display:none; margin-top: 10px;">';
            echo n . '<em>Allowed file types are JPG, GIF &amp; PNG</em>';
            echo n . '<input type="file" name="uploadFile"/> and <input type="submit" value="upload"/>' . n;
            echo n . '</div>';
            echo n . "</fieldset>";
            echo n . '<div id="data"></div>';
        }
    }
    //echo '</div>'; // end productOptions
    // end left content area
    echo hInput('from_view', $view), '</td>';
    echo '<td id="article-col-2" style="padding-top: 75px;">';
    //start article-col-2
    //PRODUCT STATUS
    //================================
    echo n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio_product($Status) . n . '</fieldset>';
    //-- comments stuff --------------
    if ($step == "create") {
        //Avoiding invite disappear when previewing
        $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite;
        if ($comments_on_default == 1) {
            $Annotate = 1;
        }
    }
    if ($use_comments == 1) {
        echo n . n . '<fieldset id="write-comments">' . n . '<legend>Allow product reviews</legend>';
        $comments_expired = false;
        if ($step != 'create' && $comments_disabled_after) {
            $lifespan = $comments_disabled_after * 86400;
            $time_since = time() - $sPosted;
            if ($time_since > $lifespan) {
                $comments_expired = true;
            }
        }
        if ($comments_expired) {
            echo n . n . graf(gTxt('expired'));
        } else {
            echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite'));
        }
        echo n . n . '</fieldset>';
    }
    /*if(is_callable("rss_admin_catlist")){
    			echo "<fieldset id='write-sort'></fieldset>";
    			echo rss_admin_catlist();
    		}*/
    //wilshireone multipule categories
    //-- publish button --------------
    echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4);
    echo '</td> <!--/article-col-2-->';
    //end article-col-2
    echo '</td></tr></table></form>';
}
Exemplo n.º 5
0
    $in_stock = false;
}
if (isset($for_id) !== false and isset($for) !== false) {
    ?>

<div class="mw-add-to-cart-holder mw-add-to-cart-<?php 
    print $params['id'];
    ?>
" >
  <?php 
    if ($for == 'content' and intval($for_id) == 0) {
        $for_id = 0;
    }
    ?>
  <?php 
    $data = get_custom_fields("field_type=price&for={$for}&for_id=" . $for_id . "");
    ?>
  <?php 
    if (is_array($data) == true) {
        ?>
  <input type="hidden"  name="for" value="<?php 
        print $for;
        ?>
" />
  <input type="hidden"  name="for_id" value="<?php 
        print $for_id;
        ?>
" />
  <?php 
    }
    ?>
Exemplo n.º 6
0
    $diff = get_custom_fields($for, $params['save_to_content_id'], 1, false, false, false, true);
}
$suggest_from_rel = false;
if (isset($params['suggest-from-related']) and $params['suggest-from-related'] != 'false') {
    $suggest_from_rel = true;
}
$data = array();
if (isset($params['for_module_id'])) {
    if (isset($params['default-fields'])) {
        mw()->fields_manager->make_default($for, $params['for_module_id'], $params['default-fields']);
    }
    $more = get_custom_fields($for, $params['for_module_id'], 1, false, false);
    if ($suggest_from_rel == true) {
        $par = array();
        $par['rel_type'] = $for;
        $more = get_custom_fields($for, 'all', 1, false, false);
        $have = array();
        if (isset($diff) and is_array($diff)) {
            $i = 0;
            foreach ($diff as $item) {
                if (isset($item['name']) and in_array($item['name'], $have)) {
                    unset($diff[$i]);
                } else {
                    if (isset($diff[$i]) and isset($item['name'])) {
                        $have[] = $item['name'];
                    }
                }
                $i++;
            }
        }
        if (is_array($more)) {
Exemplo n.º 7
0
    if (isset($params['data-id'])) {
        $params['for_module_id'] = $params['data-id'];
    }
}
$diff = false;
if (isset($params['save_to_content_id'])) {
    //
    $diff = get_custom_fields($for, $params['save_to_content_id'], 1, false, false);
}
// d($params );
$data = array();
if (isset($params['for_module_id'])) {
    if (isset($params['default-fields'])) {
        mw()->fields_manager->make_default($for, $params['for_module_id'], $params['default-fields']);
    }
    $more = get_custom_fields($for, $params['for_module_id'], 1, false, false);
    $custom_names_for_content = array();
    if (is_array($diff) and is_array($more)) {
        $i = 0;
        foreach ($more as $item2) {
            foreach ($diff as $item1) {
                if (isset($item1['copy_of_field'])) {
                    if ($item1['copy_of_field'] == $item2['id']) {
                        //print $item1['copy_of_field'];
                        unset($more[$i]);
                    }
                }
            }
            $i++;
        }
    }