本文整理汇总了PHP中isValidEMail函数的典型用法代码示例。如果您正苦于以下问题:PHP isValidEMail函数的具体用法?PHP isValidEMail怎么用?PHP isValidEMail使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isValidEMail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValidEMail
$urlok=preg_replace('/&$/','',$urlok); // Remove last &
$urlko=preg_replace('/&$/','',$urlko); // Remove last &
/*
* Actions
*/
if (GETPOST("action") == 'dopayment')
{
$PRICE=price2num(GETPOST("newamount"),'MT');
$email=GETPOST("email");
$mesg='';
if (empty($PRICE) || ! is_numeric($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount"));
elseif (empty($email)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail"));
elseif (! isValidEMail($email)) $mesg=$langs->trans("ErrorBadEMail",$email);
elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode"));
if (empty($mesg))
{
dol_syslog("newpayment.php call paybox api and do redirect", LOG_DEBUG);
print_paybox_redirect($PRICE, $conf->monnaie, $email, $urlok, $urlko, $FULLTAG);
session_destroy();
exit;
}
}
示例2: add_to_target
/**
* \brief Ajoute destinataires dans table des cibles
* \param mailing_id Id of emailing
* \param filterarray 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."/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 = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$file=$upload_dir . "/" . $_FILES['username']['name'];
$handle = @fopen($file, "r");
if ($handle)
{
$i = 0;
$j = 0;
$old = '';
while (!feof($handle))
{
$cpt++;
$buffer = trim(fgets($handle));
$tab=explode(';',$buffer,4);
$email=$tab[0];
$name=$tab[1];
$firstname=$tab[2];
$other=$tab[3];
if (! empty($buffer))
{
//print 'xx'.dol_strlen($buffer).empty($buffer)."<br>\n";
$id=$cpt;
if (isValidEMail($email))
{
if ($old <> $email)
{
$cibles[$j] = array(
'email' => $email,
'name' => $name,
'firstname' => $firstname,
'other' => $other,
'source_url' => '',
'source_id' => '',
'source_type' => 'file'
);
$old = $email;
$j++;
}
}
else
{
$i++;
$langs->load("errors");
$this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email);
}
}
}
fclose($handle);
if ($i > 0)
{
return -$i;
}
}
else
{
$this->error = $langs->trans("ErrorFaildToOpenFile");
return -1;
}
dol_syslog(get_class($this)."::add_to_target mailing ".$cpt." targets found");
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
$this->error = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
$this->error = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
}
//.........这里部分代码省略.........
示例3: update
/**
* Update a member in database (standard information and password)
* @param user User making update
* @param notrigger 1=disable trigger UPDATE (when called by create)
* @param nosyncuser 0=Synchronize linked user (standard info), 1=Do not synchronize linked user
* @param nosyncuserpass 0=Synchronize linked user (password), 1=Do not synchronize linked user
* @return int <0 si KO, >0 si OK
*/
function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0)
{
global $conf, $langs;
$nbrowsaffected = 0;
$error = 0;
dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncuser=" . $nosyncuser . ", nosyncuserpass=" . $nosyncuserpass . ", email=" . $this->email);
// Clean parameters
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
$this->nom = ucwords(trim($this->nom));
}
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
$this->prenom = ucwords(trim($this->prenom));
}
// Check parameters
if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
return -1;
}
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
$sql .= " civilite = " . ($this->civilite_id ? "'" . $this->civilite_id . "'" : "null");
$sql .= ", prenom = " . ($this->prenom ? "'" . $this->db->escape($this->prenom) . "'" : "null");
$sql .= ", nom=" . ($this->nom ? "'" . $this->db->escape($this->nom) . "'" : "null");
$sql .= ", login=" . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null");
$sql .= ", societe=" . ($this->societe ? "'" . $this->db->escape($this->societe) . "'" : "null");
$sql .= ", fk_soc=" . ($this->fk_soc > 0 ? "'" . $this->fk_soc . "'" : "null");
$sql .= ", adresse=" . ($this->adresse ? "'" . $this->db->escape($this->adresse) . "'" : "null");
$sql .= ", cp=" . ($this->cp ? "'" . $this->db->escape($this->cp) . "'" : "null");
$sql .= ", ville=" . ($this->ville ? "'" . $this->db->escape($this->ville) . "'" : "null");
$sql .= ", pays=" . ($this->pays_id > 0 ? "'" . $this->pays_id . "'" : "null");
$sql .= ", fk_departement=" . ($this->fk_departement > 0 ? "'" . $this->fk_departement . "'" : "null");
$sql .= ", email=" . "'" . $this->email . "'";
$sql .= ", phone=" . ($this->phone ? "'" . $this->db->escape($this->phone) . "'" : "null");
$sql .= ", phone_perso=" . ($this->phone_perso ? "'" . $this->db->escape($this->phone_perso) . "'" : "null");
$sql .= ", phone_mobile=" . ($this->phone_mobile ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null");
$sql .= ", note=" . ($this->note ? "'" . $this->db->escape($this->note) . "'" : "null");
$sql .= ", photo=" . ($this->photo ? "'" . $this->photo . "'" : "null");
$sql .= ", public=" . "'" . $this->public . "'";
$sql .= ", statut=" . $this->statut;
$sql .= ", fk_adherent_type=" . $this->typeid;
$sql .= ", morphy=" . "'" . $this->morphy . "'";
$sql .= ", naiss=" . ($this->naiss ? "'" . $this->db->idate($this->naiss) . "'" : "null");
if ($this->datefin) {
$sql .= ", datefin='" . $this->db->idate($this->datefin) . "'";
}
// Ne doit etre modifie que par effacement cotisation
if ($this->datevalid) {
$sql .= ", datevalid='" . $this->db->idate($this->datevalid) . "'";
}
// Ne doit etre modifie que par validation adherent
$sql .= ", fk_user_mod=" . ($user->id > 0 ? $user->id : 'null');
// Can be null because member can be create by a guest
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update update member sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql) {
$nbrowsaffected += $this->db->affected_rows($resql);
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
// Update password
if (!$error && $this->pass) {
dol_syslog(get_class($this) . "::update update password");
if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
// Si mot de passe saisi et different de celui en base
$result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncuserpass);
if (!$nbrowsaffected) {
$nbrowsaffected++;
}
}
}
// Remove link to user
if (!$error) {
dol_syslog(get_class($this) . "::update update link to user");
$sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
$this->db->rollback();
return -5;
}
// If there is a user linked to this member
if ($this->user_id > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id . " WHERE rowid = " . $this->user_id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
$this->db->rollback();
//.........这里部分代码省略.........
示例4: preg_replace
$urlko = preg_replace('/&$/', '', $urlko);
// Remove last &
// Check security token
$valid = true;
/*
* Actions
*/
if (GETPOST("action") == 'dopayment') {
$PRICE = price2num(GETPOST("newamount"), 'MT');
$email = GETPOST("email");
$mesg = '';
if (empty($PRICE) || !is_numeric($PRICE)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount"));
} elseif (empty($email)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("YourEMail"));
} elseif (!isValidEMail($email)) {
$mesg = $langs->trans("ErrorBadEMail", $email);
} elseif (empty($FULLTAG)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentCode"));
} elseif (dol_strlen($urlok) > 150) {
$mesg = 'Error urlok too long ' . $urlok;
} elseif (dol_strlen($urlko) > 150) {
$mesg = 'Error urlko too long ' . $urlko;
}
if (empty($mesg)) {
dol_syslog("newpayment.php call paybox api and do redirect", LOG_DEBUG);
print_paybox_redirect($PRICE, $conf->currency, $email, $urlok, $urlko, $FULLTAG);
session_destroy();
exit;
}
}
示例5: update
/**
* Create or Update an user into database
*
* @param User $user Objet user qui demande la creation
* @param int $notrigger 1 ne declenche pas les triggers, 0 sinon
* @return int <0 si KO, id compte cree si OK
*/
function update($user, $notrigger = 0, $action) {
global $conf, $langs;
global $mysoc;
// Clean parameters
$this->values->name = trim($this->values->name);
dol_syslog(get_class($this) . "::create login=" . $this->values->name . ", user=" . (is_object($user) ? $user->id : ''), LOG_DEBUG);
// Check parameters
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->values->EMail)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->values->Email);
return -1;
}
$this->values->CreateDate = dol_now();
trim($this->values->pass);
$error = 0;
try {
$result = $this->couchAdmin->getUser($this->values->name);
} catch (Exception $e) {
}
if (isset($result->name) && $action == 'add') {
$this->error = 'ErrorLoginAlreadyExists';
dol_syslog(get_class($this) . "::create " . $this->error, LOG_WARNING);
return -6;
} else {
if ($action == 'add') {
$this->values->Status = "DISABLE";
try {
$this->couchAdmin->createUser($this->values->name, $this->values->pass);
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR);
dol_print_error("", $this->error);
exit;
return -4;
}
}
}
try {
$user_tmp = $this->couchAdmin->getUser($this->values->name);
$this->values->salt = $user_tmp->salt;
$this->values->password_sha = $user_tmp->password_sha;
$this->values->type = $user_tmp->type;
$this->values->roles = $user_tmp->roles;
$this->values->_id = $user_tmp->_id;
$this->values->_rev = $user_tmp->_rev;
$this->values->Status = $user_tmp->Status;
$caneditpassword = ((($user->login == $this->values->name) && $user->rights->user->self->password)
|| (($user->login != $this->values->name) && $user->rights->user->user->password)) || $user->admin;
if ($caneditpassword && !empty($this->values->pass)) { // Case we can edit only password
$this->values->password_sha = sha1($this->values->pass . $this->values->salt, false);
}
unset($this->values->pass);
$this->couchdb->clean($this->values);
//print_r($this->values);exit;
$result = $this->couchdb->storeDoc($this->values); // Save all specific parameters
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR);
dol_print_error("", $this->error);
exit;
return -3;
}
if ($result) {
$this->id = $this->values->name;
if (!$notrigger) {
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('USER_CREATE', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
//.........这里部分代码省略.........
示例6: update
/**
* Update a member in database (standard information and password)
*
* @param User $user User making update
* @param int $notrigger 1=disable trigger UPDATE (when called by create)
* @param int $nosyncuser 0=Synchronize linked user (standard info), 1=Do not synchronize linked user
* @param int $nosyncuserpass 0=Synchronize linked user (password), 1=Do not synchronize linked user
* @param int $nosyncthirdparty 0=Synchronize linked thirdparty (standard info), 1=Do not synchronize linked thirdparty
* @param string $action Current action for hookmanager
* @return int <0 if KO, >0 if OK
*/
function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update')
{
global $conf, $langs, $hookmanager;
$nbrowsaffected = 0;
$error = 0;
dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncuser=" . $nosyncuser . ", nosyncuserpass=" . $nosyncuserpass . " nosyncthirdparty=" . $nosyncthirdparty . ", email=" . $this->email);
// Clean parameters
$this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
$this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
$this->address = $this->address ? $this->address : $this->address;
$this->zip = $this->zip ? $this->zip : $this->zip;
$this->town = $this->town ? $this->town : $this->town;
$this->country_id = $this->country_id > 0 ? $this->country_id : $this->country_id;
$this->state_id = $this->state_id > 0 ? $this->state_id : $this->state_id;
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
$this->lastname = ucwords(trim($this->lastname));
}
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
$this->firstname = ucwords(trim($this->firstname));
}
// Check parameters
if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
return -1;
}
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
$sql .= " civility = " . (!is_null($this->civility_id) ? "'" . $this->civility_id . "'" : "null");
$sql .= ", firstname = " . ($this->firstname ? "'" . $this->db->escape($this->firstname) . "'" : "null");
$sql .= ", lastname=" . ($this->lastname ? "'" . $this->db->escape($this->lastname) . "'" : "null");
$sql .= ", login=" . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null");
$sql .= ", societe=" . ($this->societe ? "'" . $this->db->escape($this->societe) . "'" : "null");
$sql .= ", fk_soc=" . ($this->fk_soc > 0 ? "'" . $this->fk_soc . "'" : "null");
$sql .= ", address=" . ($this->address ? "'" . $this->db->escape($this->address) . "'" : "null");
$sql .= ", zip=" . ($this->zip ? "'" . $this->db->escape($this->zip) . "'" : "null");
$sql .= ", town=" . ($this->town ? "'" . $this->db->escape($this->town) . "'" : "null");
$sql .= ", country=" . ($this->country_id > 0 ? "'" . $this->country_id . "'" : "null");
$sql .= ", state_id=" . ($this->state_id > 0 ? "'" . $this->state_id . "'" : "null");
$sql .= ", email='" . $this->email . "'";
$sql .= ", skype='" . $this->skype . "'";
$sql .= ", phone=" . ($this->phone ? "'" . $this->db->escape($this->phone) . "'" : "null");
$sql .= ", phone_perso=" . ($this->phone_perso ? "'" . $this->db->escape($this->phone_perso) . "'" : "null");
$sql .= ", phone_mobile=" . ($this->phone_mobile ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null");
$sql .= ", note_private=" . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null");
$sql .= ", note_public=" . ($this->note_private ? "'" . $this->db->escape($this->note_public) . "'" : "null");
$sql .= ", photo=" . ($this->photo ? "'" . $this->photo . "'" : "null");
$sql .= ", public='" . $this->public . "'";
$sql .= ", statut=" . $this->statut;
$sql .= ", fk_adherent_type=" . $this->typeid;
$sql .= ", morphy='" . $this->morphy . "'";
$sql .= ", birth=" . ($this->birth ? "'" . $this->db->idate($this->birth) . "'" : "null");
if ($this->datefin) {
$sql .= ", datefin='" . $this->db->idate($this->datefin) . "'";
}
// Ne doit etre modifie que par effacement cotisation
if ($this->datevalid) {
$sql .= ", datevalid='" . $this->db->idate($this->datevalid) . "'";
}
// Ne doit etre modifie que par validation adherent
$sql .= ", fk_user_mod=" . ($user->id > 0 ? $user->id : 'null');
// Can be null because member can be create by a guest
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update update member", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
$nbrowsaffected += $this->db->affected_rows($resql);
$action = 'update';
// Actions on extra fields (by external module)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('memberdao'));
$parameters = array('id' => $this->id);
$action = '';
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
} else {
if ($reshook < 0) {
$error++;
//.........这里部分代码省略.........
示例7: update
/**
* Update parameters of third party
*
* @param int $id id societe
* @param User $user Utilisateur qui demande la mise a jour
* @param int $call_trigger 0=non, 1=oui
* @param int $allowmodcodeclient Inclut modif code client et code compta
* @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur
* @param string $action 'add' or 'update'
* @param int $nosyncmember Do not synchronize info of linked member
* @return int <0 if KO, >=0 if OK
*/
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1)
{
global $langs,$conf,$hookmanager;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$error=0;
dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
$now=dol_now();
// Clean parameters
$this->id = $id;
$this->name = $this->name?trim($this->name):trim($this->nom);
$this->nom = $this->name; // For backward compatibility
$this->name_alias = trim($this->name_alias);
$this->ref_ext = trim($this->ref_ext);
$this->address = $this->address?trim($this->address):trim($this->address);
$this->zip = $this->zip?trim($this->zip):trim($this->zip);
$this->town = $this->town?trim($this->town):trim($this->town);
$this->state_id = trim($this->state_id);
$this->country_id = ($this->country_id > 0)?$this->country_id:0;
$this->phone = trim($this->phone);
$this->phone = preg_replace("/\s/","",$this->phone);
$this->phone = preg_replace("/\./","",$this->phone);
$this->fax = trim($this->fax);
$this->fax = preg_replace("/\s/","",$this->fax);
$this->fax = preg_replace("/\./","",$this->fax);
$this->email = trim($this->email);
$this->skype = trim($this->skype);
$this->url = $this->url?clean_url($this->url,0):'';
$this->idprof1 = trim($this->idprof1);
$this->idprof2 = trim($this->idprof2);
$this->idprof3 = trim($this->idprof3);
$this->idprof4 = trim($this->idprof4);
$this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):'');
$this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):'');
$this->prefix_comm = trim($this->prefix_comm);
$this->tva_assuj = trim($this->tva_assuj);
$this->tva_intra = dol_sanitizeFileName($this->tva_intra,'');
if (empty($this->status)) $this->status = 0;
if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency))
{
$this->multicurrency_code = '';
$this->fk_multicurrency = 0;
}
// Local taxes
$this->localtax1_assuj=trim($this->localtax1_assuj);
$this->localtax2_assuj=trim($this->localtax2_assuj);
$this->localtax1_value=trim($this->localtax1_value);
$this->localtax2_value=trim($this->localtax2_value);
if ($this->capital != '') $this->capital=price2num(trim($this->capital));
if (! is_numeric($this->capital)) $this->capital = ''; // '' = undef
$this->effectif_id=trim($this->effectif_id);
$this->forme_juridique_code=trim($this->forme_juridique_code);
//Gencod
$this->barcode=trim($this->barcode);
// For automatic creation
if ($this->code_client == -1) $this->get_codeclient($this,0);
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1);
$this->code_compta=trim($this->code_compta);
$this->code_compta_fournisseur=trim($this->code_compta_fournisseur);
// Check parameters
if (! empty($conf->global->SOCIETE_MAIL_REQUIRED) && ! isValidEMail($this->email))
{
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail",$this->email);
return -1;
}
if (! is_numeric($this->client) && ! is_numeric($this->fournisseur))
{
$langs->load("errors");
$this->error = $langs->trans("BadValueForParameterClientOrSupplier");
return -1;
}
$customer=false;
//.........这里部分代码省略.........
示例8: update
/**
* Update parameters of third party
* @param id id societe
* @param user Utilisateur qui demande la mise a jour
* @param call_trigger 0=non, 1=oui
* @param allowmodcodeclient Inclut modif code client et code compta
* @param allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur
* @return int <0 if KO, >=0 if OK
*/
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
{
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
global $langs,$conf;
dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
// For triggers
if ($call_trigger)
{
$objectstatic=new Societe($this->db);
$objectstatic->fetch($id);
$this->oldobject = $objectstatic;
}
$now=dol_now();
// Clean parameters
$this->id=$id;
$this->name=$this->name?trim($this->name):trim($this->nom);
$this->nom=trim($this->nom); // TODO obsolete
$this->address=$this->address?trim($this->address):trim($this->adresse);
$this->adresse=$this->address; // TODO obsolete
$this->zip=$this->zip?trim($this->zip):trim($this->cp);
$this->cp=$this->zip; // TODO obsolete
$this->town=$this->town?trim($this->town):trim($this->ville);
$this->ville=$this->town; // TODO obsolete
$this->departement_id=trim($this->departement_id);
$this->pays_id=trim($this->pays_id);
$this->tel=trim($this->tel);
$this->fax=trim($this->fax);
$this->tel = preg_replace("/\s/","",$this->tel);
$this->tel = preg_replace("/\./","",$this->tel);
$this->fax = preg_replace("/\s/","",$this->fax);
$this->fax = preg_replace("/\./","",$this->fax);
$this->email=trim($this->email);
$this->url=$this->url?clean_url($this->url,0):'';
$this->siren=trim($this->siren);
$this->siret=trim($this->siret);
$this->ape=trim($this->ape);
$this->idprof4=trim($this->idprof4);
$this->prefix_comm=trim($this->prefix_comm);
$this->tva_assuj=trim($this->tva_assuj);
$this->tva_intra=dol_sanitizeFileName($this->tva_intra,'');
if (empty($this->status)) $this->status = 0;
// Local taxes
$this->localtax1_assuj=trim($this->localtax1_assuj);
$this->localtax2_assuj=trim($this->localtax2_assuj);
$this->capital=price2num(trim($this->capital),'MT');
if (empty($this->capital)) $this->capital = 0;
$this->effectif_id=trim($this->effectif_id);
$this->forme_juridique_code=trim($this->forme_juridique_code);
//Gencod
$this->gencod=trim($this->gencod);
// For automatic creation
if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0);
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1);
$this->code_compta=trim($this->code_compta);
$this->code_compta_fournisseur=trim($this->code_compta_fournisseur);
// Check parameters
if (! empty($conf->global->SOCIETE_MAIL_REQUIRED) && ! isValidEMail($this->email))
{
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail",$this->email);
return -1;
}
$this->db->begin();
// Check name is required and codes are ok or unique.
// If error, this->errors[] is filled
$result = $this->verify();
if ($result >= 0)
{
dol_syslog("Societe::Update verify ok");
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
$sql.= ",datea = '".$this->db->idate($now)."'";
$sql.= ",address = '" . $this->db->escape($this->address) ."'";
//.........这里部分代码省略.........
示例9: update
/**
* Update a user into databse (and also password if this->pass is defined)
* @param user User qui fait la mise a jour
* @param notrigger 1 ne declenche pas les triggers, 0 sinon
* @param nosyncmember 0=Synchronize linked member (standard info), 1=Do not synchronize linked member
* @param nosyncmemberpass 0=Synchronize linked member (password), 1=Do not synchronize linked member
* @return int <0 si KO, >=0 si OK
*/
function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0)
{
global $conf, $langs;
$nbrowsaffected = 0;
$error = 0;
dol_syslog("User::update notrigger=" . $notrigger . ", nosyncmember=" . $nosyncmember . ", nosyncmemberpass=" . $nosyncmemberpass);
// Clean parameters
$this->nom = trim($this->nom);
$this->prenom = trim($this->prenom);
$this->login = trim($this->login);
$this->pass = trim($this->pass);
$this->office_phone = trim($this->office_phone);
$this->office_fax = trim($this->office_fax);
$this->user_mobile = trim($this->user_mobile);
$this->email = trim($this->email);
$this->signature = trim($this->signature);
$this->note = trim($this->note);
$this->openid = trim(empty($this->openid) ? '' : $this->openid);
// Avoid warning
$this->webcal_login = trim($this->webcal_login);
$this->phenix_login = trim($this->phenix_login);
if ($this->phenix_pass != $this->phenix_pass_crypted) {
$this->phenix_pass = md5(trim($this->phenix_pass));
}
$this->admin = $this->admin ? $this->admin : 0;
// Check parameters
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
return -1;
}
$this->db->begin();
// Mise a jour autres infos
$sql = "UPDATE " . MAIN_DB_PREFIX . "user SET";
$sql .= " name = '" . $this->db->escape($this->nom) . "'";
$sql .= ", firstname = '" . $this->db->escape($this->prenom) . "'";
$sql .= ", login = '" . $this->db->escape($this->login) . "'";
$sql .= ", admin = " . $this->admin;
$sql .= ", office_phone = '" . $this->db->escape($this->office_phone) . "'";
$sql .= ", office_fax = '" . $this->db->escape($this->office_fax) . "'";
$sql .= ", user_mobile = '" . $this->db->escape($this->user_mobile) . "'";
$sql .= ", email = '" . $this->db->escape($this->email) . "'";
$sql .= ", signature = '" . addslashes($this->signature) . "'";
$sql .= ", webcal_login = '" . $this->db->escape($this->webcal_login) . "'";
$sql .= ", phenix_login = '" . $this->db->escape($this->phenix_login) . "'";
$sql .= ", phenix_pass = '" . $this->db->escape($this->phenix_pass) . "'";
$sql .= ", note = '" . $this->db->escape($this->note) . "'";
$sql .= ", photo = " . ($this->photo ? "'" . $this->db->escape($this->photo) . "'" : "null");
$sql .= ", openid = " . ($this->openid ? "'" . $this->db->escape($this->openid) . "'" : "null");
$sql .= ", entity = '" . $this->entity . "'";
$sql .= " WHERE rowid = " . $this->id;
dol_syslog("User::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$nbrowsaffected += $this->db->affected_rows($resql);
// Update password
if ($this->pass) {
if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
// Si mot de passe saisi et different de celui en base
$result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass);
if (!$nbrowsaffected) {
$nbrowsaffected++;
}
}
}
// If user is linked to a member, remove old link to this member
if ($this->fk_member > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL where fk_member = " . $this->fk_member;
dol_syslog("User::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
$this->db->rollback();
return -5;
}
}
// Set link to user
$sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member =" . ($this->fk_member > 0 ? $this->fk_member : 'null') . " where rowid = " . $this->id;
dol_syslog("User::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
$this->db->rollback();
return -5;
}
if ($nbrowsaffected) {
if ($this->fk_member > 0 && !$nosyncmember) {
require_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent.class.php";
// This user is linked with a member, so we also update members informations
// if this is an update.
$adh = new Adherent($this->db);
$result = $adh->fetch($this->fk_member);
//.........这里部分代码省略.........
示例10: ucwords
$langs->load("errors");
$error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_id)." ".$langs->trans("ErrorProdIdAlreadyExist", $_POST[$slabel]);
$action = ($action=='add'?'create':'edit');
}
}
} */
}
if (!$error) {
if ($action == 'add') {
if (!empty($conf->global->MAIN_FIRST_TO_UPPER))
$object->name = ucwords($object->name);
dol_syslog(get_class($object) . "::create " . $object->name);
// Check parameters
if (!empty($conf->global->SOCIETE_MAIL_REQUIRED) && !isValidEMail($object->email)) {
$langs->load("errors");
$message = $langs->trans("ErrorBadEMail", $object->email);
return -1;
}
$object->tms = dol_now();
// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
if ($object->Accounting->CustomCode == -1)
$compta->setCode("CustomerCode", $object->get_codeclient($object->prefix_comm, 0));
if ($object->Accounting->SupplierCode == -1)
$compta->setCode("SupplierCode", $object->get_codefournisseur($object->prefix_comm, 1));
if (!$message) {
try {
示例11: doActions
/**
* Load data control
*/
function doActions($socid)
{
global $conf, $user, $langs;
if ($_POST["getcustomercode"])
{
// We defined value code_client
$_POST["code_client"]="Acompleter";
}
if ($_POST["getsuppliercode"])
{
// We defined value code_fournisseur
$_POST["code_fournisseur"]="Acompleter";
}
// Add new third party
if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
&& ($_POST["action"] == 'add' || $_POST["action"] == 'update'))
{
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
$error=0;
if ($_POST["action"] == 'update')
{
// Load properties of company
$this->object->fetch($socid);
}
if ($_REQUEST["private"] == 1)
{
$this->object->particulier = $_REQUEST["private"];
$this->object->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]);
$this->object->nom_particulier = $_POST["nom"];
$this->object->prenom = $_POST["prenom"];
$this->object->civilite_id = $_POST["civilite_id"];
}
else
{
$this->object->nom = $_POST["nom"];
}
$this->object->address = $_POST["adresse"];
$this->object->adresse = $_POST["adresse"]; // TODO obsolete
$this->object->cp = $_POST["zipcode"];
$this->object->ville = $_POST["town"];
$this->object->pays_id = $_POST["pays_id"];
$this->object->departement_id = $_POST["departement_id"];
$this->object->tel = $_POST["tel"];
$this->object->fax = $_POST["fax"];
$this->object->email = trim($_POST["email"]);
$this->object->url = $_POST["url"];
$this->object->siren = $_POST["idprof1"];
$this->object->siret = $_POST["idprof2"];
$this->object->ape = $_POST["idprof3"];
$this->object->idprof4 = $_POST["idprof4"];
$this->object->prefix_comm = $_POST["prefix_comm"];
$this->object->code_client = $_POST["code_client"];
$this->object->code_fournisseur = $_POST["code_fournisseur"];
$this->object->capital = $_POST["capital"];
$this->object->gencod = $_POST["gencod"];
$this->object->canvas = $_REQUEST["canvas"];
$this->object->tva_assuj = $_POST["assujtva_value"];
// Local Taxes
$this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
$this->object->tva_intra = $_POST["tva_intra"];
$this->object->forme_juridique_code = $_POST["forme_juridique_code"];
$this->object->effectif_id = $_POST["effectif_id"];
if ($_REQUEST["private"] == 1)
{
$this->object->typent_id = 8; // TODO predict another method if the field "special" change of rowid
}
else
{
$this->object->typent_id = $_POST["typent_id"];
}
$this->object->client = $_POST["client"];
$this->object->fournisseur = $_POST["fournisseur"];
$this->object->fournisseur_categorie = $_POST["fournisseur_categorie"];
$this->object->commercial_id = $_POST["commercial_id"];
$this->object->default_lang = $_POST["default_lang"];
// Check parameters
if (empty($_POST["cancel"]))
{
if (! empty($this->object->email) && ! isValidEMail($this->object->email))
{
$error = 1;
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail",$this->object->email);
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
//.........这里部分代码省略.........
示例12: setEventMessages
if ($morphy != 'mor' && empty($lastname)) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
}
if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
}
if (!($typeid > 0)) {
// Keep () before !
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
}
if ($conf->global->ADHERENT_MAIL_REQUIRED && !isValidEMail($email)) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
}
$public = 0;
if (isset($public)) {
$public = 1;
}
if (!$error) {
$db->begin();
// Email a peu pres correct et le login n'existe pas
$result = $object->create($user);
if ($result > 0) {
// Categories association
$memcats = GETPOST('memcats', 'array');
示例13: _createTiers
function _createTiers(&$db, &$user, &$ad)
{
$societe = new Societe($db);
$name = trim($ad->firstname . ' ' . $ad->lastname);
if (!empty($name)) {
$name .= ' / ' . $ad->societe;
} else {
$name = $ad->societe;
}
$societe->name = $name;
$societe->client = 1;
if (!empty($ad->email) && isValidEMail($ad->email)) {
$societe->email = $ad->email;
}
$societe->address = $ad->address;
$societe->zip = $ad->zip;
$societe->town = $ad->town;
$societe->state_id = $ad->state_id;
$societe->country_id = $ad->country_id;
$societe->phone = $ad->phone;
if ($societe->create($user) > 0) {
$ad->fk_soc = $societe->id;
return $societe;
} else {
return false;
}
}
开发者ID:ATM-Consulting,项目名称:dolibarr_module_sendinvoicetoadherent,代码行数:27,代码来源:sendinvoicetoadherent.php
示例14: update
/**
* Update parameters of third party
*
* @param int $id id societe
* @param User $user Utilisateur qui demande la mise a jour
* @param int $call_trigger 0=non, 1=oui
* @param int $allowmodcodeclient Inclut modif code client et code compta
* @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur
* @param string $action 'create' or 'update'
* @return int <0 if KO, >=0 if OK
*/
function update($user = '', $call_trigger = 1, $allowmodcodeclient = 0, $allowmodcodefournisseur = 0, $action = 'update') {
global $langs, $conf;
require_once(DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php");
$error = 0;
// For triggers
//if ($call_trigger) $this->oldobject = dol_clone($this);
// Check parameters
if (!empty($conf->global->SOCIETE_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
return -1;
}
// Check name is required and codes are ok or unique.
// If error, this->errors[] is filled
$result = $this->verify();
if ($result >= 0) {
dol_syslog(get_class($this) . "::Update verify ok");
unset($this->nom); //TODO supprimer
unset($this->departement); //TODO supprimer
unset($this->country_code); // TODO supprimer
parent::update($user);
dol_syslog(get_class($this) . "::Update json=" . json_encode($this));
//TODO - faire la suite...
return 1;
if ($resql) {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
// Si le fournisseur est classe on l'ajoute
$this->AddFournisseurInCategory($this->fournisseur_categorie);
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php');
$hookmanager = new HookManager($this->db);
$hookmanager->initHooks(array('thirdparty_extrafields'));
$parameters = array('socid' => $this->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
} else if ($reshook < 0)
$error++;
if (!$error && $call_trigger) {
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('COMPANY_MODIFY', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
if (!$error) {
dol_syslog(get_class($this) . "::Update success");
return 1;
} else {
return -1;
}
} else {
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
// Doublon
$this->error = $langs->trans("ErrorDuplicateField");
$result = -1;
} else {
$this->error = $langs->trans("Error sql=" . $sql);
dol_syslog(get_class($this) . "::Update fails update sql=" . $sql, LOG_ERR);
$result = -2;
}
return $result;
}
} else {
dol_syslog(get_class($this) . "::Update fails verify " . join(',', $this->errors), LOG_WARNING);
return -3;
}
//.........这里部分代码省略.........
示例15: add_to_target
/**
* 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';
$tmparray = explode(';', GETPOST('xinputuser'));
$email = $tmparray[0];
$lastname = $tmparray[1];
$firstname = $tmparray[2];
$other = $tmparray[3];
$cibles = array();
if (!empty($email)) {
if (isValidEMail($email)) {
$cibles[] = array('email' => $email, 'lastname' => $lastname, 'firstname' => $firstname, 'other' => $other, 'source_url' => '', 'source_id' => '', 'source_type' => 'file');
return parent::add_to_target($mailing_id, $cibles);
} else {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $email);
return -1;
}
} else {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEmail", $email);
return -1;
}
}