Permalink
Browse files

Fix: multicompany sharings compatibility

  • Loading branch information...
1 parent 6d2a3ed commit 13624eeb86b3434dd1c17a2578caf4472714f56a Regis Houssin committed Apr 7, 2012
View
@@ -159,7 +159,7 @@
if ($action == 'addthumb')
{
- if (file_exists($conf->societe->dir_output.'/logos/'.$_GET["file"]))
+ if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
{
$isimage=image_format_supported($_GET["file"]);
@@ -162,7 +162,7 @@
// Right area
if ($module == 'company') // Auto area for suppliers invoices
{
- $upload_dir = $conf->societe->dir_output;
+ $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
$filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$param.='&module='.$module;
@@ -3691,7 +3691,7 @@ function showphoto($modulepart,$object,$width=100)
if ($modulepart=='societe')
{
- $dir=$conf->societe->dir_output;
+ $dir=$conf->societe->multidir_output[$object->entity];
$smallfile=$object->logo;
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
if ($object->logo) $file=$object->id.'/logos/thumbs/'.$smallfile;
@@ -3717,14 +3717,14 @@ function showphoto($modulepart,$object,$width=100)
if ($file && file_exists($dir."/".$file))
{
// TODO Link to large image
- $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'&cache='.$cache.'">';
- $ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'&cache='.$cache.'">';
+ $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">';
+ $ret.='<img alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">';
$ret.='</a>';
}
else if ($altfile && file_exists($dir."/".$altfile))
{
- $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'&cache='.$cache.'">';
- $ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($altfile).'&cache='.$cache.'">';
+ $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($file).'&cache='.$cache.'">';
+ $ret.='<img alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i','_',$file)).'" class="photologo" border="0" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
$ret.='</a>';
}
else
@@ -179,7 +179,7 @@ function write_file($object,$outputlangs,$srctemplatepath)
$outputlangs->load("companies");
$outputlangs->load("projects");
- if ($conf->societe->dir_output)
+ if ($conf->societe->multidir_output[$object->entity])
{
// If $object is id instead of object
if (! is_object($object))
@@ -194,7 +194,7 @@ function write_file($object,$outputlangs,$srctemplatepath)
}
}
- $dir = $conf->societe->dir_output;
+ $dir = $conf->societe->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->id);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
View
@@ -124,13 +124,13 @@ function llxHeader() { }
// On fait une verification des droits et on definit le repertoire concerne
// Wrapping for third parties
- if ($modulepart == 'company')
+ if ($modulepart == 'company' || $modulepart == 'societe')
{
if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file))
{
$accessallowed=1;
}
- $original_file=$conf->societe->dir_output.'/'.$original_file;
+ $original_file=$conf->societe->multidir_output[GETPOST('entity','int')].'/'.$original_file;
$sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity;
}
@@ -252,17 +252,6 @@ function llxHeader() { }
$original_file=$conf->compta->dir_output.'/'.$original_file;
}
- // Wrapping pour les societe
- else if ($modulepart == 'societe')
- {
- if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file))
- {
- $accessallowed=1;
- }
- $original_file=$conf->societe->dir_output.'/'.$original_file;
- $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$refname."' AND entity=".$conf->entity;
- }
-
// Wrapping pour les expedition
else if ($modulepart == 'expedition')
{
@@ -199,7 +199,7 @@
{
$filearray=array();
$upload_dir = $conf->$modulepart->dir_output;
- if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output;
+ if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output;
if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output;
@@ -259,7 +259,7 @@
/*
* Documents generes
*/
-$filedir=$conf->societe->dir_output.'/'.$socid;
+$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
@@ -199,7 +199,7 @@
/*
* Documents generes
*/
-$filedir=$conf->societe->dir_output.'/'.$socid;
+$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid;
$genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer;
@@ -845,7 +845,7 @@ function delete($id)
// Remove contacts
if (! $error)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
@@ -873,7 +873,7 @@ function delete($id)
// Remove ban
if (! $error)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this)."::Delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
@@ -906,7 +906,7 @@ function delete($id)
// Remove third party
if (! $error)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."societe";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
@@ -932,7 +932,7 @@ function delete($id)
$this->db->commit();
// Delete directory
- $docdir = $conf->societe->dir_output . "/" . $id;
+ $docdir = $conf->societe->multidir_output[$this->entity] . "/" . $id;
if (file_exists($docdir))
{
dol_delete_dir_recursive($docdir);
Oops, something went wrong.

0 comments on commit 13624ee

Please sign in to comment.