コード例 #1
0
ファイル: func.php プロジェクト: OneataBogdan/lead_coriolan
function fn_get_discussion($object_id, $object_type, $get_posts = false, $params = array())
{
    static $cache = array();
    static $customer_companies = null;
    $_cache_key = $object_id . '_' . $object_type;
    if (empty($cache[$_cache_key])) {
        $discussion = db_get_row("SELECT thread_id, type, object_type FROM ?:discussion WHERE object_id = ?i AND object_type = ?s ?p", $object_id, $object_type, fn_get_discussion_company_condition('?:discussion.company_id'));
        if (empty($discussion) && $object_type == 'M') {
            $company_discussion_type = Registry::ifGet('addons.discussion.company_discussion_type', 'D');
            if ($company_discussion_type != 'D') {
                $discussion = array('object_type' => 'M', 'object_id' => $object_id, 'type' => $company_discussion_type);
                if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
                    $discussion['company_id'] = Registry::get('runtime.company_id');
                }
                $discussion['thread_id'] = db_query('INSERT INTO ?:discussion ?e', $discussion);
            }
        }
        if (!empty($discussion) && AREA == 'C' && $object_type == 'M' && Registry::ifGet('addons.discussion.company_only_buyers', 'Y') == 'Y') {
            if (empty($_SESSION['auth']['user_id'])) {
                $discussion['disable_adding'] = true;
            } else {
                if ($customer_companies === null) {
                    $customer_companies = db_get_hash_single_array('SELECT company_id FROM ?:orders WHERE user_id = ?i', array('company_id', 'company_id'), $_SESSION['auth']['user_id']);
                }
                if (empty($customer_companies[$object_id])) {
                    $discussion['disable_adding'] = true;
                }
            }
        }
        fn_set_hook('get_discussion', $object_id, $object_type, $discussion);
        $cache[$_cache_key] = $discussion;
    }
    if (!empty($cache[$_cache_key]) && !isset($cache[$_cache_key]['posts']) && $get_posts == true) {
        $params['thread_id'] = $cache[$_cache_key]['thread_id'];
        $params['avail_only'] = AREA == 'C';
        // FIXME
        $discussion_object_types = fn_get_discussion_objects();
        list($cache[$_cache_key]['posts'], $cache[$_cache_key]['search']) = fn_get_discussion_posts($params, Registry::get('addons.discussion.' . $discussion_object_types[$cache[$_cache_key]['object_type']] . '_posts_per_page'));
        $cache[$_cache_key]['average_rating'] = fn_get_average_rating($cache[$_cache_key]);
    }
    $saved_post_data = fn_restore_post_data('post_data');
    if (!empty($saved_post_data)) {
        $cache[$_cache_key]['post_data'] = $saved_post_data;
    }
    return !empty($cache[$_cache_key]) ? $cache[$_cache_key] : false;
}
    function content_55ccec9f7b1266_22892671($_smarty_tpl)
    {
        if (!is_callable('smarty_function_set_id')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.set_id.php';
        }
        if ($_smarty_tpl->tpl_vars['runtime']->value['customization_mode']['design'] == "Y" && @constant('AREA') == "C") {
            $_smarty_tpl->_capture_stack[0][] = array("template_content", null, null);
            ob_start();
            $_smarty_tpl->tpl_vars["object_id"] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value['product_id'], null, 0);
            $_smarty_tpl->tpl_vars["object_type"] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value['discussion']['object_type'], null, 0);
            $_smarty_tpl->tpl_vars["attributes"] = new Smarty_variable(fn_get_review_attributes_work($_smarty_tpl->tpl_vars['object_id']->value), null, 0);
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['attributes']->value) {
                ?>
<div id="attributes_head">
	<?php 
                $_smarty_tpl->tpl_vars["rev_count"] = new Smarty_variable(fn_get_review_count($_smarty_tpl->tpl_vars['object_id']->value, $_smarty_tpl->tpl_vars['object_type']->value, $_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id']), null, 0);
                ?>

	<?php 
                if ($_smarty_tpl->tpl_vars['product']->value['product_id'] && $_smarty_tpl->tpl_vars['attributes']->value) {
                    ?>
	
		<?php 
                    $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(fn_get_review_ratings($_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id']), null, 0);
                    ?>
	<?php 
                } else {
                    ?>
		<?php 
                    $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(fn_get_review_ratings($_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id'], true), null, 0);
                    ?>
	<?php 
                }
                ?>
	<?php 
                if ($_smarty_tpl->tpl_vars['attributes']->value && !$_smarty_tpl->tpl_vars['ratings']->value || $_smarty_tpl->tpl_vars['ratings']->value['average'] == 0.0 && !$_smarty_tpl->tpl_vars['ratings']->value['rating']) {
                    ?>
		<?php 
                    $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(fn_get_review_ratings($_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id'], true), null, 0);
                    ?>
	<?php 
                }
                ?>

	<?php 
                if ($_smarty_tpl->tpl_vars['ratings']->value['average']) {
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
<a style="text-decoration: none;" onclick="$('#review_attributes').click(); $.scrollToElm($('#review_attributes')); return false;"><?php 
                    }
                    echo $_smarty_tpl->getSubTemplate("addons/altteam_review_attributes/views/discussion/components/stars.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('stars' => fn_get_discussion_rating($_smarty_tpl->tpl_vars['ratings']->value['average'])), 0);
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
</a><?php 
                    }
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
<a style="text-decoration: none;" onclick="$('#review_attributes').click(); $.scrollToElm($('#review_attributes')); return false;"><?php 
                    }
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['rev_count']->value, ENT_QUOTES, 'UTF-8');
                    ?>
&nbsp;<?php 
                    echo $_smarty_tpl->__('reviews');
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
</a><?php 
                    }
                    ?>
	<?php 
                }
                ?>
<!--attributes_head--></div>
<?php 
            } else {
                ?>

	<?php 
                $_smarty_tpl->tpl_vars["average_rating"] = new Smarty_variable(fn_get_average_rating($_smarty_tpl->tpl_vars['object_id']->value, $_smarty_tpl->tpl_vars['object_type']->value), null, 0);
                ?>

	<?php 
                if ($_smarty_tpl->tpl_vars['average_rating']->value) {
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
<a onclick="$('#review_attributes').click(); return false;"><?php 
                    }
                    echo $_smarty_tpl->getSubTemplate("addons/altteam_review_attributes/views/discussion/components/stars.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('stars' => fn_get_discussion_rating($_smarty_tpl->tpl_vars['average_rating']->value), 'mode' => 'big'), 0);
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
</a><?php 
                    }
                    ?>
	<?php 
                }
                ?>

<?php 
            }
            list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
            if (!empty($_capture_buffer)) {
                if (isset($_capture_assign)) {
                    $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                }
                if (isset($_capture_append)) {
                    $_smarty_tpl->append($_capture_append, ob_get_contents());
                }
                Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
            } else {
                $_smarty_tpl->capture_error();
            }
            if (trim(Smarty::$_smarty_vars['capture']['template_content'])) {
                if ($_smarty_tpl->tpl_vars['auth']->value['area'] == "A") {
                    ?>
<span class="cm-template-box template-box" data-ca-te-template="addons/altteam_review_attributes/hooks/products/main_info_title.post.tpl" id="<?php 
                    echo smarty_function_set_id(array('name' => "addons/altteam_review_attributes/hooks/products/main_info_title.post.tpl"), $_smarty_tpl);
                    ?>
"><div class="cm-template-icon icon-edit ty-icon-edit hidden"></div><?php 
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                    ?>
<!--[/tpl_id]--></span><?php 
                } else {
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                }
            }
        } else {
            $_smarty_tpl->tpl_vars["object_id"] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value['product_id'], null, 0);
            $_smarty_tpl->tpl_vars["object_type"] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value['discussion']['object_type'], null, 0);
            $_smarty_tpl->tpl_vars["attributes"] = new Smarty_variable(fn_get_review_attributes_work($_smarty_tpl->tpl_vars['object_id']->value), null, 0);
            ?>

<?php 
            if ($_smarty_tpl->tpl_vars['attributes']->value) {
                ?>
<div id="attributes_head">
	<?php 
                $_smarty_tpl->tpl_vars["rev_count"] = new Smarty_variable(fn_get_review_count($_smarty_tpl->tpl_vars['object_id']->value, $_smarty_tpl->tpl_vars['object_type']->value, $_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id']), null, 0);
                ?>

	<?php 
                if ($_smarty_tpl->tpl_vars['product']->value['product_id'] && $_smarty_tpl->tpl_vars['attributes']->value) {
                    ?>
	
		<?php 
                    $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(fn_get_review_ratings($_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id']), null, 0);
                    ?>
	<?php 
                } else {
                    ?>
		<?php 
                    $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(fn_get_review_ratings($_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id'], true), null, 0);
                    ?>
	<?php 
                }
                ?>
	<?php 
                if ($_smarty_tpl->tpl_vars['attributes']->value && !$_smarty_tpl->tpl_vars['ratings']->value || $_smarty_tpl->tpl_vars['ratings']->value['average'] == 0.0 && !$_smarty_tpl->tpl_vars['ratings']->value['rating']) {
                    ?>
		<?php 
                    $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(fn_get_review_ratings($_smarty_tpl->tpl_vars['product']->value['discussion']['thread_id'], true), null, 0);
                    ?>
	<?php 
                }
                ?>

	<?php 
                if ($_smarty_tpl->tpl_vars['ratings']->value['average']) {
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
<a style="text-decoration: none;" onclick="$('#review_attributes').click(); $.scrollToElm($('#review_attributes')); return false;"><?php 
                    }
                    echo $_smarty_tpl->getSubTemplate("addons/altteam_review_attributes/views/discussion/components/stars.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('stars' => fn_get_discussion_rating($_smarty_tpl->tpl_vars['ratings']->value['average'])), 0);
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
</a><?php 
                    }
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
<a style="text-decoration: none;" onclick="$('#review_attributes').click(); $.scrollToElm($('#review_attributes')); return false;"><?php 
                    }
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['rev_count']->value, ENT_QUOTES, 'UTF-8');
                    ?>
&nbsp;<?php 
                    echo $_smarty_tpl->__('reviews');
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
</a><?php 
                    }
                    ?>
	<?php 
                }
                ?>
<!--attributes_head--></div>
<?php 
            } else {
                ?>

	<?php 
                $_smarty_tpl->tpl_vars["average_rating"] = new Smarty_variable(fn_get_average_rating($_smarty_tpl->tpl_vars['object_id']->value, $_smarty_tpl->tpl_vars['object_type']->value), null, 0);
                ?>

	<?php 
                if ($_smarty_tpl->tpl_vars['average_rating']->value) {
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
<a onclick="$('#review_attributes').click(); return false;"><?php 
                    }
                    echo $_smarty_tpl->getSubTemplate("addons/altteam_review_attributes/views/discussion/components/stars.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('stars' => fn_get_discussion_rating($_smarty_tpl->tpl_vars['average_rating']->value), 'mode' => 'big'), 0);
                    if ($_smarty_tpl->tpl_vars['runtime']->value['controller'] == "products" && $_smarty_tpl->tpl_vars['runtime']->value['mode'] == "view") {
                        ?>
</a><?php 
                    }
                    ?>
	<?php 
                }
                ?>

<?php 
            }
        }
    }