]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 20 Jun 2013 12:58:26 +0000 (12:58 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 20 Jun 2013 12:58:26 +0000 (12:58 +0000)
inc/commons/class.common.core.php
inc/commons/class.common.tools.php
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/class.ws.exporter.php

index b57e596ceef2248599df8fae871e1a22ceeabc2e..61489320ffa9daffb0d2a5042f68948de59dc4b1 100644 (file)
@@ -436,6 +436,19 @@ class commonCore extends cubeCore {
                $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
index 9660bd8a5375ee198bf2baa941da0aefa0a0e307..9eb896a16fff6e3c6a7a823c5bcb5bdea7193e33 100644 (file)
@@ -678,7 +678,7 @@ class commonTools {
 
                $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';
@@ -710,7 +710,7 @@ class commonTools {
                $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');
@@ -752,10 +752,8 @@ class commonTools {
                $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');
index 2272fec07735d1f41ab1230eddcec2c759f7318f..b3108e808bba9c2a0a724ebc19f8af89947bb92e 100644 (file)
@@ -209,6 +209,18 @@ class wsAjax extends cubeAjax {
                $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
@@ -1141,6 +1153,36 @@ class wsAjax extends cubeAjax {
                $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
index 7176a85215f177d57e96a271d23fe3501710fa42..a4b65a2997d0a8b2bb5154a5ecfe2f525dbde57d 100644 (file)
@@ -558,6 +558,23 @@ class wsServices extends cubeFlashGateway {
                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
index 5a05a146833331e13ed2dea2c425c1ba32e6c7fa..4e570de2eacd6481f115194bfab36608bab78ef4 100644 (file)
@@ -231,7 +231,7 @@ class wsUrl {
                global $core;\r
 \r
                $res = '<h1>Gestion de la collection &laquo; ' . $collection->nom . ' &raquo; <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
@@ -297,6 +297,8 @@ class wsUrl {
                $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
@@ -314,6 +316,7 @@ class wsUrl {
                $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
index dc5608b8bb2d2076b9fbcbd7abf63eae7a64a92c..cc332282449863ccbdbbd9bbc2bab014d2a44b84 100644 (file)
@@ -29,25 +29,40 @@ class wsExporter {
 
        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;
 
@@ -106,7 +121,7 @@ class wsExporter {
                        $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://';