C'è anche questo file da modificare
Lo posto tutto perchè ci sono molte modifiche da fare (inerenti i due nuovi campi da aggiungere: mf_full_image e mf_thumb_image)
\administrator\components\com_virtuemart\classes\ps_manufacturer.php:
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
*
* @version $Id: ps_manufacturer.php,v 1.4.2.2 2006/03/14 18:42:11 soeren_nb Exp $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
/****************************************************************************
*
* CLASS DESCRIPTION
*
* ps_manufacturer
*
* The class is is used to manage the manufacturers in your store.
*
* properties:
*
* error - the error message returned by validation if any
* methods:
* validate_add()
* validate_delete()
* validate_update()
* add()
* update()
* delete()
*
*
*************************************************************************/
class ps_manufacturer {
var $classname = "ps_manufacturer";
var $error;
/**************************************************************************
** name: validate_add()
** created by: soeren
** description:
** parameters:
** returns:
***************************************************************************/
function validate_add(&$d) {
global $vmLogger;
$valid = true;
$db = new ps_DB;
if (!$d["mf_name"]) {
$vmLogger->err( "ERROR: You must enter a name for the manufacturer.");
$valid = False;
}
else {
$q = "SELECT count(*) as rowcnt from #__{vm}_manufacturer where";
$q .= " mf_name='" . $d["mf_name"] . "'";
$db->setQuery($q);
$db->query();
$db->next_record();
if ($db->f("rowcnt") > 0) {
$vmLogger->err( "The given manufacturer name already exists.");
$valid = False;
}
}
/** Image Upload Validation **/
// do we have an image URL or an image File Upload?
if (!empty( $d['mf_thumb_image_url'] )) {
// Image URL
if (substr( $d['mf_thumb_image_url'], 0, 4) != "http") {
$vmLogger->err( "Image URL must begin with http." );
$valid = false;
}
$d["mf_thumb_image"] = $d['mf_thumb_image_url'];
}
else {
// File Upload
if (!validate_image( $d, "mf_thumb_image", "manufacturer")) {
$valid = false;
}
}
if (!empty( $d['mf_full_image_url'] )) {
// Image URL
if (substr( $d['mf_full_image_url'], 0, 4) != "http") {
$vmLogger->err( "Image URL must begin with http." );
return false;
}
$d["mf_full_image"] = $d['mf_full_image_url'];
}
else {
// File Upload
if (!validate_image( $d, "mf_full_image", "manufacturer")) {
$vmLogger->err( "immagine non validata." );
$valid = false;
}
}
return $valid;
}
/**************************************************************************
** name: validate_update
** created by: soeren
** description:
** parameters:
** returns:
***************************************************************************/
function validate_update(&$d) {
global $vmLogger;
$valid = true;
if (!$d["mf_name"]) {
$vmLogger->err( "ERROR: You must enter a name for the manufacturer.");
$valid = false;
}
$db =& new ps_DB;
$q = "SELECT mf_thumb_image,mf_full_image FROM #__{vm}_manufacturer WHERE manufacturer_id='". $d["manufacturer_id"] . "'";
$db->query( $q );
$db->next_record();
/** Image Upload Validation **/
// do we have an image URL or an image File Upload?
if (!empty( $d['mf_thumb_image_url'] )) {
// Image URL
if (substr( $d['mf_thumb_image_url'], 0, 4) != "http") {
$vmLogger->err( "An Image URL must begin with 'http'." );
$valid = false;
}
// if we have an uploaded image file, prepare this one for deleting.
if( $db->f("mf_thumb_image") && substr( $db->f("mf_thumb_image"), 0, 4) != "http") {
$_REQUEST["mf_thumb_image_curr"] = $db->f("mf_thumb_image");
$d["mf_thumb_image_action"] = "delete";
if (!validate_image( $d, "mf_thumb_image", "manufacturer")) {
return false;
}
}
$d["mf_thumb_image"] = $d['mf_thumb_image_url'];
}
else {
// File Upload
if (!validate_image( $d, "mf_thumb_image", "manufacturer")) {
$valid = false;
}
}
if (!empty( $d['mf_full_image_url'] )) {
// Image URL
if (substr( $d['mf_full_image_url'], 0, 4) != "http") {
$vmLogger->err( "Image URL must begin with 'http'." );
return false;
}
// if we have an uploaded image file, prepare this one for deleting.
if( $db->f("mf_full_image") && substr( $db->f("mf_thumb_image"), 0, 4) != "http") {
$_REQUEST["mf_full_image_curr"] = $db->f("mf_full_image");
$d["mf_full_image_action"] = "delete";
if (!validate_image( $d, "mf_full_image", "manufacturer")) {
$vmLogger->err( "immagine2 non validata." );
return false;
}
}
$d["mf_full_image"] = $d['mf_full_image_url'];
}
else {
// File Upload
if (!validate_image( $d, "mf_full_image", "manufacturer")) {
$vmLogger->err( "immagine non validata3." );
$valid = false;
}
}
return $valid;
}
/**************************************************************************
** name: validate_delete()
** created by: soeren
** description:
** parameters:
** returns:
***************************************************************************/
function validate_delete($manufacturer_id) {
global $db, $vmLogger;
if (empty( $manufacturer_id )) {
$vmLogger->err( "ERROR: Please select a manufacturer to delete.");
return False;
}
$db->query( "SELECT jos_vm_product.product_id, manufacturer_id
FROM jos_vm_product, jos_vm_product_mf_xref
WHERE manufacturer_id =".intval($manufacturer_id)."
AND jos_vm_product.product_id = jos_vm_product_mf_xref.product_id" );
if( $db->num_rows() > 0 ) {
$vmLogger->err( "Error: This Manufacturer still has products assigned to it.");
return false;
}
$q = "SELECT mf_thumb_image, mf_full_image FROM #__{vm}_manufacturer WHERE manufacturer_id='$manufacturer_id'";
$db->query( $q );
$db->next_record();
/* Prepare category_thumb_image for Deleting */
if( !stristr( $db->f("mf_thumb_image"), "http") ) {
$_REQUEST["mf_thumb_image_curr"] = $db->f("mf_thumb_image");
$d["mf_thumb_image_action"] = "delete";
if (!validate_image($d,"mf_thumb_image","manufacturer")) {
$vmLogger->err( "Failed deleting Manufacturer Images!" );
return false;
}
}
/* Prepare product_full_image for Deleting */
if( !stristr( $db->f("mf_full_image"), "http") ) {
$_REQUEST["mf_full_image_curr"] = $db->f("mf_full_image");
$d["mf_full_image_action"] = "delete";
if (!validate_image($d,"mf_full_image","manufacturer")) {
$vmLogger->err( "immagine non validata4." );
return false;
}
}
return True;
}
/**************************************************************************
* name: add()
* created by: soeren
* description: creates a new manufacturer record
* parameters:
* returns:
**************************************************************************/
function add(&$d) {
global $vmLogger;
$db = new ps_DB;
$GLOBALS['vmInputFilter']->safeSQL( $d );
if ($this->validate_add($d)) {
if (!process_images($d)) {
return false;
}
while(list($key,$value)= each($d)) {
if (!is_array($value))
$d[$key] = addslashes($value);
}
$q = "INSERT into #__{vm}_manufacturer (mf_name, mf_email, mf_desc, mf_category_id, mf_url, mf_thumb_image, mf_full_image)";
$q .= " VALUES ('";
$q .= $d["mf_name"] . "','";
$q .= $d["mf_email"] . "','";
$q .= $d["mf_desc"] . "','";
$q .= $d["mf_category_id"] . "','";
$q .= $d["mf_url"] . "')";
$q .= $d["mf_thumb_image"] . "','";
$q .= $d["mf_full_image"] . "','";
$db->setQuery($q);
$db->query();
$vmLogger->info( "Successfully added new manufacturer: ".$d['mf_name'].'.');
return $manufacturer_id;
}
else {
return False;
}
}
/**************************************************************************
* name: update()
* created by: soeren
* description: updates manufacturer information
* parameters:
* returns:
**************************************************************************/
function update(&$d) {
global $vmLogger;
$db = new ps_DB;
$timestamp = time();
$GLOBALS['vmInputFilter']->safeSQL( $d );
foreach ($d as $key => $value) {
if (!is_array($value))
$d[$key] = addslashes($value);
}
if ($this->validate_update($d)) {
if (!process_images($d)) {
return false;
}
$q = "UPDATE #__{vm}_manufacturer set ";
$q .= "mf_name='" . $d["mf_name"]."',";
$q .= "mf_email='" .$d["mf_email"] . "',";
$q .= "mf_desc='" .$d["mf_desc"] . "',";
$q .= "mf_category_id='" .$d["mf_category_id"] . "',";
$q .= "mf_url='" .$d["mf_url"] . "',";
$q .= "mf_thumb_image='" . $d["mf_thumb_image"] . "',";
$q .= "mf_full_image='" . $d["mf_full_image"] ."'";
$q .= "WHERE manufacturer_id='".$d["manufacturer_id"]."'";
$db->setQuery($q);
$db->query();
$vmLogger->info( "Successfully updated manufacturer: ".$d['mf_name'].'.' );
return True;
}
else {
return False;
}
}
/**
* Controller for Deleting Records.
*/
function delete(&$d) {
$record_id = $d["manufacturer_id"];
if( is_array( $record_id)) {
foreach( $record_id as $record) {
if( !$this->delete_record( $record, $d ))
return false;
}
return true;
}
else {
return $this->delete_record( $record_id, $d );
}
}
/**
* Deletes one Record.
*/
function delete_record( $record_id, &$d ) {
global $db, $vmLogger;
if (!$this->validate_delete($record_id)) {
return False;
}
$q = "DELETE from #__{vm}_manufacturer WHERE manufacturer_id='$record_id'";
$db->query($q);
/* Delete Image files */
if (!process_images($d)) {
return false;
}
$vmLogger->info( "Successfully deleted manufacturer ID: $record_id." );
return True;
}
}
?>
L'ho modificato sulla sicia di \administrator\components\com_virtuemart\classes\ps_product_category.php