本文整理汇总了PHP中Adherent::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Adherent::update方法的具体用法?PHP Adherent::update怎么用?PHP Adherent::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adherent
的用法示例。
在下文中一共展示了Adherent::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update a user into database (and also password if this->pass is defined)
*
* @param User $user User qui fait la mise a jour
* @param int $notrigger 1 ne declenche pas les triggers, 0 sinon
* @param int $nosyncmember 0=Synchronize linked member (standard info), 1=Do not synchronize linked member
* @param int $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, $hookmanager;
$nbrowsaffected = 0;
$error = 0;
dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncmember=" . $nosyncmember . ", nosyncmemberpass=" . $nosyncmemberpass);
// Clean parameters
$this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname);
$this->employee = $this->employee ? $this->employee : 0;
$this->login = trim($this->login);
$this->gender = trim($this->gender);
$this->pass = trim($this->pass);
$this->api_key = trim($this->api_key);
$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->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->skype = trim($this->skype);
$this->job = trim($this->job);
$this->signature = trim($this->signature);
$this->note = trim($this->note);
$this->openid = trim(empty($this->openid) ? '' : $this->openid);
// Avoid warning
$this->admin = $this->admin ? $this->admin : 0;
$this->address = empty($this->address) ? '' : $this->address;
$this->zip = empty($this->zip) ? '' : $this->zip;
$this->town = empty($this->town) ? '' : $this->town;
$this->accountancy_code = trim($this->accountancy_code);
$this->color = empty($this->color) ? '' : $this->color;
// Check parameters
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorBadEMail", $this->email);
return -1;
}
if (empty($this->login)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFieldRequired", $this->login);
return -1;
}
$this->db->begin();
// Update datas
$sql = "UPDATE " . MAIN_DB_PREFIX . "user SET";
$sql .= " lastname = '" . $this->db->escape($this->lastname) . "'";
$sql .= ", firstname = '" . $this->db->escape($this->firstname) . "'";
$sql .= ", employee = " . $this->employee;
$sql .= ", login = '" . $this->db->escape($this->login) . "'";
$sql .= ", api_key = " . ($this->api_key ? "'" . $this->db->escape($this->api_key) . "'" : "null");
$sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null");
// 'man' or 'woman'
$sql .= ", admin = " . $this->admin;
$sql .= ", address = '" . $this->db->escape($this->address) . "'";
$sql .= ", zip = '" . $this->db->escape($this->zip) . "'";
$sql .= ", town = '" . $this->db->escape($this->town) . "'";
$sql .= ", fk_state = " . (!empty($this->state_id) && $this->state_id > 0 ? "'" . $this->db->escape($this->state_id) . "'" : "null");
$sql .= ", fk_country = " . (!empty($this->country_id) && $this->country_id > 0 ? "'" . $this->db->escape($this->country_id) . "'" : "null");
$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 .= ", skype = '" . $this->db->escape($this->skype) . "'";
$sql .= ", job = '" . $this->db->escape($this->job) . "'";
$sql .= ", signature = '" . $this->db->escape($this->signature) . "'";
$sql .= ", accountancy_code = '" . $this->db->escape($this->accountancy_code) . "'";
$sql .= ", color = '" . $this->db->escape($this->color) . "'";
$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 .= ", fk_user = " . ($this->fk_user > 0 ? "'" . $this->db->escape($this->fk_user) . "'" : "null");
if (isset($this->thm) || $this->thm != '') {
$sql .= ", thm= " . ($this->thm != '' ? "'" . $this->db->escape($this->thm) . "'" : "null");
}
if (isset($this->tjm) || $this->tjm != '') {
$sql .= ", tjm= " . ($this->tjm != '' ? "'" . $this->db->escape($this->tjm) . "'" : "null");
}
if (isset($this->salary) || $this->salary != '') {
$sql .= ", salary= " . ($this->salary != '' ? "'" . $this->db->escape($this->salary) . "'" : "null");
}
if (isset($this->salaryextra) || $this->salaryextra != '') {
$sql .= ", salaryextra= " . ($this->salaryextra != '' ? "'" . $this->db->escape($this->salaryextra) . "'" : "null");
}
$sql .= ", weeklyhours= " . ($this->weeklyhours != '' ? "'" . $this->db->escape($this->weeklyhours) . "'" : "null");
$sql .= ", entity = '" . $this->db->escape($this->entity) . "'";
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update", LOG_DEBUG);
//.........这里部分代码省略.........
示例2: 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);
//.........这里部分代码省略.........
示例3: 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;
//.........这里部分代码省略.........
示例4: testAdherentUpdate
/**
* testAdherentUpdate
*
* @param Adherent $localobject Member instance
* @return Adherent
*
* @depends testAdherentFetch
* The depends says test is run only if previous is ok
*/
public function testAdherentUpdate($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject->login='newlogin';
$localobject->societe='New company';
$localobject->note='New note after update';
//$localobject->note_public='New note public after update';
$localobject->lastname='New name';
$localobject->firstname='New firstname';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->country_id=2;
$localobject->statut=0;
$localobject->phone='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->email='newemail@newemail.com';
$result=$localobject->update($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Adherent($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertEquals($localobject->login, $newobject->login);
$this->assertEquals($localobject->societe, $newobject->societe);
$this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->lastname, $newobject->lastname);
$this->assertEquals($localobject->firstname, $newobject->firstname);
$this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->statut, $newobject->statut);
$this->assertEquals($localobject->phone, $newobject->phone);
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
$this->assertEquals($localobject->email, $newobject->email);
return $localobject;
}