Quick Search:

View

Revision:

Diff

Diff from 184 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/reviews.php

Annotated File View

hpdl
1
1 <?php
2 /*
hpdl
153
3   $Id: reviews.php 184 2005-09-07 14:48:20Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2004 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class osC_Reviews {
14      var $is_enabled = false,
15          $is_moderated = false;
16      
17 // class constructor
18     function osC_Reviews() {
19       
20         $this->enableReviews();
21         $this->enableModeration();
22     }
23
24     function enableReviews() {
25         global $osC_Database, $osC_Customer;
26
27       switch (SERVICE_REVIEW_ENABLE_REVIEWS) {
28         case 0:
29           $this->is_enabled = true;
30           break;
31         case 1:
hpdl
184
32           if ($osC_Customer->isLoggedOn()) {
hpdl
1
33             $this->is_enabled = true;
34           } else {
35             $this->is_enabled = false;
36           }
37           break;
38         case 2:
39           if ($this->hasPurchased() == true) {
40             $this->is_enabled = true;
41           } else {
42             $this->is_enabled = false;
43           }
44           break;
45         default:
46           $this->is_enabled = false;
47           break;
48         }
49       }
50       
51     function hasPurchased() {
52       global $osC_Database, $osC_Customer;
53       
54       $Qhaspurchased = $osC_Database->query('select count(*) as total from :table_orders o, :table_orders_products op, :table_products p where o.customers_id = :customers_id and o.orders_id = op.orders_id and op.products_id = p.products_id and op.products_id = :products_id');
55       $Qhaspurchased->bindRaw(':table_orders', TABLE_ORDERS);
56       $Qhaspurchased->bindRaw(':table_orders_products', TABLE_ORDERS_PRODUCTS);
57       $Qhaspurchased->bindRaw(':table_products', TABLE_PRODUCTS);
hpdl
184
58       $Qhaspurchased->bindInt(':customers_id', $osC_Customer->getID());
hpdl
1
59       $Qhaspurchased->bindInt(':products_id', $_GET['products_id']);
60       $Qhaspurchased->execute();
61
62       if ($Qhaspurchased->valueInt('total') >= '1') {
63         return true;
64       } else {
65         return false;
66       }
67     }
68     
69     function enableModeration() {
70         global $osC_Database, $osC_Customer;
71
72       switch (SERVICE_REVIEW_ENABLE_MODERATION) {
73       case -1:
74         $this->is_moderated = false;
75         break;
76       case 0:
hpdl
184
77         if ($osC_Customer->isLoggedOn()) {
hpdl
1
78           $this->is_moderated = false;
79         } else {
80           $this->is_moderated = true;
81         }
82         break;
83       case 1:
84         $this->is_moderated = true;
85         break;
86       default:
87         $this->is_moderated = true;
88         break;
89       }
90     }
91   }    
92 ?>
    \ No newline at end of file