<?php
/*
  $Id: reviews.php $
  TomatoCart Open Source Shopping Cart Solutions
  http://www.tomatocart.com

  Copyright (c) 2009 Wuxi Elootec Technology Co., Ltd;  Copyright (c) 2007 osCommerce

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/

  class osC_Services_reviews_Admin {
    var $title,
        $description,
        $uninstallable = true,
        $depends,
        $precedes;

    function osC_Services_reviews_Admin() {
      global $osC_Language;

      $osC_Language->loadIniFile('modules/services/reviews.php');

      $this->title = $osC_Language->get('services_reviews_title');
      $this->description = $osC_Language->get('services_reviews_description');
    }

    function install() {
      global $osC_Database;

      $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('最新评论', 'MAX_DISPLAY_NEW_REVIEWS', '6', '最多显示多少个最新评论。', '6', '0', now())");
      $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('客户级别', 'SERVICE_REVIEW_ENABLE_REVIEWS', '1', '客户书写评论所需的级别。', '6', '0', 'osc_cfg_set_boolean_value(array(\'0\', \'1\', \'2\'))', now())");
      $osC_Database->simpleQuery("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('评论审核', 'SERVICE_REVIEW_ENABLE_MODERATION', '-1', '客户评论是否需要先被管理员审核。', '6', '0', 'osc_cfg_set_boolean_value(array(\'-1\', \'0\', \'1\'))', now())");
    }

    function remove() {
      global $osC_Database;

      $osC_Database->simpleQuery("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MAX_DISPLAY_NEW_REVIEWS',
                   'SERVICE_REVIEW_ENABLE_REVIEWS',
                   'SERVICE_REVIEW_ENABLE_MODERATION');
    }
  }
?>
