Fix: add backward compatibility

This commit is contained in:
Regis Houssin 2012-04-06 23:24:31 +02:00
parent 94788e2ccb
commit 98f7a189d1
12 changed files with 41 additions and 28 deletions

View File

@ -272,8 +272,11 @@ class Conf
// Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module)
{
$this->$module->dir_output=$rootfordata."/".$module;
$this->$module->dir_temp=$rootfordata."/".$module."/temp";
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
// For backward compatibility
$this->$module->dir_output = $rootfordata."/".$module;
$this->$module->dir_temp = $rootfordata."/".$module."/temp";
}
// For mycompany storage
@ -285,6 +288,9 @@ class Conf
$this->admin->dir_temp=$rootfordata.'/admin/temp';
// For user storage
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
// For backward compatibility
$this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp";
@ -305,11 +311,18 @@ class Conf
$this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp";
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture";
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp";
// Module product/service
$this->product->dir_output=array($this->entity => $rootfordata."/produit");
$this->product->dir_temp =array($this->entity => $rootfordata."/produit/temp");
$this->service->dir_output=array($this->entity => $rootfordata."/produit");
$this->service->dir_temp =array($this->entity => $rootfordata."/produit/temp");
$this->product->multidir_output=array($this->entity => $rootfordata."/produit");
$this->product->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
$this->service->multidir_output=array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility
$this->product->dir_output=$rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp";
// Module contrat
$this->contrat->dir_output=$rootfordata."/contracts";
$this->contrat->dir_temp =$rootfordata."/contracts/temp";

View File

@ -69,9 +69,9 @@ if ($id > 0)
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db,'Failed to load object');
$dir=$conf->product->dir_output[$object->entity]; // By default
if ($object->type == 0) $dir=$conf->product->dir_output[$object->entity];
if ($object->type == 1) $dir=$conf->service->dir_output[$object->entity];
$dir=$conf->product->multidir_output[$object->entity]; // By default
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity];
}
/*

View File

@ -310,8 +310,8 @@ if ($modulepart)
{
$accessallowed=1;
}
if ($conf->product->enabled) $original_file=$conf->product->dir_output[GETPOST('entity','int')].'/'.$original_file;
elseif ($conf->service->enabled) $original_file=$conf->service->dir_output[GETPOST('entity','int')].'/'.$original_file;
if ($conf->product->enabled) $original_file=$conf->product->multidir_output[GETPOST('entity','int')].'/'.$original_file;
elseif ($conf->service->enabled) $original_file=$conf->service->multidir_output[GETPOST('entity','int')].'/'.$original_file;
}
// Wrapping pour les contrats

View File

@ -42,7 +42,7 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$result = $object->fetch($id);
$object->add_photo($conf->product->dir_output[$object->entity], $_FILES['photofile']);
$object->add_photo($conf->product->multidir_output[$object->entity], $_FILES['photofile']);
}
}
/*
@ -139,7 +139,7 @@ if ($id)
$nbbyrow=5;
$pdir = get_exdir($object->id,2) . $object->id ."/photos/";
$dir = $conf->product->dir_output[$object->entity] . '/'. $pdir;
$dir = $conf->product->multidir_output[$object->entity] . '/'. $pdir;
print '<br><table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';

View File

@ -213,9 +213,9 @@ class ActionsCardProduct extends Product
// Photo
$this->tpl['nblignes'] = 4;
if ($this->object->is_photo_available($conf->product->dir_output[$this->object->entity]))
if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity]))
{
$this->tpl['photos'] = $this->object->show_photos($conf->product->dir_output[$this->object->entity],1,1,0,0,0,80);
$this->tpl['photos'] = $this->object->show_photos($conf->product->multidir_output[$this->object->entity],1,1,0,0,0,80);
}
// Nature

View File

@ -208,9 +208,9 @@ class ActionsCardService extends Product
// Photo
$this->tpl['nblignes'] = 4;
if ($this->object->is_photo_available($conf->service->dir_output))
if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity]))
{
$this->tpl['photos'] = $this->object->show_photos($conf->service->dir_output,1,1,0,0,0,80);
$this->tpl['photos'] = $this->object->show_photos($conf->service->multidir_output[$this->object->entity],1,1,0,0,0,80);
}
// Duration

View File

@ -62,8 +62,8 @@ if ($id > 0 || ! empty($ref))
{
$result = $object->fetch($id, $ref);
if ($conf->product->enabled) $upload_dir = $conf->product->dir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
elseif ($conf->service->enabled) $upload_dir = $conf->service->dir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
if ($conf->product->enabled) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
elseif ($conf->service->enabled) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
}
$modulepart='produit';

View File

@ -1044,7 +1044,7 @@ else
if ($ret == 'html') print '<br>';
}
$showphoto=$object->is_photo_available($conf->product->dir_output[$object->entity]);
$showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
$showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire;
// En mode visu
@ -1070,7 +1070,7 @@ else
if ($showphoto || $showbarcode)
{
print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">';
if ($showphoto) print $object->show_photos($conf->product->dir_output[$object->entity],1,1,0,0,0,80);
if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,1,0,0,0,80);
if ($showphoto && $showbarcode) print '<br><br>';
if ($showbarcode) print $form->showbarcode($object);
print '</td>';

View File

@ -49,7 +49,7 @@ $object = new Product($db);
if ($id > 0 || ! empty($ref))
{
$result = $object->fetch($id, $ref);
$dir = (! empty($conf->product->dir_output[$object->entity])?$conf->product->dir_output[$object->entity]:$conf->service->dir_output[$object->entity]);
$dir = (! empty($conf->product->multidir_output[$object->entity])?$conf->product->multidir_output[$object->entity]:$conf->service->multidir_output[$object->entity]);
}

View File

@ -130,14 +130,14 @@ print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->libelle.'</td>';
$isphoto=$object->is_photo_available($conf->product->dir_output[$object->entity]);
$isphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
$nblignes=5;
if ($isphoto)
{
// Photo
print '<td valign="middle" align="center" width="30%" rowspan="'.$nblignes.'">';
print $object->show_photos($conf->product->dir_output[$object->entity],1,1,0,0,0,80);
print $object->show_photos($conf->product->multidir_output[$object->entity],1,1,0,0,0,80);
print '</td>';
}

View File

@ -111,7 +111,7 @@ if (! empty($id) || ! empty($ref))
// Generation des graphs
$WIDTH=380;
$HEIGHT=160;
$dir = (! empty($conf->product->dir_temp[$object->entity])?$conf->product->dir_temp[$object->entity]:$conf->service->dir_temp[$object->entity]);
$dir = (! empty($conf->product->multidir_temp[$object->entity])?$conf->product->multidir_temp[$object->entity]:$conf->service->multidir_temp[$object->entity]);
if (! file_exists($dir.'/'.$object->id))
{
if (dol_mkdir($dir.'/'.$object->id) < 0)

View File

@ -197,13 +197,13 @@ if ($modulepart)
elseif (preg_match('/^productstats_/i',$modulepart))
{
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
$original_file=(!empty($conf->product->dir_temp[GETPOST('entity','int')])?$conf->product->dir_temp[GETPOST('entity','int')]:$conf->service->dir_temp[GETPOST('entity','int')]).'/'.$original_file;
$original_file=(!empty($conf->product->multidir_temp[GETPOST('entity','int')])?$conf->product->multidir_temp[GETPOST('entity','int')]:$conf->service->multidir_temp[GETPOST('entity','int')]).'/'.$original_file;
}
// Wrapping for products or services
elseif ($modulepart == 'product')
{
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
$original_file=(! empty($conf->product->dir_output[GETPOST('entity','int')])?$conf->product->dir_output[GETPOST('entity','int')]:$conf->service->dir_output[GETPOST('entity','int')]).'/'.$original_file;
$original_file=(! empty($conf->product->multidir_output[GETPOST('entity','int')])?$conf->product->multidir_output[GETPOST('entity','int')]:$conf->service->multidir_output[GETPOST('entity','int')]).'/'.$original_file;
}
// Wrapping for products or services
elseif ($modulepart == 'tax')
@ -239,7 +239,7 @@ if ($modulepart)
elseif ($modulepart == 'graph_product')
{
$accessallowed=1;
$original_file=$conf->product->dir_temp[GETPOST('entity','int')].'/'.$original_file;
$original_file=$conf->product->multidir_temp[GETPOST('entity','int')].'/'.$original_file;
}
// Wrapping pour les code barre
elseif ($modulepart == 'barcode')