Skip to content

Commit

Permalink
Fix: add backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Apr 6, 2012
1 parent 94788e2 commit 98f7a18
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 28 deletions.
25 changes: 19 additions & 6 deletions htdocs/core/class/conf.class.php
Expand Up @@ -272,8 +272,11 @@ function setValues($db)
// 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
Expand All @@ -285,6 +288,9 @@ function setValues($db)
$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";

Expand All @@ -305,11 +311,18 @@ function setValues($db)
$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";
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/photos_resize.php
Expand Up @@ -69,9 +69,9 @@
{
$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];
}

/*
Expand Down
4 changes: 2 additions & 2 deletions htdocs/document.php
Expand Up @@ -310,8 +310,8 @@ function llxHeader() { }
{
$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
Expand Down
4 changes: 2 additions & 2 deletions htdocs/fourn/product/photos.php
Expand Up @@ -42,7 +42,7 @@
{
$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']);
}
}
/*
Expand Down Expand Up @@ -139,7 +139,7 @@
$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">';

Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/canvas/product/actions_card_product.class.php
Expand Up @@ -213,9 +213,9 @@ function assign_values(&$action, $id=0, $ref='')

// 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
Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/canvas/service/actions_card_service.class.php
Expand Up @@ -208,9 +208,9 @@ function assign_values(&$action, $id=0, $ref='')

// 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
Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/document.php
Expand Up @@ -62,8 +62,8 @@
{
$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';

Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/fiche.php
Expand Up @@ -1044,7 +1044,7 @@
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
Expand All @@ -1070,7 +1070,7 @@
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>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/photos.php
Expand Up @@ -49,7 +49,7 @@
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]);
}


Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/price.php
Expand Up @@ -130,14 +130,14 @@
// 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>';
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/stats/fiche.php
Expand Up @@ -111,7 +111,7 @@
// 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)
Expand Down
6 changes: 3 additions & 3 deletions htdocs/viewimage.php
Expand Up @@ -197,13 +197,13 @@ function llxHeader() { }
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')
Expand Down Expand Up @@ -239,7 +239,7 @@ function llxHeader() { }
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')
Expand Down

0 comments on commit 98f7a18

Please sign in to comment.