try {\r
$this->authentifie();\r
} catch (Exception $e) {\r
- \r
+\r
}\r
\r
if ($this->user) {\r
// Table des compilations de collection\r
$db->book_collection_compile->collection_id('integer', 0, false);\r
$db->book_collection_compile->compile_date('integer', 0, false);\r
- $db->book_collection_compile->online_ios('integer', 0, false);\r
- $db->book_collection_compile->online_android('integer', 0, false);\r
+ $db->book_collection_compile->online_ios('varchar', 10, false);\r
+ $db->book_collection_compile->online_android('varchar', 10, false);\r
$db->book_collection_compile->primary('book_collection_compile', 'collection_id', 'compile_date');\r
\r
// Table des notification push\r
$db->ws_users_tree->facturable_id('integer', 0, false);\r
$db->ws_users_tree->facturable_entreprise_id('integer', 0, false);\r
$db->ws_users_tree->administrateur_id('integer', 0, false);\r
- // Clé \r
+ // Clé\r
$db->ws_users_tree->primary('pk_utilisateur_id', 'utilisateur_id');\r
// Table des entreprises\r
$db->ws_entreprises_tree->entreprise_id('integer', 0, false);\r
$c = $core->con->openCursor('book_collection_compile');\r
$c->collection_id = $id;\r
$c->compile_date = $time;\r
- $c->online_ios = 0;\r
- $c->online_android = 0;\r
+ $c->online_ios = '';\r
+ $c->online_android = '';\r
$c->insert();\r
\r
- if ($_GET['ctrl']) {\r
- self::collectionVersionPublish(array('', $id, $time, 'ios'), $x);\r
- }\r
-\r
$x->addReload();\r
}\r
\r
global $core;\r
\r
$id = $args[1];\r
- $date = $args[2];\r
- $os = $args[3];\r
-\r
- $online = 'online_' . $os;\r
-\r
- $c = $core->con->openCursor('book_collection_compile');\r
- $c->$online = 0;\r
- $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND ' . $online . '=1');\r
\r
- $c = $core->con->openCursor('book_collection_compile');\r
- $c->$online = 1;\r
- $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($date) . '\'');\r
+ foreach ($_POST['version'] as $version => $oss) {\r
+ $c = $core->con->openCursor('book_collection_compile');\r
+ foreach ($oss as $os => $appver) {\r
+ $c->{'online_' . $os} = $appver;\r
+ }\r
+ $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($version) . '\'');\r
+ }\r
\r
self::cleanCachesCollection($id, $os);\r
\r
}\r
\r
protected static function cleanCachesCollection($id, $os) {\r
- $files = array('json', 'update');\r
- $resolutions = array(150, 300);\r
-\r
- foreach ($files as $f) {\r
- foreach ($resolutions as $r) {\r
- $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $r . '.' . $f;\r
- if (file_exists($ff)) {\r
- unlink($ff);\r
- }\r
- }\r
- }\r
+ $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.*';\r
+ `rm $ff`;\r
}\r
\r
public static function collectionVersionDelete($args, &$x) {\r
$id = $this->callArgs[0];
$os = $this->callArgs[1];
$resolution = $this->callArgs[2];
- $local = (isset($this->callArgs[3])) ? $this->callArgs[3] : null;
+ $local = (isset($this->callArgs[3]) && $this->callArgs[3] != '0') ? $this->callArgs[3] : null;
+ $appver = (isset($this->callArgs[4]) && $this->callArgs[4]) ? $this->callArgs[4] : '1.0';
if (is_null($resolution)) {
$resolution = 150;
$this->outputXML = false;
header('Content-type: application/json');
- $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.json';
- $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.update';
+ $appverf = str_replace('.', '_', $appver);
+
+ $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.' . $appverf . '.json';
+ $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.' . $appverf . '.update';
if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) {
unlink($update);
$limit = TIME - 72000;
if (!file_exists($cache) || !file_exists($update) || filemtime($cache) < $limit) {
- $r = $core->con->select('SELECT * FROM book_collection_compile WHERE online_' . $os . '=1 AND collection_id=\'' . $core->con->escape($id) . '\'');
- $r->fetch();
- $version = $r->compile_date;
+ $r = $core->con->select('SELECT *,online_' . $os . ' AS v FROM book_collection_compile WHERE online_' . $os . '!=\'\' AND collection_id=\'' . $core->con->escape($id) . '\' ORDER BY compile_date DESC');
+ while ($r->fetch()) {
+ if (version_compare($r->v, $appver, '>')) {
+ continue;
+ }
- $daoCollection = new wsDAOCollection($core->con);
- $collection = $daoCollection->selectById($id);
+ $version = $r->compile_date;
- $ns = $collection->settings['namespace'];
+ $daoCollection = new wsDAOCollection($core->con);
+ $collection = $daoCollection->selectById($id);
+ $ns = $collection->settings['namespace'];
- $vcompo = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json';
- $composition = json_decode(file_get_contents($vcompo));
+ $vcompo = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json';
+ $composition = json_decode(file_get_contents($vcompo));
- $couvertures = array();
- $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';
+ $couvertures = array();
+ $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';
- $publications = array();
- $langs = array();
+ $publications = array();
+ $langs = array();
- foreach ($composition as $k => $g) {
- foreach ($g->publications as $l => $p) {
- $publications[] = $p->id;
+ foreach ($composition as $k => $g) {
+ foreach ($g->publications as $l => $p) {
+ $publications[] = $p->id;
+ }
}
- }
- $daoBook = new wsDAOBook($core->con);
- $books = $daoBook->selectByIds($publications);
-
- $langsnames = array();
- foreach ($composition as $k => $g) {
- foreach ($g->publications as $l => $p) {
- $book = $books[$p->id];
- $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;
- $couv = $root . '/cover.jpg';
- $couvertures[$p->id] = base64_encode(file_get_contents($couv));
- $composition[$k]->publications[$l]->width = $book->parametres->width;
- $composition[$k]->publications[$l]->height = $book->parametres->height;
- $composition[$k]->publications[$l]->lang = $book->lang;
- $langs[] = $book->lang;
+ $daoBook = new wsDAOBook($core->con);
+ $books = $daoBook->selectByIds($publications);
+
+ $langsnames = array();
+ foreach ($composition as $k => $g) {
+ foreach ($g->publications as $l => $p) {
+ $book = $books[$p->id];
+ $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;
+ $couv = $root . '/cover.jpg';
+ $couvertures[$p->id] = base64_encode(file_get_contents($couv));
+ $composition[$k]->publications[$l]->width = $book->parametres->width;
+ $composition[$k]->publications[$l]->height = $book->parametres->height;
+ $composition[$k]->publications[$l]->lang = $book->lang;
+ $langs[] = $book->lang;
+ }
}
- }
- $langs = array_unique($langs);
+ $langs = array_unique($langs);
- $w2h = new wiki2xhtml();
- $w2h->setOpt('active_pre', 0);
+ $w2h = new wiki2xhtml();
+ $w2h->setOpt('active_pre', 0);
- $contents = $collection->contents;
- foreach ($langs as $lang) {
- $langsnames[$lang] = cubeLang::getNameByCode($lang);
- $contents[$lang]['apropos'] = $w2h->transform($contents[$lang]['apropos']);
- }
+ $contents = $collection->contents;
+ foreach ($langs as $lang) {
+ $langsnames[$lang] = cubeLang::getNameByCode($lang);
+ $contents[$lang]['apropos'] = $w2h->transform($contents[$lang]['apropos']);
+ }
- $traductions = array();
- $r = $core->con->select('SELECT traductions,lang_id FROM langues WHERE lang_id IN(\'' . implode('\',\'', $langs) . '\')');
- while ($r->fetch()) {
- $traductions[$r->lang_id] = json_decode($r->traductions);
- }
+ $traductions = array();
+ $r = $core->con->select('SELECT traductions,lang_id FROM langues WHERE lang_id IN(\'' . implode('\',\'', $langs) . '\')');
+ while ($r->fetch()) {
+ $traductions[$r->lang_id] = json_decode($r->traductions);
+ }
+
+ $d = array('id' => $id, 'res' => $resolution, 'ns' => $ns, 'langs' => $langs, 'langnames' => $langsnames, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures, 'traductions' => $traductions, 'contents' => $contents);
+ $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books, $resolution));
- $d = array('id' => $id, 'res' => $resolution, 'ns' => $ns, 'langs' => $langs, 'langnames' => $langsnames, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures, 'traductions' => $traductions, 'contents' => $contents);
- $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books, $resolution));
+ $dao = new wsDAOCollection($core->con);
+ $col = $dao->selectById($id);
- $dao = new wsDAOCollection($core->con);
- $col = $dao->selectById($id);
+ $json = json_encode($d);
+ file_put_contents($cache, $json);
+ file_put_contents($update, $version);
- $json = json_encode($d);
- file_put_contents($cache, $json);
- file_put_contents($update, $version);
+ break;
+ }
} else {
$d = json_decode(file_get_contents($cache), true);
}
}
}
+
$d['forceUpdate'] = $force;
echo json_encode($d);
exit;
$res.='<tr><td class="min nowrap">' . __('Identifiant de l\'application') . '</td><td>' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '</td></tr>';
$res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Dev (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_dev" /></td></tr>';
$res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_prod" /></td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Versions iOS') . '</td><td>' . form::field(array('settings[v_ios]', 'namespace'), 64, 64, $collection->settings['v_ios']) . '</td></tr>';
+ $res.='<tr><td class="min nowrap">' . __('Versions Android') . '</td><td>' . form::field(array('settings[v_android]', 'namespace'), 64, 64, $collection->settings['v_android']) . '</td></tr>';
$res.='</table>';
$res.='<h3>' . __('Applications offline') . '</h3>';
$res.='</form>';
$res.='<p class="clear"></p>';
$res.='<h3>' . __('Versions') . '</h3>';
+ $res.='<form action="collectionVersionPublish/' . $collection->collection_id . '" method="post">';
$res.='<a href="#" class="ajax" rel="collectionVersionCreate/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Créer une version')) . '</a><br /><br />';
$r = $core->con->select('SELECT * FROM book_collection_compile WHERE collection_id=\'' . $collection->collection_id . '\' ORDER BY compile_date DESC');
+
+ $v_ios = self::getSelectVersions($collection->settings['v_ios']);
+ $v_android = self::getSelectVersions($collection->settings['v_android']);
+
+
if (!$r->count()) {
$res.=__('Aucune version de la collection n\'a été crée');
} else {
$del = '<a class="ajax suppr btbook" rel="collectionVersionDelete/' . $r->collection_id . '/' . $r->compile_date . '" href="#" title="' . __('Êtes-vous certain de vouloir supprimer cette version ?') . '"><div></div><span>' . __('Effacer') . '</span></a>';
}
- if ($r->online_ios) {
- $pub_ios = __('Publiée');
- } else {
- $pub_ios = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/ios" href="#"><div></div><span>' . __('Publier') . '</span></a>';
- }
+ $pub_ios = form::combo('version[' . $r->compile_date . '][ios]', $v_ios, $r->online_ios);
+ $pub_android = form::combo('version[' . $r->compile_date . '][android]', $v_android, $r->online_android);
- if ($r->online_android) {
- $pub_android = __('Publiée');
- } else {
- $pub_android = '<a class="ajax download btbook" rel="collectionVersionPublish/' . $r->collection_id . '/' . $r->compile_date . '/android" href="#"><div></div><span>' . __('Publier') . '</span></a>';
- }
$res.='<tr><td>' . date('Y-m-d H:i:s', $r->compile_date) . '</td><td>' . $pub_ios . '</td><td>' . $pub_android . '</td><td class="min nowrap">' . $del . '</td></tr>';
}
$res.='</table>';
}
-
+ $res.='<a href="#" class="submit right">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>';
+ $res.='</form>';
+ $res.='<p class="clear"></p>';
$res.='<h3>' . __('Notifications') . '</h3>';
$res.='<p>' . __('Indiquez le texte de la notification à envoyer aux utilisateurs') . ' (' . __('Max 200 caractères') . ').<br />' . __('Laissez vide si vous souhaitez simplement afficher un badge') . '</p>';
$res.='<form method="post" action="publishCollection">';
return $res;
}
+ public static function getSelectVersions($versions) {
+ fb($versions);
+ $res = array('-----' => '');
+ $e = explode(',', $versions);
+
+ foreach ($e as $ee) {
+ $ee = trim($ee);
+ $res[$ee] = $ee;
+ }
+ return $res;
+ }
+
public static function listeCollections($dashboard = null, $settings = null) {
global $core;