function fn_get_post_attributes($post, $object_id) { $attributes = fn_get_review_attributes($object_id); //get rating values for each post $ratings = db_get_hash_single_array('SELECT attr_id, rating FROM ?:review_rating WHERE post_id = ?i', array('attr_id', 'rating'), $post['post_id']); foreach ($attributes as $attribute) { $post['attributes'][$attribute['attr_id']] = $attribute; $post['attributes'][$attribute['attr_id']]['value'] = $ratings[$attribute['attr_id']]; } return $post; }
} //[/Ruslan] $suffix = ".apply"; } return array(CONTROLLER_STATUS_REDIRECT, 'review_attributes' . $suffix); } if ($mode == 'manage') { // if (!defined('REVIEW_ATTRIBUTES_VERSION') || REVIEW_ATTRIBUTES_VERSION != Registry::get('settings.review_attributes_version')) { // $menu['upgrade'] = array ( // 'title' => __('upgrade'), // 'href' => INDEX_SCRIPT . '?dispatch=review_attributes.upgrade', // ); // Registry::set('navigation.dynamic.sections', $menu); // Registry::set('navigation.dynamic.active_section', $mode); // } $review_attributes = fn_get_review_attributes(); Registry::get('view')->assign('review_attributes', $review_attributes); } elseif ($mode == 'apply') { //[Ruslan] $review_attributes = fn_get_review_attributes_work(); // $products = db_get_fields('SELECT DISTINCT object_id FROM ?:review_attributes_links'); // // foreach ($products as $k => $prod_id) { // $prod_list[$k]['product_id'] = $prod_id; // $prod_list[$k]['attr_ids'] = db_get_fields('SELECT attr_id FROM ?:review_attributes_links WHERE object_id = ?i', $prod_id); // } Registry::get('view')->assign('review_attributes', $review_attributes); //[/Ruslan] } elseif ($mode == 'upgrade') { $addon = 'altteam_review_attributes'; $rewrite_opts = array();
* @module "Alt-team: Extended reviews with attributes" * @version 4.1.x * @license http://www.alt-team.com/addons-license-agreement.html ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($mode == 'manage') { $posts = Registry::get('view')->getTemplateVars('posts'); $ids = array(); foreach ($posts as $k => $v) { $ids[] = $v['post_id']; //get review attributes available for each post if (($v['type'] == 'R' || $v['type'] == 'B') && $v['object_type'] == 'P') { $posts[$k]['attributes'] = fn_get_review_attributes($v['object_id']); } } //get rating values for each post $ratings = db_get_hash_multi_array('SELECT post_id, attr_id, rating FROM ?:review_rating WHERE post_id IN (?n)', array('post_id', 'attr_id', 'rating'), $ids); foreach ($posts as $k => $post) { if (isset($post['attributes'])) { foreach ($post['attributes'] as $key => $attribute) { $posts[$k]['attributes'][$key]['value'] = isset($ratings[$post['post_id']][$attribute['attr_id']]) ? $ratings[$post['post_id']][$attribute['attr_id']] : 0; } } } //get additional field message title $_titles = db_get_array('SELECT post_id, message_title FROM ?:discussion_messages WHERE post_id IN (?n)', $ids); foreach ($_titles as $v) { $titles[$v['post_id']] = $v['message_title'];
* @module "Alt-team: Extended reviews with attributes" * @version 4.1.x * @license http://www.alt-team.com/addons-license-agreement.html ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'update') { if (!empty($_REQUEST['posts']) && is_array($_REQUEST['posts'])) { foreach ($_REQUEST['posts'] as $p_id => $post) { if (!empty($post['attributes'])) { foreach ($post['attributes'] as $attr_id => $rate) { $_data['rating'] = $rate; $_data['attr_id'] = $attr_id; $_data['post_id'] = $p_id; $_data = fn_check_table_fields($_data, 'review_rating'); db_query("REPLACE INTO ?:review_rating ?e", $_data); } } } } } } if ($mode == 'update') { $product_id = empty($_REQUEST['product_id']) ? 0 : intval($_REQUEST['product_id']); $review_attributes = fn_get_review_attributes($product_id); Registry::get('view')->assign('review_attributes', $review_attributes); Registry::set('navigation.tabs.review_attributes', array('title' => __('review_attributes'), 'js' => true)); }