From: vincent@cubedesigners.com Date: Wed, 12 Jan 2011 09:25:03 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=43f5985fcb79e4e59e40e976486ec2e7e3514d90;p=cubeextranet.git --- diff --git a/importWs.php b/importWs.php index 58dc13a60..99ffd3d93 100644 --- a/importWs.php +++ b/importWs.php @@ -2,13 +2,13 @@ include('inc/prepend.php'); try { - cubePHP::neverStop(); + set_time_limit(0); $utilisateurs = true; $documents = false; $books = false; $themes = true; - $langues = false; + $langues = true; if ($utilisateurs) { $books = true; @@ -19,13 +19,13 @@ try { $grades = array(0 => 1, 0.4 => 1, '0.4' => 1, 0.5 => 1, '0.5' => 1, 1 => 1, 2 => 2, 3 => 3, 4 => 5); - $tables = array('books', 'book_pages', 'dashboard', 'devis', 'documents', 'entreprises', 'factures', 'icones', 'langues', 'projets', 'signatures', 'taches', 'themes', 'timereport', 'utilisateurs', 'themes_droits'); + $tables = array('books', 'book_pages', 'dashboard', 'devis', 'documents', 'entreprises', 'factures', 'icones', 'langues', 'projets', 'signatures', 'taches', 'themes', 'timereport', 'utilisateurs'/*, 'themes_droits'*/); foreach($tables as $t) { $core->con->execute('ALTER TABLE ' . $t . ' DISABLE KEYS'); } if ($themes) { - $core->con->execute('TRUNCATE TABLE themes_droits'); + // $core->con->execute('TRUNCATE TABLE themes_droits'); $core->con->execute('TRUNCATE TABLE themes'); $core->con->execute('TRUNCATE TABLE icones'); $core->con->execute('TRUNCATE TABLE signatures'); @@ -44,8 +44,9 @@ try { } if ($utilisateurs) { - $core->con->execute('DELETE FROM entreprises WHERE entreprise_id>242 AND entreprise_id<7'); $core->con->execute('DELETE FROM utilisateurs WHERE utilisateur_id>278'); + $core->con->execute('DELETE FROM entreprises WHERE entreprise_id>242'); + $core->con->execute('UPDATE entreprises SET ws_grade=0, ws_admin=1'); } if ($utilisateurs) { @@ -62,6 +63,10 @@ try { } $utilisateurs_entreprises = array(); + $r = $core->con->select('SELECT entreprise,utilisateur_id FROM utilisateurs'); + while ($r->fetch()) { + $utilisateurs_entreprises[$r->utilisateur_id] = $r->entreprise; + } $entreprise_id++; // Obtient les emails des utilisateurs @@ -74,38 +79,47 @@ try { } $utilisateur_id++; // Importe les entreprises et utilisateurs du WS dont les membres n'ont pas été reliés à l'extranet - $r = $core->con->select('SELECT * FROM ws.user WHERE extranet=0 AND (uid IN (SELECT uid FROM ws.book) OR grade>=3) ORDER BY date'); + $r = $core->con->select('SELECT * FROM ws.user WHERE extranet=0 AND (uid IN (SELECT uid FROM ws.book) OR grade>=3) ORDER BY rs'); $ws2ext = array(); while ($r->fetch()) { // On s'occupe de l'entreprise - if (trim($r->rs) == '') { - $r->rs = trim($r->prenom . ' ' . $r->nom); + $email = trim(mb_strtolower($r->email)); + + $rs = trim($r->rs); + if ($rs == '') { + $rs = trim($r->prenom . ' ' . $r->nom); } - $nom = mb_strtolower(trim($r->rs)); + $nom = mb_strtolower($rs); $nom = cubeText::str2URL($nom); - $email = trim(mb_strtolower($r->email)); - if (isset($entreprises[$nom])) { + + if (isset($utilisateurs[$email])) { + $newid = $utilisateurs[$email]; + $e = $utilisateurs_entreprises[$newid]; + $update = true; + } elseif (isset($entreprises[$nom])) { $e = $entreprises[$nom]; + $update = true; } else { $c = $core->con->openCursor('entreprises'); $c->entreprise_id = $entreprise_id; - $c->nom = $r->rs; + $c->nom = $rs; $c->adresse = $r->adresse; $c->code_postal = $r->code_postal; $c->ville = $r->ville; $c->pays = $r->pays; $c->date_creation = $r->date; $c->ws_grade = $grades[$r->grade]; - try { - $c->insert(); - } - catch(Exception $e) { - fb($entreprises); - } + $c->insert(); $e = $entreprises[$nom] = $entreprise_id; - $entreprise_id++; + $update = false; + } + + if ($update) { + $c = $core->con->openCursor('entreprises'); + $c->ws_grade = $grades[$r->grade]; + $c->update('WHERE entreprise_id=\'' . $e . '\''); } // Puis de l'utilisateur if (isset($utilisateurs[$email])) { @@ -127,8 +141,10 @@ try { $c->code_postal = $r->code_postal; $c->ville = $r->ville; $c->pays = $r->pays; + $c->lang = $r->lang; $c->telephone = $r->telephone; $c->date_creation = $r->date; + $c->notes = 'Inséré à la migration du Fluidbook Workshop'; $c->ws_password = $r->password; $c->ws_id = $r->uid; $c->insert(); @@ -164,7 +180,7 @@ try { } if (!isset($ws2ext[$r->admin])) { - $ws2ext[$r->admin] = 5; + $ws2ext[$r->admin] = 1; } $c = $core->con->openCursor('entreprises'); $c->ws_admin = $ws2ext[$r->admin]; @@ -179,6 +195,8 @@ try { } } + exit; + if ($themes) { // Importe les signatures $r = $core->con->select('SELECT * FROM ws.signature'); @@ -207,7 +225,6 @@ try { while ($r->fetch()) { $c = $core->con->openCursor('themes'); $c->theme_id = $r->tid; - $c->proprietaire = getWsUser($r->proprietaire); $c->date = $r->date; $c->nom = $r->titre; @@ -234,6 +251,7 @@ try { } if ($langues) { // Importe les langues + $allTrads = array(); $trad = array(); $r = $core->con->select('SELECT * FROM ws.lang_trad,ws.lang_ord WHERE lang_trad.idlt=lang_ord.idlt'); while ($r->fetch()) { @@ -246,12 +264,21 @@ try { $r = $core->con->select('SELECT * FROM ws.lang'); while ($r->fetch()) { + $idl = getLangCode($r->idl); ksort($trad[$idl]); - $textes = new wsLangueTextes(); - $textes->textes = $trad[$idl]; + + $traductions = wsLang::getTraductionWithId($trad[$idl]); + $allTrads[$idl] = $traductions; + + if (strlen($idl) > 2) { + continue; + } + $c = $core->con->openCursor('langues'); - $c->lang_id = $r->idl; - $c->traductions = json_encode(getLangCode($r->idl)); + $c->lang_id = $idl; + $c->charset = 'Latin1'; + $c->font = 'Fluidbook.otf'; + $c->traductions = json_encode($traductions); $c->insert(); } } @@ -269,8 +296,8 @@ try { $c->date = $r->date; $c->insert(); // TODO Copie des fichiers - /*$docs[$r->did] = true; - if (!file_exists(dirname(__FILE__) . '/docs/' . $r->did)) { + $docs[$r->did] = true; + /*if (!file_exists(dirname(__FILE__) . '/docs/' . $r->did)) { mkdir(dirname(__FILE__) . '/docs/' . $r->did, 0777, true); }*/ } @@ -294,17 +321,22 @@ try { $c = $core->con->openCursor('books'); $c->book_id = $r->bid; $c->nom = $r->titre; - $c->lang = $r->lang; + $c->lang = substr(getLangCode($r->lang), 0, 2); $c->theme = $r->tid; + if (strlen($r->lang) > 2) { + $c->traductions = json_encode($allTrads[$r->lang]); + } else { + $c->traductions = ''; + } $books_proprietaires[$r->bid] = $c->proprietaire = getWsUser($r->uid); $c->status = $r->status; $c->date_status = $r->date_status; $c->hash = $r->code; $c->compteur_visites = 20; $c->date = $r->date; - $parametres = new wsBookParametres(); + $parametres = new wsBookParametres(new stdClass()); + $r->signature = $signatures[$r->tid]; $parametres->fromRecord($r); - $parametres->signature = $signatures[$r->tid]; $parametres->fromXML(simplexml_load_string('' . $r->extras . '')); $c->parametres = serialize($parametres); $c->insert(); @@ -334,6 +366,7 @@ try { } } catch(Exception $e) { + print_r($e); fb($e); } diff --git a/inc/extranet/Controlleur/class.extranet.core.php b/inc/extranet/Controlleur/class.extranet.core.php index 19c8052f7..7eb31a979 100644 --- a/inc/extranet/Controlleur/class.extranet.core.php +++ b/inc/extranet/Controlleur/class.extranet.core.php @@ -302,7 +302,7 @@ class extranetCore extends cubeCore { // Table des langues $db->langues->lang_id('varchar', 20, false); $db->langues->font('varchar', 64, false); - $db->langues->charset('text', 0, false); + $db->langues->charset('varchar', 64, false); $db->langues->traductions('text', 0, false); // Clés $db->langues->primary('pk_langues', 'lang_id'); diff --git a/inc/extranet/Controlleur/class.extranet.url.php b/inc/extranet/Controlleur/class.extranet.url.php index 4f26dc9fa..53cbf6a5c 100644 --- a/inc/extranet/Controlleur/class.extranet.url.php +++ b/inc/extranet/Controlleur/class.extranet.url.php @@ -302,7 +302,7 @@ class extranetUrl { if ($entreprise_id == 'new' || !$client->ws_admin) { $class = 'empty-field'; $default_id = ''; - $default = __('Entrez le nom du projet ou du client'); + $default = __('Entrez le nom du revendeur ou de l\'administrateur'); } else { $class = ''; $default_id = $client->ws_admin; diff --git a/inc/extranet/DAO/class.extranet.dao.utilisateur.php b/inc/extranet/DAO/class.extranet.dao.utilisateur.php index 131aee84f..0b6322c21 100644 --- a/inc/extranet/DAO/class.extranet.dao.utilisateur.php +++ b/inc/extranet/DAO/class.extranet.dao.utilisateur.php @@ -156,6 +156,8 @@ class extranetDAOUtilisateur extends extranetDAO { { $where = 'nom LIKE \'' . $this->con->escape($q) . '%\' OR '; $where .= 'prenom LIKE \'' . $this->con->escape($q) . '%\' OR '; + $where .= 'CONCAT(prenom,\' \',nom) LIKE \'' . $this->con->escape($q) . '%\' OR '; + $where .= 'CONCAT(nom,\' \',prenom) LIKE \'' . $this->con->escape($q) . '%\' OR '; if ($search_entreprise) { $where .= 'entreprise IN(SELECT entreprise_id FROM entreprises WHERE nom LIKE \'%' . $this->con->escape($q) . '%\') OR '; } diff --git a/inc/ws/Metier/class.ws.lang.php b/inc/ws/Metier/class.ws.lang.php index 6c97af661..efb8f7c34 100644 --- a/inc/ws/Metier/class.ws.lang.php +++ b/inc/ws/Metier/class.ws.lang.php @@ -82,7 +82,7 @@ class wsLang extends cubeMetier { public static function checkTranslations($traductions) { foreach($traductions as $k => $v) { - if (is_int($k)) { + if (is_int($k) || intval($k)>0) { $traductions = wsLang::getTraductionWithId($traductions); } break; diff --git a/inc/ws/Metier/class.ws.parametres.php b/inc/ws/Metier/class.ws.parametres.php index 1267868da..8073e2eac 100644 --- a/inc/ws/Metier/class.ws.parametres.php +++ b/inc/ws/Metier/class.ws.parametres.php @@ -132,7 +132,6 @@ class wsParametres extends cubeMetier implements Iterator { $value = (string)$value; break; } // switch - fb($value,$varname); $this->datas[$varname] = $value; } diff --git a/typo/extranet/desc.xml b/typo/extranet/desc.xml index ea114779e..5be148bdb 100644 --- a/typo/extranet/desc.xml +++ b/typo/extranet/desc.xml @@ -23,6 +23,7 @@ 8 auto 0 + 1 $texte @@ -34,6 +35,7 @@ 41 auto 0 + 1 $texte