\r
$shortcuts = array();\r
if (wsDroits::creation()) {\r
+ fb('creation');\r
$shortcuts[] = '<a href="#" class="popup" rel="newBookForm">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';\r
}\r
\r
$filtres = array();\r
- $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']);\r
+ if (wsDroits::revendeur(false)) {\r
+ $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']);\r
+ }\r
$filtres[] = new commonFiltre(__('Année'), 'annee_book', $settings['filtres']);\r
$res = commonPage::barre($filtres , 'filtreBooks', 'books', $shortcuts);\r
$res .= commonPage::tMain(null, true);\r
\r
public static function editor($args)\r
{\r
- wsDroits::creation(true);\r
+ commonDroits::min(1);\r
\r
global $core;\r
\r
$args = cubePage::getArgs($args);\r
$book_id = $args[0];\r
\r
+ self::checkDocumentVersionOfBook($book_id);\r
+\r
if ($book_id == 'new') {\r
$dao = new wsDAOBook($core->con);\r
$book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang);\r
echo $res;\r
}\r
\r
+ public static function editComposition($args)\r
+ {\r
+ $fv = array(session_name() => session_id(),\r
+ 'book_id' => $args[0]);\r
+ $res = cubeMedia::flash2(WEBROOT . '/swf/composer.swf?junk=' . TIME, '100%', '100%', $fv, 'composerSwf', 'swfPanel', 10, '#d2d3c7', '', 'false', 'noscale', 'normal', array(), false, true, true);\r
+ return $res;\r
+ }\r
+\r
public static function stats($args)\r
{\r
$bid = (isset($args[1]))?$args[1]:null;\r
\r
$dao = new wsDAOBook($core->con);\r
$book_id = $e[0];\r
+\r
+ self::checkDocumentVersionOfBook($book_id);\r
+\r
$book = $dao->selectById($book_id);\r
if ($book->hash != $e[1]) {\r
commonDroits::error();\r
wsStats::exportXLS($bid);\r
}\r
\r
- public static function editComposition($args)\r
- {\r
- wsDroits::creation(true);\r
- $fv = array(session_name() => session_id(),\r
- 'book_id' => $args[0]);\r
- $res = cubeMedia::flash2(WEBROOT . '/swf/composer.swf?junk=' . TIME, '100%', '100%', $fv, 'composerSwf', 'swfPanel', 10, '#d2d3c7', '', 'false', 'noscale', 'normal', array(), false, true, true);\r
- return $res;\r
- }\r
-\r
public static function chooseExistingBook()\r
{\r
wsDroits::creation(true);\r
if (!isset($args[1])) {\r
$args[1] = 2964;\r
}\r
+ self::checkDocumentVersionOfBook($args[1]);\r
// cubePHP::neverStop();\r
$dao = new wsDAOBook($core->con);\r
header('Content-type: text/plain');\r
exit;\r
}\r
\r
+ protected static function checkDocumentVersionOfBook($book_id)\r
+ {\r
+ global $core;\r
+ cubePHP::neverStop();\r
+ $dao = new wsDAOBook($core->con);\r
+ $pages = $dao->getPagesOfBook($book_id);\r
+ $toUpdate = array();\r
+ foreach($pages as $p => $infos) {\r
+ if ($infos['version'] < 2) {\r
+ $toUpdate[] = $infos['document_id'];\r
+ }\r
+ }\r
+\r
+ $toUpdate = array_unique($toUpdate);\r
+ foreach($toUpdate as $document_id) {\r
+ fb('updateDocument', $document_id);\r
+ self::updateDocument($document_id);\r
+ }\r
+ }\r
+\r
+ protected static function updateDocument($document_id)\r
+ {\r
+ global $core;\r
+\r
+ $dao = new wsDAODocument($core->con);\r
+ $doc = $dao->selectById($document_id);\r
+\r
+ $doc->copyOriginalFromOlderVersion();\r
+ $doc->globalOperations();\r
+\r
+ for($i = 1;$i <= $doc->generalInfos['pages'];$i++) {\r
+ $doc->processOnePage($i);\r
+ }\r
+\r
+ $doc->version = 2;\r
+ $dao->updateFromObject($doc);\r
+ }\r
+\r
public static function getParamsHelp()\r
{\r
commonDroits::min(5);\r
public function getPagesOfBook($book_id)\r
{\r
$pages = array();\r
- $r = $this->con->select('SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages FROM book_pages b LEFT JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page');\r
+ $r = $this->con->select('SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b LEFT JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page');\r
while ($r->fetch()) {\r
$n = explode(',', $r->num);\r
if ($r->conversion != '') {\r
}\r
$pages[$r->book_page] = array('document_id' => $r->document_id,\r
'document_page' => $r->document_page,\r
+ 'version' => $r->version,\r
'defaultNum' => $num,\r
- 'nb_pages' => $r->doc_pages,\r
- 'resolution' => $c->resolution,\r
- 'quality' => $c->quality,\r
- 'method' => $c->method,\r
- 'objects' => $c->objects);\r
+ 'nb_pages' => $r->doc_pages\r
+ );\r
+\r
+ $qp = array('resolution', 'method', 'quality', 'objects');\r
+ foreach($qp as $p) {\r
+ if (isset($c) && isset($c->$p)) {\r
+ $pages[$r->book_page][$p] = $c->$p;\r
+ }\r
+ }\r
}\r
return $pages;\r
}\r
protected $bookmarks;\r
protected $numberSections;\r
protected $localHash;\r
+ protected $version;\r
// Crop & cut\r
protected $autocrop;\r
protected $manualcrop;\r
$this->uncropped = $this->out . 'uncrop.pdf';\r
$this->common_log_pointer = fopen($this->log . '/commons.log', 'a');\r
$this->pages_log_pointers = array();\r
+\r
+ if(is_null($this->conversionInfos)){\r
+ $this->conversionInfos=new wsDocumentConversionInfos();\r
+ }\r
}\r
\r
- public function copyOriginal($tmp_file)\r
+ public function copyOriginalFromUpload($tmp_file)\r
{\r
move_uploaded_file($tmp_file, $this->in);\r
$this->uncropDocument();\r
}\r
\r
+ public function copyOriginalFromOlderVersion()\r
+ {\r
+ if (!file_exists($this->in)) {\r
+ copy('http://ws.fluidbook.com/docs/' . $this->document_id . '/original.pdf', $this->in);\r
+ }\r
+ $this->uncropDocument();\r
+ }\r
+\r
public function getInfos($in = null, $force = false)\r
{\r
if (is_null($in)) {\r