$db->book_collection_compile->compile_date('integer', 0, false);\r
$db->book_collection_compile->online('integer', 0, false);\r
$db->book_collection_compile->primary('book_collection_compile', 'collection_id', 'compile_date');\r
+\r
+ // Table des notification push\r
+ $db->book_collection_push->collection_id('integer', 0, false);\r
+ $db->book_collection_push->platform('varchar', 16, false);\r
+ $db->book_collection_push->token('varchar', 128, false);\r
+ $db->book_collection_push->locale('varchar', 8, false);\r
+ $db->book_collection_push->env('varchar', 32, false);\r
+ $db->book_collection_push->datas('text', 0, false);\r
+ $db->book_collection_push->last_visit('integer', 0, false);\r
+ $db->book_collection_push->primary('pk_book_collection_push', 'collection_id', 'token');\r
+ $db->book_collection_push->index('idx_book_collection_push_platform', 'BTREE', 'platform');\r
+ $db->book_collection_push->index('idx_book_collection_push_token', 'BTREE', 'token');\r
+\r
// Table des droits\r
$db->ws_users_tree->utilisateur_id('integer', 0, false);\r
$db->ws_users_tree->entreprise_id('integer', 0, false);\r
$e = explode('.', $_FILES['cert']['name']);
array_pop($e);
- $base = implode('.', $e);
+ $base = CubeIT_Text::str2URL(implode('.', $e));
$pem = $tmp . '/' . $base . '.pem';
$p12 = $tmp . '/' . $base . '.p12';
$openssl->setPath(CONVERTER_PATH);
$openssl->setEnv('RANDFILE', $tmp . '/.rnd');
$openssl->setArg(null, 'pkcs12');
- $openssl->setArg('-password', 'pass:');
+ $openssl->setArg('-password', 'pass:' . $_POST['password']);
$openssl->setArg('-in', $p12);
$openssl->setArg('-out', $pem);
$openssl->setArg('-nodes');
$openssl->setArg(null, '2048');
$openssl->execute();
-
// Generate csr
// openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest -subj "/emailAddress=yourAddress@example.com, CN=John Doe, C=US"
-
$openssl = new cubeCommandLine('openssl');
$openssl->setPath(CONVERTER_PATH);
$openssl->setArg(null, 'req');
$save = $_POST;\r
\r
$datas = array();\r
+\r
+ $dir = WS_COLLECTIONS . '/apns/' . $_POST['collection_id'];\r
+ if (!file_exists($dir)) {\r
+ mkdir($dir, 0777, true);\r
+ }\r
+ if (isset($_FILES['apns_dev'])) {\r
+ move_uploaded_file($_FILES['apns_dev']['tmp_name'], $dir . '/apns_dev.pem');\r
+ }\r
+ if (isset($_FILES['apns_prod'])) {\r
+ move_uploaded_file($_FILES['apns_prod']['tmp_name'], $dir . '/apns_prod.pem');\r
+ }\r
+\r
foreach ($_POST['group'] as $gid => $group) {\r
if ($gid && $gid == 'new_') {\r
continue;\r
$exporter->exportCollection($id, $os);\r
}\r
\r
+ public static function publishCollection($args, &$x) {\r
+ global $core;\r
+ $collection = $args[1];\r
+\r
+ $env = Zend_Mobile_Push_Apns::SERVER_SANDBOX_URI;\r
+\r
+ // Notifications\r
+\r
+ $apns = new Zend_Mobile_Push_Apns();\r
+ if ($env == Zend_Mobile_Push_Apns::SERVER_SANDBOX_URI) {\r
+ $c = 'dev';\r
+ } else {\r
+ $c = 'prod';\r
+ }\r
+ $apns->setCertificate(WS_COLLECTIONS . '/apns/' . $args[1] . '/apns_' . $c . '.pem');\r
+ $apns->setCertificatePassphrase('apns');\r
+ $apns->connect($env);\r
+\r
+ $r = $core->con->select('SELECT token FROM book_collection_push WHERE platform=\'ios\' AND collection_id = \'' . $core->con->escape($collection) . '\'');\r
+ while ($r->fetch()) {\r
+ $m = new Zend_Mobile_Push_Message_Apns();\r
+ $m->setBadge(5);\r
+ $m->setToken($r->token);\r
+ $m->setSound('none');\r
+ $m->setId(microtime(true) * 1000);\r
+ $apns->send($m);\r
+ }\r
+ $apns->close();\r
+ }\r
+\r
}\r
\r
?>
\ No newline at end of file
exit;\r
}\r
\r
+ public function collectionPushRegister() {\r
+ global $core;\r
+\r
+ $c = $core->con->openCursor('book_collection_push');\r
+ $c->collection_id = $_POST['id'];\r
+ $c->token = $_POST['token'];\r
+ $c->datas = $_POST['datas'];\r
+ $c->platform = $_POST['platform'];\r
+ $c->locale = $_POST['locale'];\r
+ $c->last_visit = TIME;\r
+ try {\r
+ $c->insert();\r
+ } catch (Exception $e) {\r
+ $c->update('WHERE collection_id=\'' . $core->con->escape($_POST['id']) . '\' AND token=\'' . $core->con->escape($_POST['token']) . '\'');\r
+ }\r
+ }\r
+\r
}\r
\r
?>
\ No newline at end of file
global $core;\r
\r
$res = '<h1>Gestion de la collection « ' . $collection->nom . ' » <em># ' . $collection->collection_id . '</em></h1>';\r
- $res.='<form method="post" action="saveCollectionComposition">';\r
+ $res.='<form method="post" action="saveCollectionComposition" enctype="multipart/form-data>';\r
$res.='<table class="max">';\r
$res.='<tr><td class="min nowrap">#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';\r
$res.='<tr><td class="min nowrap">' . __('Nom de la collection') . '</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';\r
$res.='<table class="max">';\r
$res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]', 'phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';\r
$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>';\r
+ $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Dev (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_dev" /></td></tr>';\r
+ $res.='<tr><td class="min nowrap">' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')</td><td><input type="file" name="apns_prod" /></td></tr>';\r
$res.='</table>';\r
\r
\r
$res.='<p class="clear"></p>';\r
$res.='<h3>' . __('Versions') . '</h3>';\r
\r
+ $res.='<a href="#" class="right ajax" rel="publishCollection/' . $collection->collection_id . '">' . $core->typo->Ajouter(__('Publier et notifier les utilisateurs')) . '</a>';\r
\r
$res.='<h3>' . __('Export') . '</h3>';\r
$res.='<a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/android">' . $core->typo->Ajouter(__('Exporter pour Android')) . '</a> <a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/ios">' . $core->typo->Ajouter(__('Exporter pour iOS')) . '</a>';\r
protected function _createProject($os, $name, $ns) {
if ($os == 'ios') {
- $dir = '/Phonegap/Projects/' . str_replace('.', '/', $ns);
+ $dir = $this->_iosProjectDir($ns);
$sdir = '/mnt/macbox' . $dir;
- if (file_exists($sdir)) {
- return;
+ if (!file_exists($sdir)) {
+ `sudo /usr/local/bin/remountmac`;
+ mkdir($sdir, 0777, true);
+ $cl = new CubeIT_CommandLine('/Phonegap/Cordova/bin/create');
+ $cl->setArg(null, $dir);
+ $cl->setArg(null, $ns);
+ $cl->setArg(null, CubeIT_Text::str2URL($name));
+ $cl->setSSH('paris.cubedesigners.com', 'vincent', '', 22022);
+ $cl->execute();
+ // Install plugins
+ $this->_iosPlugin($dir, 'PushPlugin');
+ $this->_iosPlugin($dir, 'ExternalFileUtil');
}
- `sudo /usr/local/bin/remountmac`;
- mkdir($sdir, 0777, true);
- $cl = new CubeIT_CommandLine('/Phonegap/Cordova/bin/create');
- $cl->setArg('shared');
- $cl->setArg(null, $dir);
- $cl->setArg(null, $ns);
- $cl->setArg(null, CubeIT_Text::str2URL($name));
- $cl->setSSH('paris.cubedesigners.com', 'vincent', '', 22022);
- $cl->execute();
} elseif ($os == 'android') {
}
}
+ protected function _iosProjectDir($ns) {
+ return '/Phonegap/Projects/' . str_replace('.', '/', $ns);
+ }
+
+ protected function _iosPlugin($dir, $plugin) {
+ // git@github.com:phonegap-build/PushPlugin.git
+ $cl = new CubeIT_CommandLine('/usr/local/bin/plugman');
+ $cl->setManualArg('--platform ios');
+ $cl->setManualArg('--project ' . $dir);
+ $cl->setManualArg('--plugin /Phonegap/Plugins/' . $plugin);
+ $cl->setSSH('paris.cubedesigners.com', 'vincent', '', 22022);
+ $cl->execute();
+ }
+
public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null) {
global $core;
$root = 'fluidbook@fluidbook.com:/home/fluidbook/www/references/';
$rootURL = 'http://www.fluidbook.com/references/';
} else if ($this->action == 'hosting') {
- $root = '/home/fluidbook/hosting/';
+ $root = 'fluidbook@hosting.fluidbook.com:/home/fluidbook/hosting/';
$rootURL = 'http://hosting.fluidbook.com/';
} else if ($this->action == 'ftp') {
$root = 'ftp://';