From a7876a0e2b5390b1ea5ad4bde0751ab19865b00a Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 5 Jan 2011 16:53:59 +0000 Subject: [PATCH] --- .../Controlleur/class.extranet.core.php | 2 + .../class.ws.conversion.session.php | 2 - inc/ws/Controlleur/class.ws.flash.php | 46 ++++++++++++++++++- inc/ws/DAO/class.ws.dao.document.php | 5 +- .../Metier/class.ws.document.localinfos.php | 14 ++---- inc/ws/Metier/class.ws.document.php | 2 + 6 files changed, 58 insertions(+), 13 deletions(-) diff --git a/inc/extranet/Controlleur/class.extranet.core.php b/inc/extranet/Controlleur/class.extranet.core.php index ee835ed16..365ec2d0e 100644 --- a/inc/extranet/Controlleur/class.extranet.core.php +++ b/inc/extranet/Controlleur/class.extranet.core.php @@ -317,10 +317,12 @@ class extranetCore extends cubeCore { $db->documents->bookmarks('text', 0, false); $db->documents->numberSections('text', 0, false); $db->documents->links('text', 0, false); + $db->documents->localHash('varchar', 64, false); // Clés $db->documents->primary('pk_documents', 'document_id'); $db->documents->index('index_documents_file', 'BTREE', 'file'); $db->documents->index('index_documents_date', 'BTREE', 'date'); + $db->documents->index('index_documents_localHash', 'BTREE', 'localHash'); $db->documents->reference('fk_documents_proprietaire', 'proprietaire', 'utilisateurs', 'utilisateur_id'); // . // Table pages des documents diff --git a/inc/ws/Controlleur/class.ws.conversion.session.php b/inc/ws/Controlleur/class.ws.conversion.session.php index 6ceb8cd44..cace59595 100644 --- a/inc/ws/Controlleur/class.ws.conversion.session.php +++ b/inc/ws/Controlleur/class.ws.conversion.session.php @@ -105,10 +105,8 @@ class wsConversionSession { if ($pages == 'all') { $doc = $this->getDocumentById($id); $this->totalPages += $doc->generalInfos['pages']; - trigger_error('all : ' . $doc->generalInfos['pages']); } else { $this->totalPages += count($pages); - trigger_error($pages); } } $this->totalDoc = count($this->documents); diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 901b2ac19..e36cd5e80 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -61,6 +61,13 @@ class wsFlash extends cubeFlashGateway { } } + public function addDocument() + { + $_SESSION['conversionSession'] = array(); + $_SESSION['conversionSession'][$this->args['document_id']] = 'all'; + $_SESSION['conversionSessionReload'] = true; + } + public function reload() { global $core; @@ -134,11 +141,48 @@ class wsFlash extends cubeFlashGateway { public function testDocuments() { + global $core; + $toload = $this->xml->addChild('toLoad'); $alreadyLoaded = $this->xml->addChild('alreadyLoaded'); + $hash = array(); + foreach($this->args['fileName'] as $k => $name) { - $toload->addChild('file', $name); + $o = new wsDocumentLocalInfos(); + $o->fileName = $name; + $o->fileSize = intval($this->args['fileSize'][$k]); + $o->modificationDate = intval($this->args['modificationDate'][$k]); + $o->creationDate = intval($this->args['creationDate'][$k]); + + $hash[$k] = md5(serialize($o)); + } + + $in = array(); + foreach($hash as $h) { + $in[] = "'" . $h . "'"; + } + + $sql = 'SELECT document_id,localHash FROM documents WHERE localHash'; + if (count($in) == 1) { + $sql .= ' = ' . implode(',', $in); + } else { + $sql .= ' IN (' . implode(',', $in) . ')'; + } + + $al = array(); + $r = $core->con->select($sql); + while ($r->fetch()) { + $k = array_search($r->localHash, $hash); + $al[$k] = true; + $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]); + $f->addAttribute('document_id', $r->document_id); + } + + foreach($this->args['fileName'] as $k => $name) { + if (!isset($al[$k])) { + $toload->addChild('file', $name); + } } } diff --git a/inc/ws/DAO/class.ws.dao.document.php b/inc/ws/DAO/class.ws.dao.document.php index 70fef51f2..8e476223d 100644 --- a/inc/ws/DAO/class.ws.dao.document.php +++ b/inc/ws/DAO/class.ws.dao.document.php @@ -1,7 +1,7 @@ $k = serialize($data[$k]); } } + if (isset($data['localInfos'])) { + $c->localHash = md5($c->localInfos); + } if ($data['document_id'] == 'new') { $document_id = $c->document_id = $this->getNextId(); diff --git a/inc/ws/Metier/class.ws.document.localinfos.php b/inc/ws/Metier/class.ws.document.localinfos.php index dbf97a49d..2020fd960 100644 --- a/inc/ws/Metier/class.ws.document.localinfos.php +++ b/inc/ws/Metier/class.ws.document.localinfos.php @@ -1,13 +1,9 @@ fields['fileName'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Nom du fichier"), 'extra' => false, 'grade' => 0); - $this->fields['fileSize'] = array('type' => 'integer', 'default' => '', 'editable' => true, 'label' => __("Couleur des sous-menus"), 'extra' => false, 'grade' => 0); - $this->fields['modificationDate'] = array('type' => 'date', 'default' => TIME, 'editable' => true, 'label' => __("Date de dernière modification"), 'extra' => false, 'grade' => 0); - $this->fields['creationDate'] = array('type' => 'date', 'default' => TIME, 'editable' => true, 'label' => __("Date de dernière modification"), 'extra' => false, 'grade' => 0); - } +class wsDocumentLocalInfos { + public $fileName; + public $fileSize; + public $modificationDate; + public $creationDate; } ?> \ No newline at end of file diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 5d82480d5..48c60cc6a 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -21,6 +21,7 @@ class wsDocument extends cubeMetier { protected $bookmarks; protected $numberSections; protected $links; + protected $localHash; // Crop & cut protected $autocrop; protected $manualcrop; @@ -758,6 +759,7 @@ disablelinks Disable links. fwrite($pointer, $c); } + public function __destruct() { if (isset($this->common_log_pointer) && is_resource($this->common_log_pointer)) { -- 2.39.5