Skip to content

Commit

Permalink
Fix: multicompany sharings compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Apr 7, 2012
1 parent 6d2a3ed commit 13624ee
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 140 deletions.
2 changes: 1 addition & 1 deletion htdocs/admin/company.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/ajax/ajaxdirpreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;

Expand Down
15 changes: 2 additions & 13 deletions htdocs/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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')
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/install/repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/societe/canvas/company/tpl/card_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/societe/canvas/individual/tpl/card_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions htdocs/societe/class/societe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 13624ee

Please sign in to comment.