From: vincent@cubedesigners.com Date: Tue, 25 Jan 2011 17:00:49 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3664e69cf0d1f92456a21091e7822b09ad26f7bd;p=cubeextranet.git --- diff --git a/importWs.php b/importWs.php index 67a30662f..7e850484d 100644 --- a/importWs.php +++ b/importWs.php @@ -2,11 +2,9 @@ include('inc/prepend.php'); try { - set_time_limit(0); - $utilisateurs = true; - $documents = false; - $books = false; + $documents = true; + $books = true; $themes = true; $langues = true; @@ -17,6 +15,17 @@ try { $documents = true; } + define('MYSQL_BIN', '/usr/local/mysql/bin/'); + fb(MYSQL_BIN); + // Copie de la base extranet vers extranet_dev + cubeDb::truncateDatabase('extranet_dev'); + cubeDb::mysqlDump(DB_HOST, 'extranet' , DB_USER , DB_PASSWORD , dirname(__FILE__) . '/dump.sql', false, 0); + cubeDb::mysqlRestore(DB_HOST, DB_NAME, DB_USER , DB_PASSWORD , dirname(__FILE__) . '/dump.sql', false); + unlink(dirname(__FILE__) . '/dump.sql'); + + touch(ROOT . '/cache/DB_TODO'); + $core->dbSync(); + $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'*/); @@ -24,30 +33,12 @@ try { $core->con->execute('ALTER TABLE ' . $t . ' DISABLE KEYS'); } - if ($themes) { - // $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'); - } - if ($langues) { - $core->con->execute('TRUNCATE TABLE langues'); - } + // Copie des dossiers - if ($books) { - $core->con->execute('TRUNCATE TABLE book_pages'); - $core->con->execute('TRUNCATE TABLE books'); - } + `/bin/cp /home/extranet/www/devis/* /home/extranet/dev/devis/`; + `/bin/cp /home/extranet/www/factures/* /home/extranet/dev/factures/`; - if ($documents) { - $core->con->execute('TRUNCATE TABLE documents'); - } - - if ($utilisateurs) { - $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'); - } + $core->con->execute('UPDATE entreprises SET ws_grade=0, ws_admin=1'); if ($utilisateurs) { // Importe les entreprises @@ -324,7 +315,7 @@ try { $c->pages = $r->pages; $c->trim = $r->trim; $c->date = $r->date; - $c->version=1; + $c->version = 1; $c->insert(); // TODO Copie des fichiers $docs[$r->did] = true; @@ -393,6 +384,8 @@ try { $core->con->execute('INSERT INTO book_pages (book_id,book_page,document_id,document_page) SELECT bid,bpid,did,dpid FROM ws.book_pages'); } + $core->refreshWSUsersTree(); + foreach($tables as $t) { $core->con->execute('ALTER TABLE ' . $t . ' ENABLE KEYS'); } diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 540350139..68255e353 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -11,7 +11,11 @@ class commonCore extends cubeCore { $this->dbSync(); cubeLang::set(); - $this->authentifie(); + try { + $this->authentifie(); + } + catch(Exception $e) { + } if ($this->user) { // Défini la langue de l'utilisateur en fonction du contenu de user @@ -117,11 +121,12 @@ class commonCore extends cubeCore { public function dbSync() { $cache = ROOT . '/cache/DB_SYNC'; + $todo = ROOT . '/cache/DB_TODO'; if (!file_exists($cache)) { touch($cache); $dosync = true; } else { - $dosync = filemtime(__FILE__) > filemtime($cache); + $dosync = filemtime(__FILE__) >= filemtime($cache) || (file_exists($todo) && filemtime($todo) >= filemtime($cache)); } if (!$dosync) { @@ -129,7 +134,6 @@ class commonCore extends cubeCore { } $this->views->dropAllViews(); - $db = new CubeDbStruct($this->con); // Table utilisateurs $db->utilisateurs->utilisateur_id('integer', 0, false); @@ -419,13 +423,13 @@ class commonCore extends cubeCore { $db->demandes->administrateur('integer', 0, false); // Clés $db->demandes->primary('pk_demandes', 'demande_id'); - try { $dbi = new CubeDbStruct($this->con); $dbi->synchronize($db); } catch(Exception $e) { fb($e); + return; } $this->views->createView('equipiers', 'SELECT * FROM utilisateurs WHERE grade>=1'); @@ -512,7 +516,6 @@ class commonCore extends cubeCore { . 'FROM themes t ' . 'LEFT JOIN books b ON t.theme_id=b.theme ' . 'GROUP BY t.theme_id'); - $this->views->createView('demandes_vue', 'SELECT d.*, CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS utilisateur_nom, CONCAT(r.rs,\' (\',r.prenom,\' \',r.nom,\')\') AS revendeur_nom, c.entreprise AS entreprise, a.prenom AS administrateur_nom ' . 'FROM demandes d ' . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id ' diff --git a/inc/config.inc.php b/inc/config.inc.php index 71053cc43..7c7bd456d 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -3,43 +3,32 @@ define('DB_DRIVER', 'mysql'); define('ROOT', dirname(__FILE__) . '/..'); -$local = stristr($_SERVER['HTTP_HOST'], 'dev.'); +$dev = stristr($_SERVER['HTTP_HOST'], 'dev.'); $extranet = stristr($_SERVER['HTTP_HOST'], 'extranet.cubedesigners.com'); $ws = stristr($_SERVER['HTTP_HOST'], 'ws.fluidbook.com'); -if ($local) { +define('WEBROOT', ''); +define('SITE_PATH', WEBROOT . '/'); +define('FONT_PATH', ROOT . '/fluidbook/fonts/'); +define('FTPROOT', '/home/extranet/ftp/'); +define('DEV', false); +define('WINDOWS', false); +define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin'); +define('MXMLC_PATH', '/usr/local/bin/mxmlc'); +define('AS3_SOURCES', '/home/ws/sources'); + +if ($dev) { // Définition de la configuration sur l'environnement de développement define('DB_HOST', 'localhost'); - define('DB_NAME', 'extranet'); - define('DB_USER', 'root'); - define('DB_PASSWORD', 'valparaiso'); - define('DEV', true); - define('WINDOWS', true); - define('FONT_PATH', ROOT . '/fluidbook/fonts/'); - define('AS3_SOURCES', 'C:\Users\Vincent\Documents\Works\as3;C:\Users\Vincent\Documents\Works\cubeExtranet\swf\_src;C:\Users\Vincent\Documents\Works\as3-10'); - - define('WEBROOT', ''); - define('SITE_PATH', WEBROOT . '/'); - - define('CONVERTER_PATH', ROOT . '/fluidbook/tools/'); - define('MXMLC_PATH', 'C:\Program Files\Adobe\Flex SDK\bin\mxmlc.exe'); - define('FTPROOT', 'C:/Users/Vincent/Documents/Works/cubeExtranet/_ftp/'); - define('FLUIDBOOK_SOURCES', 'C:\Users\Vincent\Documents\Works\fluidbook3d\_src'); + define('DB_NAME', 'extranet_dev'); + define('DB_USER', 'ws'); + define('DB_PASSWORD', '*arica*2'); } else { // Définition des variables dans l'environnement de production define('DB_HOST', 'localhost'); define('DB_NAME', 'extranet'); define('DB_USER', 'ws'); define('DB_PASSWORD', '*arica*2'); - define('WEBROOT', ''); - define('SITE_PATH', WEBROOT . '/'); - - define('FTPROOT', '/home/extranet/ftp/'); - define('DEV', false); - define('WINDOWS', false); - define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin'); - define('MXMLC_PATH', '/usr/local/bin/mxmlc'); - define('AS3_SOURCES', '/home/ws/sources'); } if ($ws) { @@ -48,13 +37,8 @@ if ($ws) { define('MODE', 'extranet'); } -define('FLASH_SOURCES', ROOT . '/swf/'); - -if (DEV) { - define('STATIC_SERVER', 'http://devstatic.ws.fluidbook.com' . WEBROOT); -} else { - define('STATIC_SERVER', 'http://static.ws.fluidbook.com' . WEBROOT); -} +define('FLASH_SOURCES', AS3_SOURCES); +define('STATIC_SERVER', 'http://static.' . $_SERVER['HTTP_HOST'] . WEBROOT); // Workshop define('THEMES', WEBROOT . '/fluidbook/themes/'); define('ICONS', WEBROOT . '/fluidbook/icones/');