Reorganize code to reduce memory usage

This commit is contained in:
Laurent Destailleur 2009-02-19 18:57:54 +00:00
parent 52c0edeaca
commit d433c7120f
7 changed files with 61 additions and 64 deletions

View File

@ -34,6 +34,7 @@
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
/**

View File

@ -28,6 +28,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");
@ -864,11 +865,11 @@ if ($rowid && $action != 'edit')
{
if ($adh->societe) $name.=' ('.$adh->societe.')';
}
else
else
{
$name=$adh->societe;
}
// Create a form array
$formquestion=array(
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
@ -1038,7 +1039,7 @@ if ($rowid && $action != 'edit')
}
print '</td></tr>';
}
// Other attributs
foreach($adho->attribute_label as $key=>$value)
{
@ -1144,7 +1145,7 @@ if ($rowid && $action != 'edit')
print "<font class=\"butActionRefused\" href=\"#\">".$langs->trans("CreateDolibarrThirdParty")."</font>";
}
}
// Supprimer
if ($user->rights->adherent->supprimer)
{

View File

@ -25,6 +25,7 @@
*/
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
/**

View File

@ -36,45 +36,6 @@ if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
if (! defined('ADODB_DATE_VERSION')) include_once(DOL_DOCUMENT_ROOT."/includes/adodbtime/adodb-time.inc.php");
/**
* \brief Return true if email syntax is ok
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true if email ok, false if ko
*/
function ValidEmail($address)
{
if (eregi(".*<(.+)>", $address, $regs)) {
$address = $regs[1];
}
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address))
{
return true;
}
else
{
return false;
}
}
/**
* \brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true si email valide, false sinon
*/
function check_mail($mail)
{
list($user, $domain) = split("@", $mail, 2);
if (checkdnsrr($domain, "MX"))
{
return true;
}
else
{
return false;
}
}
/**
* \brief Clean a string to use it as a file name.
* \param str String to clean
@ -739,8 +700,6 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64)
if (empty($email)) return '&nbsp;';
if (! ValidEmail($email)) return "Bad email";
if (! empty($addlink))
{
$newemail='<a href="';

View File

@ -26,6 +26,44 @@
*/
/**
* \brief Return true if email syntax is ok
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true if email ok, false if ko
*/
function ValidEmail($address)
{
if (eregi(".*<(.+)>", $address, $regs)) {
$address = $regs[1];
}
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address))
{
return true;
}
else
{
return false;
}
}
/**
* \brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
* \return boolean true si email valide, false sinon
*/
function CheckMailDomain($mail)
{
list($user, $domain) = split("@", $mail, 2);
if (checkdnsrr($domain, "MX"))
{
return true;
}
else
{
return false;
}
}
/**
* \brief Return lines of an html table from an array
* \remarks Used by array2table function only

View File

@ -28,6 +28,7 @@
require("../../master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);

View File

@ -17,28 +17,24 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/telephonie/client/new.php
\ingroup telephonie
\brief Creation d'un nouveau client
\version $Revision$
\version $Id$
*/
require("pre.inc.php");
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
require_once(DOL_DOCUMENT_ROOT.'/companybankaccount.class.php');
require_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
require_once(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php");
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
$user->getrights('societe');
$langs->load("companies");
@ -143,7 +139,7 @@ if ($_POST["action"] == 'add')
$verif = "nok";
}
if (!check_mail(trim($contact->email)) && $verif == 'ok')
if (!CheckMailDomain(trim($contact->email)) && $verif == 'ok')
{
$mesg = "Email invalide (domaine invalide)";
$verif = "nok";
@ -248,7 +244,7 @@ if ($_POST["action"] == 'add')
$verif = "nok";
$mesg .= "Tarif France Invalide : $temporel > 0.04 !";
}
if ($temporel < 0.016 )
{
$error = 1031;
@ -396,7 +392,7 @@ if ($_POST["action"] == 'add')
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
@ -431,7 +427,7 @@ if ($_POST["action"] == 'add')
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = "0";
$ligne->note = $_POST["note"];
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
@ -469,7 +465,7 @@ if ($_POST["action"] == 'add')
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
@ -501,7 +497,7 @@ if ($_POST["action"] == 'add')
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
@ -562,25 +558,25 @@ if ($_POST["action"] == 'add')
if (!$error)
{
$db->begin();
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.")";
if (! $db->query($sql) )
{
$error++;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES ";
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.",now())";
if (! $db->query($sql) )
{
$error++;
}
if ( $error == 0 )
{
$db->commit();