forked from Wavyzz/dolibarr
new migration script for members
This commit is contained in:
@@ -4944,8 +4944,8 @@ and rowid in (...)
|
|||||||
function migrate_users_socialnetworks()
|
function migrate_users_socialnetworks()
|
||||||
{
|
{
|
||||||
global $db, $langs;
|
global $db, $langs;
|
||||||
// skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp
|
// skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$db->begin();
|
$db->begin();
|
||||||
print '<tr><td colspan="4">';
|
print '<tr><td colspan="4">';
|
||||||
$sql = 'SELECT rowid, socialnetworks';
|
$sql = 'SELECT rowid, socialnetworks';
|
||||||
@@ -4963,59 +4963,59 @@ function migrate_users_socialnetworks()
|
|||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
while ($obj = $db->fetch_object($resql)) {
|
||||||
$arraysocialnetworks = array();
|
$arraysocialnetworks = array();
|
||||||
if (!empty($obj->skype)) {
|
if (!empty($obj->skype)) {
|
||||||
$arraysocialnetworks['skype'] = $obj->skype;
|
$arraysocialnetworks['skype'] = $obj->skype;
|
||||||
}
|
}
|
||||||
if (!empty($obj->twitter)) {
|
if (!empty($obj->twitter)) {
|
||||||
$arraysocialnetworks['twitter'] = $obj->twitter;
|
$arraysocialnetworks['twitter'] = $obj->twitter;
|
||||||
}
|
}
|
||||||
if (!empty($obj->facebook)) {
|
if (!empty($obj->facebook)) {
|
||||||
$arraysocialnetworks['facebook'] = $obj->facebook;
|
$arraysocialnetworks['facebook'] = $obj->facebook;
|
||||||
}
|
}
|
||||||
if (!empty($obj->linkedin)) {
|
if (!empty($obj->linkedin)) {
|
||||||
$arraysocialnetworks['linkedin'] = $obj->linkedin;
|
$arraysocialnetworks['linkedin'] = $obj->linkedin;
|
||||||
}
|
}
|
||||||
if (!empty($obj->instagram)) {
|
if (!empty($obj->instagram)) {
|
||||||
$arraysocialnetworks['instagram'] = $obj->instagram;
|
$arraysocialnetworks['instagram'] = $obj->instagram;
|
||||||
}
|
}
|
||||||
if (!empty($obj->snapchat)) {
|
if (!empty($obj->snapchat)) {
|
||||||
$arraysocialnetworks['snapchat'] = $obj->snapchat;
|
$arraysocialnetworks['snapchat'] = $obj->snapchat;
|
||||||
}
|
}
|
||||||
if (!empty($obj->googleplus)) {
|
if (!empty($obj->googleplus)) {
|
||||||
$arraysocialnetworks['googleplus'] = $obj->googleplus;
|
$arraysocialnetworks['googleplus'] = $obj->googleplus;
|
||||||
}
|
}
|
||||||
if (!empty($obj->youtube)) {
|
if (!empty($obj->youtube)) {
|
||||||
$arraysocialnetworks['youtube'] = $obj->youtube;
|
$arraysocialnetworks['youtube'] = $obj->youtube;
|
||||||
}
|
}
|
||||||
if (!empty($obj->whatsapp)) {
|
if (!empty($obj->whatsapp)) {
|
||||||
$arraysocialnetworks['whatsapp'] = $obj->whatsapp;
|
$arraysocialnetworks['whatsapp'] = $obj->whatsapp;
|
||||||
}
|
}
|
||||||
if ($obj->socialnetworks=='' || is_null($obj->socialnetworks)) {
|
if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) {
|
||||||
$obj->socialnetworks = '[]';
|
$obj->socialnetworks = '[]';
|
||||||
}
|
}
|
||||||
$socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true));
|
$socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true));
|
||||||
$sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"';
|
$sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"';
|
||||||
$sqlupd.= ', skype=null';
|
$sqlupd.= ', skype=null';
|
||||||
$sqlupd.= ', twitter=null';
|
$sqlupd.= ', twitter=null';
|
||||||
$sqlupd.= ', facebook=null';
|
$sqlupd.= ', facebook=null';
|
||||||
$sqlupd.= ', linkedin=null';
|
$sqlupd.= ', linkedin=null';
|
||||||
$sqlupd.= ', instagram=null';
|
$sqlupd.= ', instagram=null';
|
||||||
$sqlupd.= ', snapchat=null';
|
$sqlupd.= ', snapchat=null';
|
||||||
$sqlupd.= ', googleplus=null';
|
$sqlupd.= ', googleplus=null';
|
||||||
$sqlupd.= ', youtube=null';
|
$sqlupd.= ', youtube=null';
|
||||||
$sqlupd.= ', whatsapp=null';
|
$sqlupd.= ', whatsapp=null';
|
||||||
$sqlupd.= ' WHERE rowid='.$obj->rowid;
|
$sqlupd.= ' WHERE rowid='.$obj->rowid;
|
||||||
//print $sqlupd."<br>";
|
//print $sqlupd."<br>";
|
||||||
$resqlupd = $db->query($sqlupd);
|
$resqlupd = $db->query($sqlupd);
|
||||||
if (! $resqlupd) {
|
if (! $resqlupd) {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} else {
|
} else {
|
||||||
@@ -5036,19 +5036,78 @@ function migrate_members_socialnetworks()
|
|||||||
global $db, $langs;
|
global $db, $langs;
|
||||||
|
|
||||||
print '<tr><td colspan="4">';
|
print '<tr><td colspan="4">';
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'adherent SET socialnetworks=JSON_OBJECT(';
|
$error = 0;
|
||||||
$sql.= '"skype", skype,';
|
$db->begin();
|
||||||
$sql.= '"twitter", twitter,';
|
print '<tr><td colspan="4">';
|
||||||
$sql.= '"facebook", facebook,';
|
$sql = 'SELECT rowid, socialnetworks';
|
||||||
$sql.= '"linkedin", linkedin,';
|
$sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'adherent WHERE ';
|
||||||
$sql.= '"instagram", instagram,';
|
$sql .= ' skype IS NOT NULL OR skype !=""';
|
||||||
$sql.= '"snapchat", snapchat,';
|
$sql .= ' OR twitter IS NOT NULL OR twitter !=""';
|
||||||
$sql.= '"googleplus", googleplus,';
|
$sql .= ' OR facebook IS NOT NULL OR facebook!=""';
|
||||||
$sql.= '"youtube", youtube,';
|
$sql .= ' OR linkedin IS NOT NULL OR linkedin!=""';
|
||||||
$sql.= '"whatsapp", whatsapp)';
|
$sql .= ' OR instagram IS NOT NULL OR instagram!=""';
|
||||||
|
$sql .= ' OR snapchat IS NOT NULL OR snapchat!=""';
|
||||||
|
$sql .= ' OR googleplus IS NOT NULL OR googleplus!=""';
|
||||||
|
$sql .= ' OR youtube IS NOT NULL OR youtube!=""';
|
||||||
|
$sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""';
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
while ($obj = $db->fetch_object($resql)) {
|
||||||
|
$arraysocialnetworks = array();
|
||||||
|
if (!empty($obj->skype)) {
|
||||||
|
$arraysocialnetworks['skype'] = $obj->skype;
|
||||||
|
}
|
||||||
|
if (!empty($obj->twitter)) {
|
||||||
|
$arraysocialnetworks['twitter'] = $obj->twitter;
|
||||||
|
}
|
||||||
|
if (!empty($obj->facebook)) {
|
||||||
|
$arraysocialnetworks['facebook'] = $obj->facebook;
|
||||||
|
}
|
||||||
|
if (!empty($obj->linkedin)) {
|
||||||
|
$arraysocialnetworks['linkedin'] = $obj->linkedin;
|
||||||
|
}
|
||||||
|
if (!empty($obj->instagram)) {
|
||||||
|
$arraysocialnetworks['instagram'] = $obj->instagram;
|
||||||
|
}
|
||||||
|
if (!empty($obj->snapchat)) {
|
||||||
|
$arraysocialnetworks['snapchat'] = $obj->snapchat;
|
||||||
|
}
|
||||||
|
if (!empty($obj->googleplus)) {
|
||||||
|
$arraysocialnetworks['googleplus'] = $obj->googleplus;
|
||||||
|
}
|
||||||
|
if (!empty($obj->youtube)) {
|
||||||
|
$arraysocialnetworks['youtube'] = $obj->youtube;
|
||||||
|
}
|
||||||
|
if (!empty($obj->whatsapp)) {
|
||||||
|
$arraysocialnetworks['whatsapp'] = $obj->whatsapp;
|
||||||
|
}
|
||||||
|
if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) {
|
||||||
|
$obj->socialnetworks = '[]';
|
||||||
|
}
|
||||||
|
$socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true));
|
||||||
|
$sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'adherent SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"';
|
||||||
|
$sqlupd.= ', skype=null';
|
||||||
|
$sqlupd.= ', twitter=null';
|
||||||
|
$sqlupd.= ', facebook=null';
|
||||||
|
$sqlupd.= ', linkedin=null';
|
||||||
|
$sqlupd.= ', instagram=null';
|
||||||
|
$sqlupd.= ', snapchat=null';
|
||||||
|
$sqlupd.= ', googleplus=null';
|
||||||
|
$sqlupd.= ', youtube=null';
|
||||||
|
$sqlupd.= ', whatsapp=null';
|
||||||
|
$sqlupd.= ' WHERE rowid='.$obj->rowid;
|
||||||
|
//print $sqlupd."<br>";
|
||||||
|
$resqlupd = $db->query($sqlupd);
|
||||||
|
if (! $resqlupd) {
|
||||||
|
dol_print_error($db);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (! $error) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
|
|||||||
Reference in New Issue
Block a user