From 13e9ff24a7eb2ba0c1524bcdca011e8f935767da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 28 Apr 2009 20:35:01 +0000 Subject: [PATCH] =?UTF-8?q?New:=20parametre=20de=20config=20des=20repertoi?= =?UTF-8?q?res=20dans=20les=20proprietes=20de=20la=20classe=20du=20module?= =?UTF-8?q?=20=20avec=20un=20r=E9pertoire=20parent=20en=20fonction=20de=20?= =?UTF-8?q?l'entit=E9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/mailing/liste.php | 3 +- htdocs/comm/mailing/mailing.class.php | 17 +-- htdocs/core/conf.class.php | 23 +-- htdocs/document.php | 2 +- htdocs/fichinter/apercu.php | 2 +- htdocs/fichinter/document.php | 2 +- htdocs/fichinter/fiche.php | 2 +- htdocs/fichinter/fichinter.class.php | 6 +- .../modules/fichinter/modules_fichinter.php | 4 +- .../modules/fichinter/pdf_soleil.modules.php | 4 +- .../modules/mailings/fraise.modules.php | 3 +- .../modules/mailings/kiwi.modules.php | 131 +++++++++--------- .../modules/mailings/peche.modules.php | 10 +- .../modules/mailings/poire.modules.php | 66 +++++---- .../modules/mailings/pomme.modules.php | 58 ++++---- .../includes/modules/modExpedition.class.php | 5 +- htdocs/includes/modules/modExport.class.php | 15 +- .../includes/modules/modExternalRss.class.php | 19 ++- .../includes/modules/modFckeditor.class.php | 21 ++- .../includes/modules/modFicheinter.class.php | 13 +- .../includes/modules/modFournisseur.class.php | 4 +- htdocs/includes/modules/modImport.class.php | 10 +- htdocs/includes/modules/modLabel.class.php | 10 +- htdocs/includes/modules/modLdap.class.php | 10 +- htdocs/includes/modules/modMailing.class.php | 13 +- htdocs/viewimage.php | 4 +- mysql/migration/2.6.0-2.7.0.sql | 6 +- mysql/tables/llx_categorie.key.sql | 3 +- mysql/tables/llx_categorie.sql | 17 ++- mysql/tables/llx_mailing.sql | 27 ++-- 30 files changed, 304 insertions(+), 206 deletions(-) diff --git a/htdocs/comm/mailing/liste.php b/htdocs/comm/mailing/liste.php index 144dc5ac299..41b4dea90bc 100644 --- a/htdocs/comm/mailing/liste.php +++ b/htdocs/comm/mailing/liste.php @@ -1,5 +1,6 @@ + * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ llxHeader(); $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; -$sql.= " WHERE 1=1"; +$sql.= " WHERE m.entity = ".$conf->entity; if ($sref) $sql.= " AND m.rowid = '".$sref."'"; if ($sall) $sql.= " AND (m.titre like '%".$sall."%' OR m.sujet like '%".$sall."%' OR m.body like '%".$sall."%')"; if (! $sortorder) $sortorder="ASC"; diff --git a/htdocs/comm/mailing/mailing.class.php b/htdocs/comm/mailing/mailing.class.php index 75d6b003e98..8c4868ebe64 100644 --- a/htdocs/comm/mailing/mailing.class.php +++ b/htdocs/comm/mailing/mailing.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,7 +82,7 @@ class Mailing extends CommonObject */ function create($user) { - global $langs; + global $conf, $langs; $this->db->begin(); @@ -95,8 +96,8 @@ class Mailing extends CommonObject } $sql = "INSERT INTO ".$this->db_table; - $sql .= " (date_creat, fk_user_creat)"; - $sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.")"; + $sql .= " (date_creat, fk_user_creat, entity)"; + $sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.", ".$conf->entity.")"; if (! $this->titre) { @@ -368,8 +369,8 @@ class Mailing extends CommonObject /** - * \brief Retourne le libell� du statut d'un mailing (brouillon, valid�e, ... - * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long + * \brief Retourne le libelle du statut d'un mailing (brouillon, validee, ... + * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * \return string Libelle */ function getLibStatut($mode=0) @@ -378,10 +379,10 @@ class Mailing extends CommonObject } /** - * \brief Renvoi le libell� d'un statut donn� + * \brief Renvoi le libelle d'un statut donn� * \param statut Id statut - * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Picto - * \return string Libell� du statut + * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * \return string Libelle du statut */ function LibStatut($statut,$mode=0) { diff --git a/htdocs/core/conf.class.php b/htdocs/core/conf.class.php index 81d4b8db9ad..afc2d00b2da 100644 --- a/htdocs/core/conf.class.php +++ b/htdocs/core/conf.class.php @@ -155,9 +155,6 @@ class Conf $this->webcal->enabled=defined('MAIN_MODULE_WEBCALENDAR')?MAIN_MODULE_WEBCALENDAR:0; $this->propal->enabled=defined("MAIN_MODULE_PROPALE")?MAIN_MODULE_PROPALE:0; - // Module externalrss - $this->externalrss->dir_temp=DOL_DATA_ROOT."/rss/temp"; - // Sous module bons d'expedition $this->expedition_bon->enabled=defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0; @@ -170,11 +167,10 @@ class Conf // Module taxes et charges sociales $this->tax->dir_output=DOL_DATA_ROOT."/taxes"; $this->tax->dir_temp =DOL_DATA_ROOT."/taxes/temp"; - + // Module ficheinter - $this->fichinter->dir_output=DOL_DATA_ROOT."/ficheinter"; - $this->fichinter->dir_temp =DOL_DATA_ROOT."/ficheinter/temp"; - if (defined('FICHEINTER_OUTPUTDIR') && FICHEINTER_OUTPUTDIR) { $this->fichinter->dir_output=FICHEINTER_OUTPUTDIR; } # Pour passer outre le rep par defaut + if (defined('FICHEINTER_OUTPUTDIR') && FICHEINTER_OUTPUTDIR) { $this->ficheinter->dir_output=FICHEINTER_OUTPUTDIR; } # Pour passer outre le rep par defaut + // Module produit $this->produit->MultiPricesEnabled=defined("PRODUIT_MULTIPRICES")?PRODUIT_MULTIPRICES:0; @@ -224,18 +220,7 @@ class Conf // Module actions $this->actions->dir_output=DOL_DATA_ROOT."/action"; $this->actions->dir_temp =DOL_DATA_ROOT."/action/temp"; - // Module export - $this->export->dir_output=DOL_DATA_ROOT."/export"; - $this->export->dir_temp =DOL_DATA_ROOT."/export/temp"; - // Module import - $this->import->dir_output=DOL_DATA_ROOT."/import"; - $this->import->dir_temp =DOL_DATA_ROOT."/import/temp"; - // Module ldap - $this->ldap->dir_temp=DOL_DATA_ROOT."/ldap/temp"; - // Module FCKeditor - $this->fckeditor->dir_output=DOL_DATA_ROOT."/fckeditor"; - // Module emailing - $this->mailings->dir_temp=DOL_DATA_ROOT."/mailings/temp"; + // Module oscommerce 1 $this->boutique->livre->enabled=defined("BOUTIQUE_LIVRE")?BOUTIQUE_LIVRE:0; $this->boutique->album->enabled=defined("BOUTIQUE_ALBUM")?BOUTIQUE_ALBUM:0; diff --git a/htdocs/document.php b/htdocs/document.php index bfdecba170b..aafbf242acd 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -132,7 +132,7 @@ if ($modulepart) { $accessallowed=1; } - $original_file=$conf->fichinter->dir_output.'/'.$original_file; + $original_file=$conf->ficheinter->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='$refname'"; } diff --git a/htdocs/fichinter/apercu.php b/htdocs/fichinter/apercu.php index 57cd8ae0567..8145598ff47 100644 --- a/htdocs/fichinter/apercu.php +++ b/htdocs/fichinter/apercu.php @@ -110,7 +110,7 @@ if ($_GET["id"] > 0) { * Documents */ $fichinterref = sanitizeFileName($fichinter->ref); - $dir_output = $conf->fichinter->dir_output . "/"; + $dir_output = $conf->ficheinter->dir_output . "/"; $filepath = $dir_output . $fichinterref . "/"; $file = $filepath . $fichinterref . ".pdf"; $filedetail = $filepath . $fichinterref . "-detail.pdf"; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 75f9d9906a4..9aeb9f382ce 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -64,7 +64,7 @@ $pagenext = $page + 1; $object = new Fichinter($db); $object->fetch($_GET["id"]); -$upload_dir = $conf->fichinter->dir_output.'/'.sanitizeFileName($object->ref); +$upload_dir = $conf->ficheinter->dir_output.'/'.sanitizeFileName($object->ref); $modulepart='fichinter'; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 1cfe7a0a3a8..c3e6d73b072 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -903,7 +903,7 @@ elseif ($_GET["id"] > 0) * Built documents */ $filename=sanitizeFileName($fichinter->ref); - $filedir=$conf->fichinter->dir_output . "/".$fichinter->ref; + $filedir=$conf->ficheinter->dir_output . "/".$fichinter->ref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id; $genallowed=$user->rights->ficheinter->creer; $delallowed=$user->rights->ficheinter->supprimer; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index b807848132a..4e5d7ae8ffc 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -480,10 +480,10 @@ class Fichinter extends CommonObject // Remove directory with files $fichinterref = sanitizeFileName($this->ref); - if ($conf->fichinter->dir_output) + if ($conf->ficheinter->dir_output) { - $dir = $conf->fichinter->dir_output . "/" . $fichinterref ; - $file = $conf->fichinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf"; + $dir = $conf->ficheinter->dir_output . "/" . $fichinterref ; + $file = $conf->ficheinter->dir_output . "/" . $fichinterref . "/" . $fichinterref . ".pdf"; if (file_exists($file)) { fichinter_delete_preview($this->db, $this->id, $this->ref); diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 882832b9b24..1cb6642c6cb 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -238,10 +238,10 @@ function fichinter_delete_preview($db, $fichinterid, $fichinterref='') $fichinterref = $fichinter->ref; } - if ($conf->fichinter->dir_output) + if ($conf->ficheinter->dir_output) { $fichinterref = sanitizeFileName($fichinterref); - $dir = $conf->fichinter->dir_output . "/" . $fichinterref ; + $dir = $conf->ficheinter->dir_output . "/" . $fichinterref ; $file = $dir . "/" . $fichinterref . ".pdf.png"; $multiple = $file . "."; diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index cf317ca339e..26a1a31a46f 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -94,7 +94,7 @@ class pdf_soleil extends ModelePDFFicheinter $outputlangs->setPhpLang(); - if ($conf->fichinter->dir_output) + if ($conf->ficheinter->dir_output) { // If $fichinter is id instead of object if (! is_object($fichinter)) @@ -109,7 +109,7 @@ class pdf_soleil extends ModelePDFFicheinter } $fichref = sanitizeFileName($fichinter->ref); - $dir = $conf->fichinter->dir_output; + $dir = $conf->ficheinter->dir_output; if (! eregi('specimen',$fichref)) $dir.= "/" . $fichref; $file = $dir . "/" . $fichref . ".pdf"; diff --git a/htdocs/includes/modules/mailings/fraise.modules.php b/htdocs/includes/modules/mailings/fraise.modules.php index d146b1d067b..4078c77230a 100644 --- a/htdocs/includes/modules/mailings/fraise.modules.php +++ b/htdocs/includes/modules/mailings/fraise.modules.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/includes/modules/mailings/kiwi.modules.php b/htdocs/includes/modules/mailings/kiwi.modules.php index 786cd9e71fd..ba4b53ae509 100644 --- a/htdocs/includes/modules/mailings/kiwi.modules.php +++ b/htdocs/includes/modules/mailings/kiwi.modules.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2005-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -24,40 +25,40 @@ include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php' */ class mailing_kiwi extends MailingTargets { - // CHANGE THIS: Put here a name not already used - var $name='ContactsCategories'; - // CHANGE THIS: Put here a description of your selector module. - // This label is used if no translation found for key MailingModuleDescXXX where XXX=name is found - var $desc="Third parties (by categories)"; + // CHANGE THIS: Put here a name not already used + var $name='ContactsCategories'; + // CHANGE THIS: Put here a description of your selector module. + // This label is used if no translation found for key MailingModuleDescXXX where XXX=name is found + var $desc="Third parties (by categories)"; // CHANGE THIS: Set to 1 if selector is available for admin users only - var $require_admin=0; + var $require_admin=0; - var $require_module=array("categorie"); - var $picto='company'; - var $db; + var $require_module=array("categorie"); + var $picto='company'; + var $db; - // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector - function mailing_categories($DB) - { - $this->db=$DB; - } + // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector + function mailing_categories($DB) + { + $this->db=$DB; + } - /** - * \brief This is the main function that returns the array of emails - * \param mailing_id Id of mailing. No need to use it. - * \param filterarray If you used the formFilter function. Empty otherwise. - * \return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id,$filtersarray=array()) - { - global $langs; + /** + * \brief This is the main function that returns the array of emails + * \param mailing_id Id of mailing. No need to use it. + * \param filterarray If you used the formFilter function. Empty otherwise. + * \return int <0 if error, number of emails added if ok + */ + function add_to_target($mailing_id,$filtersarray=array()) + { + global $conf, $langs; - $cibles = array(); - - // CHANGE THIS - // Select the contacts from category + $cibles = array(); + + // CHANGE THIS + // Select the contacts from category $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname,"; if ($_POST['filter']) $sql.= " llx_categorie.label as label"; else $sql.=" null as label"; @@ -65,26 +66,27 @@ class mailing_kiwi extends MailingTargets if ($_POST['filter']) $sql.= " LEFT JOIN llx_categorie_societe ON llx_categorie_societe.fk_societe=s.rowid"; if ($_POST['filter']) $sql.= " LEFT JOIN llx_categorie ON llx_categorie.rowid = llx_categorie_societe.fk_categorie"; $sql.= " WHERE s.email != ''"; + $sql.= " AND s.entity = ".$conf->entity; if ($_POST['filter']) $sql.= " AND llx_categorie.rowid='".$_POST['filter']."'"; - $sql.= " ORDER BY s.email"; + $sql.= " ORDER BY s.email"; - // Stocke destinataires dans cibles - $result=$this->db->query($sql); - if ($result) + // Stocke destinataires dans cibles + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + $j = 0; + + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) { - $num = $this->db->num_rows($result); - $i = 0; - $j = 0; - - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); - - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $cibles[$j] = array( + $cibles[$j] = array( 'email' => $obj->email, 'fk_contact' => $obj->fk_contact, 'name' => $obj->name, @@ -92,23 +94,22 @@ class mailing_kiwi extends MailingTargets 'other' => ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''), 'url' => $this->url($obj->id) ); - $old = $obj->email; - $j++; - } - - $i++; - } + $old = $obj->email; + $j++; } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } - - - return parent::add_to_target($mailing_id, $cibles); + + $i++; + } } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } + + return parent::add_to_target($mailing_id, $cibles); + } /** @@ -136,9 +137,10 @@ class mailing_kiwi extends MailingTargets */ function getNbOfRecipients() { - $sql = "SELECT count(distinct(s.email)) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.email != ''"; + $sql = "SELECT count(distinct(s.email)) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.email != ''"; + $sql.= " AND s.entity = ".$conf->entity; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients @@ -152,7 +154,7 @@ class mailing_kiwi extends MailingTargets */ function formFilter() { - global $langs; + global $conf, $langs; $s=''; $s.='