Work on module socialnetworks

This commit is contained in:
Laurent Destailleur 2018-09-26 16:55:46 +02:00
parent 79ade6a1af
commit 98b1e13ed7
4 changed files with 85 additions and 15 deletions

View File

@ -186,6 +186,8 @@ if (empty($reshook))
$object->country_id = GETPOST("country_id",'int');
$object->state_id = GETPOST("state_id",'int');
$object->skype = GETPOST("skype",'alpha');
$object->twitter = GETPOST("twitter",'alpha');
$object->facebook = GETPOST("facebook",'alpha');
$object->email = GETPOST("email",'alpha');
$object->phone_pro = GETPOST("phone_pro",'alpha');
$object->phone_perso = GETPOST("phone_perso",'alpha');
@ -358,6 +360,8 @@ if (empty($reshook))
$object->email = GETPOST("email",'alpha');
$object->skype = GETPOST("skype",'alpha');
$object->twitter = GETPOST("twitter",'alpha');
$object->facebook = GETPOST("facebook",'alpha');
$object->phone_pro = GETPOST("phone_pro",'alpha');
$object->phone_perso = GETPOST("phone_perso",'alpha');
$object->phone_mobile = GETPOST("phone_mobile",'alpha');
@ -658,13 +662,28 @@ else
// Instant message and no email
print '<tr><td><label for="jabberid">'.$langs->trans("IM").'</label></td>';
print '<td colspan="3"><input name="jabberid" id="jabberid" type="text" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOST("jabberid",'alpha')?GETPOST("jabberid",'alpha'):$object->jabberid).'"></td></tr>';
print '<td colspan="3"><input name="jabberid" id="jabberid" type="text" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("jabberid")?GETPOST("jabberid",'alpha'):$object->jabberid).'"></td></tr>';
// Skype
if (! empty($conf->skype->enabled))
if (! empty($conf->socialnetworks->enabled))
{
print '<tr><td><label for="skype">'.$langs->trans("Skype").'</label></td>';
print '<td colspan="3"><input name="skype" id="skype" type="text" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOST("skype",'alpha')?GETPOST("skype",'alpha'):$object->skype).'"></td></tr>';
// Skype
if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
{
print '<tr><td><label for="skype">'.fieldLabel('Skype','skype').'</label></td>';
print '<td colspan="3"><input type="text" name="skype" id="skype" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype",'alpha'):$object->skype).'"></td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td><label for="twitter">'.fieldLabel('Twitter','twitter').'</label></td>';
print '<td colspan="3"><input type="text" name="twitter" id="twitter" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter",'alpha'):$object->twitter).'"></td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td><label for="facebook">'.fieldLabel('Facebook','facebook').'</label></td>';
print '<td colspan="3"><input type="text" name="facebook" id="facebook" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("facebook")?GETPOST("facebook",'alpha'):$object->facebook).'"></td></tr>';
}
}
// Visibility
@ -914,11 +933,26 @@ else
}
print '</tr>';
// Skype
if (! empty($conf->skype->enabled))
if (! empty($conf->socialnetworks->enabled))
{
print '<tr><td><label for="skype">'.$langs->trans("Skype").'</label></td>';
print '<td><input name="skype" id="skype" type="text" class="minwidth100" maxlength="80" value="'.(isset($_POST["skype"])?GETPOST("skype"):$object->skype).'"></td></tr>';
// Skype
if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
{
print '<tr><td><label for="skype">'.fieldLabel('Skype','skype').'</label></td>';
print '<td><input type="text" name="skype" id="skype" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype",'alpha'):$object->skype).'"></td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td><label for="twitter">'.fieldLabel('Twitter','twitter').'</label></td>';
print '<td><input type="text" name="twitter" id="twitter" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter",'alpha'):$object->twitter).'"></td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td><label for="facebook">'.fieldLabel('Facebook','facebook').'</label></td>';
print '<td><input type="text" name="facebook" id="facebook" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOST("facebook")?GETPOST("facebook",'alpha'):$object->facebook).'"></td></tr>';
}
}
// Visibility

View File

@ -354,6 +354,8 @@ class Contact extends CommonObject
$sql .= ", fax='".$this->db->escape($this->fax)."'";
$sql .= ", email='".$this->db->escape($this->email)."'";
$sql .= ", skype='".$this->db->escape($this->skype)."'";
$sql .= ", twitter='".$this->db->escape($this->twitter)."'";
$sql .= ", facebook='".$this->db->escape($this->facebook)."'";
$sql .= ", photo='".$this->db->escape($this->photo)."'";
$sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
$sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
@ -441,6 +443,16 @@ class Contact extends CommonObject
$tmpobj->skype = $this->skype;
$usermustbemodified++;
}
if ($tmpobj->twitter != $this->twitter)
{
$tmpobj->twitter = $this->twitter;
$usermustbemodified++;
}
if ($tmpobj->facebook != $this->facebook)
{
$tmpobj->facebook = $this->facebook;
$usermustbemodified++;
}
if ($usermustbemodified)
{
$result=$tmpobj->update($user, 0, 1, 1, 1);
@ -690,7 +702,7 @@ class Contact extends CommonObject
$sql.= " c.fk_pays as country_id,";
$sql.= " c.fk_departement,";
$sql.= " c.birthday,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,";
$sql.= " c.photo,";
$sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,";
$sql.= " c.import_key,";
@ -756,6 +768,8 @@ class Contact extends CommonObject
$this->email = $obj->email;
$this->jabberid = $obj->jabberid;
$this->skype = $obj->skype;
$this->twitter = $obj->twitter;
$this->facebook = $obj->facebook;
$this->photo = $obj->photo;
$this->priv = $obj->priv;
$this->mail = $obj->email;

View File

@ -1244,7 +1244,7 @@ else
print '</td></tr>';
}
// Email web
// Email / Web
print '<tr><td>'.fieldLabel('EMail','email',$conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
print '<td colspan="3"><input type="text" name="email" id="email" value="'.$object->email.'"></td></tr>';
print '<tr><td>'.fieldLabel('Web','url').'</td>';
@ -1256,19 +1256,19 @@ else
if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
{
print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
print '<td colspan="3"><input type="text" name="skype" class="minwidth100" maxlength="80" id="skype" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype",'alpha'):$object->skype).'"></td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td>'.fieldLabel('Twitter','twitter').'</td>';
print '<td colspan="3"><input type="text" name="twitter" id="twitter" value="'.$object->twitter.'"></td></tr>';
print '<td colspan="3"><input type="text" name="twitter" class="minwidth100" maxlength="80" id="twitter" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter",'alpha'):$object->twitter).'"></td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td>'.fieldLabel('Facebook','facebook').'</td>';
print '<td colspan="3"><input type="text" name="facebook" id="facebook" value="'.$object->facebook.'"></td></tr>';
print '<td colspan="3"><input type="text" name="facebook" class="minwidth100" maxlength="80" id="facebook" value="'.dol_escape_htmltag(GETPOSTISSET("facebook")?GETPOST("facebook",'alpha'):$object->facebook).'"></td></tr>';
}
}

View File

@ -186,6 +186,16 @@ class Societe extends CommonObject
* @var string
*/
public $skype;
/**
* Twitter username
* @var string
*/
public $twitter;
/**
* Facebook username
* @var string
*/
public $facebook;
/**
* Webpage
* @var string
@ -811,6 +821,8 @@ class Societe extends CommonObject
$this->fax = preg_replace("/\./","",$this->fax);
$this->email = trim($this->email);
$this->skype = trim($this->skype);
$this->twitter = trim($this->twitter);
$this->facebook = trim($this->facebook);
$this->url = $this->url?clean_url($this->url,0):'';
$this->note_private = trim($this->note_private);
$this->note_public = trim($this->note_public);
@ -934,6 +946,8 @@ class Societe extends CommonObject
$sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null");
$sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null");
$sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null");
$sql .= ",twitter = ".(! empty($this->twitter)?"'".$this->db->escape($this->twitter)."'":"null");
$sql .= ",facebook = ".(! empty($this->facebook)?"'".$this->db->escape($this->facebook)."'":"null");
$sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null");
$sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null");
@ -1059,6 +1073,8 @@ class Societe extends CommonObject
$lmember->address=$this->address;
$lmember->email=$this->email;
$lmember->skype=$this->skype;
$lmember->twitter=$this->twitter;
$lmember->facebook=$this->facebook;
$lmember->phone=$this->phone;
$result=$lmember->update($user,0,1,1,1); // Use nosync to 1 to avoid cyclic updates
@ -1162,7 +1178,7 @@ class Societe extends CommonObject
$sql .= ', s.status';
$sql .= ', s.price_level';
$sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif';
$sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur';
$sql .= ', s.phone, s.fax, s.email, s.skype, s.twitter, s.facebook, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur';
$sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6';
$sql .= ', s.capital, s.tva_intra';
$sql .= ', s.fk_typent as typent_id';
@ -1255,6 +1271,8 @@ class Societe extends CommonObject
$this->email = $obj->email;
$this->skype = $obj->skype;
$this->twitter = $obj->twitter;
$this->facebook = $obj->facebook;
$this->url = $obj->url;
$this->phone = $obj->phone;
$this->fax = $obj->fax;
@ -3221,6 +3239,8 @@ class Societe extends CommonObject
$this->phone=$member->phone; // Prof phone
$this->email=$member->email;
$this->skype=$member->skype;
$this->twitter=$member->twitter;
$this->facebook=$member->facebook;
$this->client = 1; // A member is a customer by default
$this->code_client = -1;
@ -3360,6 +3380,8 @@ class Societe extends CommonObject
$this->country_code='FR';
$this->email='specimen@specimen.com';
$this->skype='tom.hanson';
$this->twitter='tomhanson';
$this->facebook='tomhanson';
$this->url='http://www.specimen.com';
$this->phone='0909090901';