[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/ -> article_reviews_write.php (source)

   1  <?php
   2  /*

   3  $Id: article_reviews_write.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13  // Most of this file is changed or moved to BTS - Basic Template System - format.

  14  // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  15  //       catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  16  // (Sub 'fallback' with your current template to see if there is a template specific file.)

  17  
  18    require ('includes/application_top.php');
  19  
  20    if (!tep_session_is_registered('customer_id')) {
  21      $navigation->set_snapshot();
  22      tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  23    }
  24  
  25    $article_info_query = tep_db_query("select a.articles_id, ad.articles_name from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = '" . (int)$HTTP_GET_VARS['articles_id'] . "' and a.articles_status = '1' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "'");
  26    if (!tep_db_num_rows($article_info_query)) {
  27      tep_redirect(tep_href_link(FILENAME_ARTICLE_REVIEWS, tep_get_all_get_params(array('action'))));
  28    } else {
  29      $article_info = tep_db_fetch_array($article_info_query);
  30    }
  31  
  32    $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  33    $customer = tep_db_fetch_array($customer_query);
  34  
  35    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
  36      $rating = tep_db_prepare_input($HTTP_POST_VARS['rating']);
  37      $review = tep_db_prepare_input($HTTP_POST_VARS['review']);
  38  
  39      $error = false;
  40      if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) {
  41        $error = true;
  42  
  43        $messageStack->add('review', JS_REVIEW_TEXT);
  44      }
  45  
  46      if (($rating < 1) || ($rating > 5)) {
  47        $error = true;
  48  
  49        $messageStack->add('review', JS_REVIEW_RATING);
  50      }
  51  
  52      if ($error == false) {
  53        tep_db_query("insert into " . TABLE_ARTICLE_REVIEWS . " (articles_id, customers_id, customers_name, reviews_rating, date_added) values ('" . (int)$HTTP_GET_VARS['articles_id'] . "', '" . (int)$customer_id . "', '" . tep_db_input($customer['customers_firstname']) . ' ' . tep_db_input($customer['customers_lastname']) . "', '" . tep_db_input($rating) . "', now())");
  54        $insert_id = tep_db_insert_id();
  55  
  56        tep_db_query("insert into " . TABLE_ARTICLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . tep_db_input($review) . "')");
  57  
  58        tep_redirect(tep_href_link(FILENAME_ARTICLE_REVIEWS, tep_get_all_get_params(array('action'))));
  59      }
  60    }
  61  
  62    $articles_name = $article_info['articles_name'];
  63  
  64    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ARTICLE_REVIEWS_WRITE);
  65  
  66    $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_ARTICLE_REVIEWS, tep_get_all_get_params()));
  67  ?>
  68  
  69  <script language="javascript"><!--
  70  function checkForm() {
  71    var error = 0;
  72    var error_message = "<?php echo JS_ERROR; ?>";
  73  
  74    var review = document.article_reviews_write.review.value;
  75  
  76    if (review.length < <?php echo REVIEW_TEXT_MIN_LENGTH; ?>) {
  77      error_message = error_message + "<?php echo JS_REVIEW_TEXT; ?>";
  78      error = 1;
  79    }
  80  
  81    if ((document.article_reviews_write.rating[0].checked) || (document.article_reviews_write.rating[1].checked) || (document.article_reviews_write.rating[2].checked) || (document.article_reviews_write.rating[3].checked) || (document.article_reviews_write.rating[4].checked)) {
  82    } else {
  83      error_message = error_message + "<?php echo JS_REVIEW_RATING; ?>";
  84      error = 1;
  85    }
  86  
  87    if (error == 1) {
  88      alert(error_message);
  89      return false;
  90    } else {
  91      return true;
  92    }
  93  }
  94  
  95  function popupWindow(url) {
  96    window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
  97  }
  98  //--></script>

  99  
 100  <?php 
 101   $content = CONTENT_ARTICLES_REVIEWS_WRITE;
 102  
 103    include (bts_select('main', $content_template)); // BTSv1.5

 104  
 105  require (DIR_WS_INCLUDES . 'application_bottom.php'); 
 106  
 107  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7