From 1d82dd15191f927305eecca2d370a3a53ca11160 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 16 Mar 2011 15:09:28 +0000 Subject: [PATCH] --- inc/commons/class.common.core.php | 1 + inc/ws/Controlleur/class.ws.maintenance.php | 69 ++++++++++++++++----- inc/ws/DAO/class.ws.dao.book.php | 10 +++ inc/ws/Metier/class.ws.book.php | 1 + 4 files changed, 67 insertions(+), 14 deletions(-) diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 446c7008f..34fb157c7 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -350,6 +350,7 @@ class commonCore extends cubeCore { $db->books->numerotation('text', 0, false); $db->books->changedate('integer', 0, false); $db->books->compiledate('integer', 0, false); + $db->books->syncv1('integer',0,false,0); // Clés $db->books->primary('pk_books', 'book_id'); $db->books->index('index_books_nom', 'BTREE', 'nom'); diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index bede0daa5..7973878b7 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -14,14 +14,6 @@ class wsMaintenance { public static function importFromOldWS($args) { global $core; - // Supprime pour le test - $core->con->execute('DELETE FROM book_pages WHERE book_id>3940 AND book_id<10000'); - $core->con->execute('DELETE FROM books WHERE book_id>3940 AND book_id<10000'); - $core->con->execute('DELETE FROM themes WHERE theme_id>627 AND theme_id<1000'); - $core->con->execute('DELETE FROM documents WHERE document_id>12673 AND document_id<100000'); - $core->con->execute('DELETE FROM langues WHERE lang_id=\'te\''); - $core->con->execute('DELETE FROM utilisateurs WHERE utilisateur_id>699'); - $core->con->execute('DELETE FROM entreprises WHERE entreprise_id>561'); // Import des fluidbooks // Donc le dernier importé est le max dont le numéro est inférieur à 10000 $r = $core->con->select('SELECT MAX(book_id) AS book_id FROM books WHERE book_id<10000'); @@ -33,15 +25,12 @@ class wsMaintenance { $oldBooks[] = $r->bid; } - fb($oldBooks, 'Old books to import'); - if (count($oldBooks)) { self::importLangs($oldBooks); self::importThemes($oldBooks); self::importDocs($oldBooks); self::importBooks($oldBooks); } - $core->refreshWSUsersTree(); } @@ -165,8 +154,6 @@ class wsMaintenance { fb($e); } } - - fb($oldDocuments, 'Old documents imported'); } public static function importBooks($oldBooks) @@ -195,6 +182,7 @@ class wsMaintenance { $c->hash = $r->code; $c->compteur_visites = 20; $c->date = $r->date; + $c->syncv1 = 1; $parametres = new wsBookParametres(new stdClass()); $parametres->fromRecord($r); @@ -404,7 +392,60 @@ class wsMaintenance { public static function dumpDatabase() { - cubeDb::mysqlDump('localhost', DB_NAME , DB_USER , DB_PASSWORD , ROOT. '/backups/dump-'.date('Y-m-d-H-i-s').'.sql', true, 8); + cubeDb::mysqlDump('localhost', DB_NAME , DB_USER , DB_PASSWORD , ROOT . '/backups/dump-' . date('Y-m-d-H-i-s') . '.sql', true, 8); + } + + public static function cleanPackages() + { + $limit = TIME - (4 * 3600); // 4 heures avant maintenant* + + // Clean downloaded packages + $dir = WS_FILES . '/packager/download/'; + $dr = opendir($dir); + while ($file = readdir($dr)) { + if ($file == '.' || $file == '..') { + continue; + } + $f = $dir . $file; + if (filemtime($f) > $limit) { + continue; + } + unlink($f); + } + // Clean tempdir of packager + $dir = WS_FILES . '/packager/'; + $dr = opendir($dir); + while ($file = readdir($dr)) { + if ($file == 'download' || $file == '.' || $file == '..') { + continue; + } + $f = $dir . $file; + if (!is_dir($f)) { + continue; + } + if (filemtime($f) > $limit) { + continue; + } + `rm -rf $f`; + } + } + + public static function cleanConversionSessions() + { + $limit = TIME - (4 * 3600); // 4 heures avant maintenant* + + $dir = ROOT . '/cache/conversionSessions/'; + $dr = opendir($dir); + while ($file = readdir($dr)) { + if ($file == '.' || $file == '..') { + continue; + } + $f = $dir . $file; + if (filemtime($f) > $limit) { + continue; + } + unlink($f); + } } } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index a9d5dd12c..cc7d4e086 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -33,6 +33,7 @@ class wsDAOBook extends commonDAO { $book->facturable_id = $r->facturable_id; $book->tache = $r->tache; $book->projet = $r->projet; + $book->syncv1 = $r->syncv1; return $book; } @@ -55,6 +56,7 @@ class wsDAOBook extends commonDAO { $book->parametres = new wsBookParametres(); $book->tache = 0; $book->pages = array(); + $book->syncv1 = 0; return $book; } @@ -106,11 +108,13 @@ class wsDAOBook extends commonDAO { $c->compteur_visites = 20; $c->parametres = serialize(new wsParametres()); $c->changedate = TIME; + $c->syncv1 = 0; $book_id = $c->book_id = $this->getNextId(); $c->insert(); } else { $c->changedate = TIME; + $c->syncv1 = 0; $book_id = $data['book_id']; $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\''); } @@ -139,6 +143,7 @@ class wsDAOBook extends commonDAO { $c->theme = $r->theme; $c->changedate = TIME; $c->compiledate = 0; + $c->syncv1 = 0; $book_id = $c->book_id = $this->getNextId(); $c->insert(); @@ -338,6 +343,7 @@ class wsDAOBook extends commonDAO { $c = $this->con->openCursor('books'); $c->chapters = json_encode(json_decode($json, false)); $c->changedate = TIME; + $c->syncv1 = 0; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -346,6 +352,7 @@ class wsDAOBook extends commonDAO { $c = $this->con->openCursor('books'); $c->theme = $theme; $c->changedate = TIME; + $c->syncv1 = 0; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -410,6 +417,7 @@ class wsDAOBook extends commonDAO { $c->lang = $base; $c->traductions = $t; $c->changedate = TIME; + $c->syncv1 = 0; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -428,6 +436,7 @@ class wsDAOBook extends commonDAO { $c->nom = $parametres->title; $c->parametres = serialize($parametres); $c->changedate = TIME; + $c->syncv1 = 0; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -483,6 +492,7 @@ class wsDAOBook extends commonDAO { $c->parametres = serialize($parametres); $c->numerotation = implode(',', $numerotation); $c->changedate = TIME; + $c->syncv1 = 0; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); $this->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\''); diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index b7e0ccaf8..53427eca5 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -35,6 +35,7 @@ class wsBook extends cubeMetier { protected $changedate; protected $compiledate; + protected $syncv1; public function __get($varname) { -- 2.39.5