*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/mailings/peche.modules.php
* \ingroup mailing
* \brief File of class to offer a selector of emailing targets with Rule 'Peche'.
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
/**
* \class mailing_peche
* \brief Class to offer a selector of emailing targets with Rule 'Peche'.
*/
class mailing_peche extends MailingTargets
{
var $name='EmailsFromFile'; // Identifiant du module mailing
var $desc='EMails issus d\'un fichier'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
var $require_module=array(); // Module mailing actif si modules require_module actifs
var $require_admin=1; // Module mailing actif pour user admin ou non
var $picto='generic';
var $db;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function mailing_peche($db)
{
$this->db=$db;
}
/**
* On the main mailing area, there is a box with statistics.
* If you want to add a line in this report you must provide an
* array of SQL request that returns two field:
* One called "label", One called "nb".
*
* @return array Array with SQL requests
*/
function getSqlArrayForStats()
{
global $langs;
$langs->load("users");
$statssql=array();
return $statssql;
}
/*
* \brief Return here number of distinct emails returned by your selector.
* For example if this selector is used to extract 500 different
* emails from a text file, this function must return 500.
* \return int '' means NA
*/
function getNbOfRecipients()
{
return '';
}
/**
* Renvoie url lien vers fiche de la source du destinataire du mailing
*
* @param int $id ID
* @return string Url lien
*/
function url($id)
{
global $langs;
return $langs->trans('LineInFile',$id);
//' - '.$langs->trans("File").' '.dol_trunc(,12);
}
/**
* Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings
*
* @return string Retourne zone select
*/
function formFilter()
{
global $langs;
$s='';
$s.='';
return $s;
}
/**
* Ajoute destinataires dans table des cibles
*
* @param int $mailing_id Id of emailing
* @param array $filtersarray Requete sql de selection des destinataires
* @return int < 0 si erreur, nb ajout si ok
*/
function add_to_target($mailing_id,$filtersarray=array())
{
global $conf,$langs,$_FILES;
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
// For compatibility with Unix, MS-Dos or Macintosh
ini_set('auto_detect_line_endings', true);
$cibles = array();
$upload_dir=$conf->mailing->dir_temp;
if (create_exdir($upload_dir) >= 0)
{
$resupload = dol_move_uploaded_file($_FILES['username']['tmp_name'], $upload_dir . "/" . $_FILES['username']['name'], 1, 0, $_FILES['username']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$cpt=0;
//$mesg = '