]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 18 Feb 2013 11:00:07 +0000 (11:00 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 18 Feb 2013 11:00:07 +0000 (11:00 +0000)
inc/config.inc.php
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/DAO/class.ws.dao.collection.php
inc/ws/DAO/class.ws.dao.document.php
inc/ws/Metier/class.ws.book.parametres.php
js/extranet.js
js/ws.js
style/ws/style.css

index a7a9d78ac99a7b81adb857c8d5f3e772313c77f4..3bb5b0c152aa89f2453dc39ea73be7f6117ddfe6 100644 (file)
@@ -45,6 +45,7 @@ define('L10N', dirname(__FILE__) . '/../l10n');
 \r
 define('JS_PATH', WEBROOT . '/js');\r
 define('JS', JS_PATH);\r
+define('MINIMIZE_JS',false);\r
 \r
 define('JOURNEE', 8);\r
 define('TAUX_JOURNALIER', 500);\r
index 65798305ec9e3b3098670faa650e867d138dcb74..f99138abc34b2e2bb6791421ce99c674714a1211 100644 (file)
@@ -196,12 +196,50 @@ class wsAjax extends cubeAjax {
        public static function saveCollection($args, &$x) {\r
                global $core;\r
                $dao = new wsDAOCollection($core->con);\r
-               $dao->sauve($_POST);\r
+               $dao->sauve($_POST, $core->user->utilisateur_id);\r
 \r
                $x->addClosePopup();\r
                $x->addContent('listeCollections', wsUrl::listeCollections());\r
        }\r
 \r
+       public static function saveCollectionComposition($args, &$x) {\r
+               global $core;\r
+               $dao = new wsDAOCollection($core->con);\r
+\r
+               $save = array('nom' => $_POST['nom'],\r
+                       'collection_id' => $_POST['collection_id']);\r
+\r
+               $datas = array();\r
+               foreach ($_POST['group'] as $gid => $group) {\r
+                       if ($gid && $gid == '_new') {\r
+                               continue;\r
+                       }\r
+\r
+                       if (isset($group['publications'])) {\r
+                               $publications = array();\r
+                               foreach ($group['publications'] as $pid => $publication) {\r
+                                       $publication = array('id' => $publication['id'], 'label' => $publication['label'], 'online' => isset($publication['online']));\r
+                                       $publications[] = $publication;\r
+                               }\r
+                               $group['publications'] = $publications;\r
+                       } else {\r
+                               $group['publications'] = array($dao->_emptyPublication);\r
+                       }\r
+\r
+                       $datas[] = $group;\r
+               }\r
+               if (count($datas) == 0) {\r
+                       $datas = $dao->_emptyCollection();\r
+               }\r
+               \r
+               fb($datas);\r
+               \r
+               $save['datas'] = $datas;\r
+               $dao->sauve($save);\r
+\r
+               //$x->addReload();\r
+       }\r
+\r
        public static function changeBookProprietaire($args, &$x) {\r
                return self::_changeProprietaire('book', $args[1], $_POST['proprietaire'], $x);\r
        }\r
index bb7fd0c6fd00bebcfcf5df2dd21fb38b231b6622..231f6cc78219638f99b8302f63e8320a702adb9a 100644 (file)
@@ -207,6 +207,7 @@ class wsUrl {
                global $core;\r
                commonDroits::min(1);\r
                cubePage::ui('Sortable');\r
+               cubePage::autocomplete();\r
                //cubePage::checkbox();\r
 \r
                $dao = new wsDAOCollection($core->con);\r
@@ -229,8 +230,16 @@ class wsUrl {
        public static function collectionEdit($collection) {\r
                global $core;\r
 \r
-               $res = '<ul>';\r
-               $res.='<h1>Gestion de la collection &laquo; ' . $collection->nom . ' &raquo; <em># ' . $collection->collection_id . '</em></h1>';\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.='<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
+\r
+               $res.='</table>';\r
+               $res.='<h3>Composition</h3>';\r
+               $res .= '<ul>';\r
+\r
 \r
                $dao = new wsDAOCollection($core->con);\r
                $books = $dao->getPublications($collection->collection_id);\r
@@ -240,16 +249,18 @@ class wsUrl {
 \r
                foreach ($datas as $gid => $group) {\r
                        $class = 'group';\r
-                       if ($gid == 'new_') {\r
+                       if ($gid && $gid == 'new_') {\r
                                $class.=' empty';\r
                        }\r
-                       $res.='<li class="group">';\r
+                       $res.='<li class="' . $class . '">';\r
                        $res.='<div class="g">';\r
                        $res.='<a href="#" class="move"></a>';\r
                        $g = 'group[' . $gid . ']';\r
                        $res.=__('Nom du groupe') . ' ' . form::field(array($g . '[label]'), 20, 64, $group['label']);\r
+                       $res.='<a href="#" class="delete"></a>';\r
                        $res.='</div>';\r
                        $res.='<ul>';\r
+                       $res.='<li style="height:2px;"></li>';\r
                        foreach ($group['publications'] as $pid => $publication) {\r
                                $p = $g . '[publication][' . $pid . ']';\r
                                $res.='<li class="publication"><div>';\r
@@ -261,17 +272,20 @@ class wsUrl {
                                }\r
                                $res.='<a href="#" class="move"></a>';\r
                                $res.=mb_strtoupper($book->lang);\r
-                               $res.='<span class="id"># ' . form::field($p . '[id]', 20, 64, $publication['id']) . '</span>';\r
-                               $res.='<span class="label">' . __('Label') . ' ' . form::field($p . '[label]', 20, 64, $publication['label']) . '</span>';\r
+                               $res.='<span class="id"># ' . form::field(array($p . '[s]'), 64, 256, trim($publication['id'] . ' - ' . $book->nom, ' -'), 'publication_id') . form::hidden(array($p . '[id]'), $publication['id']) . '</span>';\r
+                               $res.='<span class="label">' . __('Label') . ' ' . form::field(array($p . '[label]'), 20, 64, $publication['label']) . '</span>';\r
                                $res.='<a href="#" class="delete"></a>';\r
                                $res.='<a href="#" class="add"></a>';\r
-                               $res.='<span class="online">' . form::checkbox($p . '[online]', '1', $publication['online']) . '</span>';\r
+                               $res.='<span class="online">' . form::checkbox(array($p . '[online]'), '1', $publication['online']) . '</span>';\r
                                $res.='</div></li>';\r
                        }\r
                        $res.='</ul>';\r
                        $res.='</li>';\r
                }\r
                $res.='</ul>';\r
+               $res.='<a href="#" class="submit right">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>';\r
+               $res.='</form>';\r
+               $res.='<p class="clear"></p>';\r
                return $res;\r
        }\r
 \r
@@ -279,7 +293,7 @@ class wsUrl {
                global $core;\r
 \r
                cubePage::truePopup();\r
-               cubePage::autocomplete();\r
+               \r
                $droits = wsDroits::getDroits();\r
 \r
                commonDroits::min(3);\r
index da4a168d92097e90f1dfca51f86c23d086c42ce4..f0fbdaaceee42ad0265b335174b1b3f5e8f47168 100644 (file)
@@ -612,6 +612,34 @@ class wsDAOBook extends commonDAO {
                        }\r
                        $parametres->$k = $v;\r
                }\r
+\r
+               $ip = array();\r
+               if (isset($parametres->stats_exclude_ip) && trim($parametres->stats_exclude_ip) != '') {\r
+                       $list = $parametres->stats_exclude_ip;\r
+                       $list = str_replace("\r", "\n", $list);\r
+                       $e = explode("\n", $list);\r
+                       foreach ($e as $i) {\r
+                               $i = trim($i);\r
+                               if ($i == '') {\r
+                                       continue;\r
+                               }\r
+                               $long = ip2long($i);\r
+                               if ($long !== false) {\r
+                                       $ip[] = $long;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               $file = '/home/stats/www/exclude/' . $book_id;\r
+               \r
+               if (count($ip)) {\r
+                       file_put_contents($file, implode(',', $ip));\r
+                       chmod($file, 0777);\r
+                       chown($file, 'stats');\r
+               } else if (file_exists($file)) {\r
+                       unlink($file);\r
+               }\r
+\r
                $c = $this->con->openCursor('books');\r
                $c->nom = $parametres->title;\r
                $c->parametres = serialize($parametres);\r
index d8080918e9ba9fec260a6d34da6d1b929889119e..8e7f98cff8ba873351df7c9240a143b331e77abc 100644 (file)
@@ -26,7 +26,7 @@ class wsDAOCollection extends commonDAO {
                return $collection;
        }
 
-       protected function _emptyCollection() {
+       public function _emptyCollection() {
                return array($this->_emptyGroup());
        }
 
@@ -34,7 +34,7 @@ class wsDAOCollection extends commonDAO {
                return array('label' => '', 'publications' => array($this->_emptyPublication()));
        }
 
-       protected function _emptyPublication() {
+       public function _emptyPublication() {
                return array('id' => '', 'label' => '', 'online' => false);
        }
 
index fc147da9bbc3f31a3250cb6fc02ed6028fc8daa3..55d98f1caec758aa29dffd2773188184e49bda25 100644 (file)
@@ -111,8 +111,8 @@ class wsDAODocument extends commonDAO {
 \r
        public function setLinksAndRulers($book_id, $links, $rulers, $comments = '', $user = 0) {\r
                $daoBook = new wsDAOBook($this->con);\r
-               $pages = $daoBook->getPagesOfBook($book_id,false);\r
-               \r
+               $pages = $daoBook->getPagesOfBook($book_id, false);\r
+\r
                if (is_array($links)) {\r
                        $links = json_encode($links);\r
                }\r
@@ -140,6 +140,18 @@ class wsDAODocument extends commonDAO {
                $links = array();\r
                $rulers = array();\r
 \r
+               foreach ($pages as $p) {\r
+                       if (!isset($links[$p['document_id']])) {\r
+                               $links[$p['document_id']] = array();\r
+                               $rulers[$p['document_id']] = array();\r
+                       }\r
+                       \r
+                       if (!isset($links[$p['document_id']][$p['document_page']])) {\r
+                               $links[$p['document_id']][$p['document_page']] = array();\r
+                               $rulers[$p['document_id']][$p['document_page']] = array();\r
+                       }\r
+               }\r
+\r
                foreach ($t as $page => $tt) {\r
                        if (!is_int($page)) {\r
                                continue;\r
@@ -166,6 +178,8 @@ class wsDAODocument extends commonDAO {
                        }\r
                }\r
 \r
+               fb($links);\r
+\r
                foreach ($links as $document_id => $dummy) {\r
                        wsLinks::setDocumentLinks($document_id, json_encode($links[$document_id]), json_encode($rulers[$document_id]), $user, $comments, TIME);\r
                }\r
index 3309e972a885dd433eef1611e648553d6ba26540..fb4528a496a9a4292079dfbd5fefa5d4808c1861 100644 (file)
@@ -69,7 +69,7 @@ class wsBookParametres extends wsParametres {
                $this->fields['friendWidth'] = array('type' => 'integer', 'default' => 319, 'editable' => true, 'label' => __('Largeur du menu'), 'grade' => 5);\r
                $this->fields['friendHeight'] = array('type' => 'integer', 'default' => 500, 'editable' => true, 'label' => __('Largeur du menu'), 'grade' => 5);\r
                $this->forms['share'] = array('label' => __('Fonctions de partage'),\r
-                       'fieldsnames' => array('share','|','email_title', 'email_body', 'email_editable', 'askAcknowledge', '|',\r
+                       'fieldsnames' => array('share', '|', 'email_title', 'email_body', 'email_editable', 'askAcknowledge', '|',\r
                                'facebook_title', 'facebook_description', 'facebook_image', 'twitter_description', '|',\r
                                'friend', 'facebook', 'twitter', 'googleplus', 'linkedin', 'viadeo', '|', 'customSharer', '|', 'friendWidth', 'friendHeight'));\r
                // .\r
@@ -176,10 +176,11 @@ class wsBookParametres extends wsParametres {
                // .\r
                $this->fields['stats'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les statistiques Fluidbook'), 'grade' => 3);\r
                $this->fields['stats_score'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher les scores dans les rapports'), 'grade' => 5);\r
+               $this->fields['stats_exclude_ip'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Exclure les IP suivantes des statistiques'), 'grade' => 3, 'hint' => sprintf(__('Indiquer une adresse ip de la forme %s par ligne'), 'www.xxx.yyy.zzz'));\r
                $this->fields['googleAnalytics'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Code Google Analytics'), 'size' => 10);\r
                $this->fields['googleAnalyticsCustom'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Code Google Analytics personnalisé'));\r
                $this->forms['stats'] = array('label' => __('Statistiques'),\r
-                       'fieldsnames' => array('stats', 'stats_score', '|', 'googleAnalytics', 'googleAnalyticsCustom'));\r
+                       'fieldsnames' => array('stats', 'stats_score', 'stats_exclude_ip', '|', 'googleAnalytics', 'googleAnalyticsCustom'));\r
 \r
                $this->fields['displayChaptersIcon'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Affiche l'icône du sommaire"), 'grade' => 1);\r
                $this->fields['displayChaptersLine'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Affiche une ligne entre le label et le numéro de page"), 'grade' => 5);\r
index f5beba03bbae7393ac75465e2167a2ec5b9ee8f6..c6cb669dd8e34f5d5f90c68948acab37986d5d09 100644 (file)
@@ -3,7 +3,7 @@ FIRST_LOAD = true;
 function load_extranet() {\r
 \r
        if ($("#devisAdresse #client_nom").length > 0) {\r
-               $("#devisAdresse #client_nom").autocomplete(SITE_PATH + 'autocomplete/client', {\r
+               $("#devisAdresse #client_nom").autocompletej(SITE_PATH + 'autocomplete/client', {\r
                        cacheLength: 0,\r
                        maxItemsToShow: 15,\r
                        onFindValue: findClient,\r
@@ -13,7 +13,7 @@ function load_extranet() {
 \r
 \r
        if ($("#factureAdresse #projet_nom").length > 0) {\r
-               $("#factureAdresse #projet_nom").autocomplete(SITE_PATH + 'autocomplete/projet', {\r
+               $("#factureAdresse #projet_nom").autocompletej(SITE_PATH + 'autocomplete/projet', {\r
                        cacheLength: 0,\r
                        maxItemsToShow: 15,\r
                        onFindValue: findProjet,\r
index a1c76a2b941791322b8ce50bfbea3fc455340b3a..93b895b85e215203761f0db533e97bf251d96d04 100644 (file)
--- a/js/ws.js
+++ b/js/ws.js
@@ -10,24 +10,64 @@ function load_ws_once() {
        });\r
 \r
        if ($("#collection").length > 0) {\r
-               $("#collection>ul").sortable({\r
-                       cancel: 'h3,input',\r
+               $("#collection>form>ul").sortable({\r
+                       cancel: 'h1',\r
                        axis: 'y',\r
                        handle: '.move'\r
                });\r
 \r
-               $("#collection>ul ul").sortable({\r
-                       cancel: 'h3,input',\r
-                       axis: 'y',\r
-                       handle: '.move',\r
-                       connectWith: '#collection>ul ul'\r
+\r
+               $("#collection>form>ul a.delete").click(function() {\r
+                       $(this).parents('li:first').remove();\r
+               });\r
+\r
+               $("#collection>form>ul>li").each(function() {\r
+                       initGroup($(this));\r
+               });\r
+\r
+\r
+               var newCounter = 1;\r
+\r
+               $("#newGroup").click(function() {\r
+                       var g = $(".group.empty").clone();\r
+                       var html = g.get(0).outerHTML;\r
+                       html = html.replace(/new_/gi, "new_" + newCounter);\r
+                       g = $(html);\r
+                       $(g).removeClass('empty');\r
+                       $("#collection>form>ul").append(g);\r
+\r
+                       initGroup(g);\r
+\r
+                       newCounter++;\r
+                       return false;\r
+               });\r
+       }\r
+}\r
+\r
+function initGroup(group) {\r
+       $(group).find("ul").sortable({\r
+               cancel: 'h1',\r
+               axis: 'y',\r
+               handle: '.move',\r
+               connectWith: '#collection>form>ul ul'\r
+       });\r
+\r
+       try {\r
+               $('.publication_id').autocompletej(SITE_PATH + 'autocomplete/book', {\r
+                       cacheLength: 0,\r
+                       maxItemsToShow: 15,\r
+                       onFindValue: findBook,\r
+                       onItemSelect: findBook\r
                });\r
+       } catch (err) {\r
+               fb(err);\r
        }\r
+\r
 }\r
 \r
 function load_ws() {\r
        if ($("#book_nom").length) {\r
-               $("#book_nom").autocomplete(SITE_PATH + 'autocomplete/book', {\r
+               $("#book_nom").autocompletej(SITE_PATH + 'autocomplete/book', {\r
                        cacheLength: 0,\r
                        maxItemsToShow: 15,\r
                        onFindValue: findBook,\r
@@ -36,7 +76,7 @@ function load_ws() {
        }\r
 \r
        if ($("#book_proprietaire").length) {\r
-               $("#book_proprietaire").autocomplete(SITE_PATH + 'autocomplete/wsuser', {\r
+               $("#book_proprietaire").autocompletej(SITE_PATH + 'autocomplete/wsuser', {\r
                        cacheLength: 0,\r
                        maxItemsToShow: 15,\r
                        onFindValue: findProprietaire,\r
@@ -46,7 +86,7 @@ function load_ws() {
 \r
 \r
        if ($("#ws_admin_nom").length > 0) {\r
-               $("#ws_admin_nom").autocomplete(SITE_PATH + 'autocomplete/wsadmin', {\r
+               $("#ws_admin_nom").autocompletej(SITE_PATH + 'autocomplete/wsadmin', {\r
                        cacheLength: 0,\r
                        maxItemsToShow: 15,\r
                        onFindValue: findWSAdmin,\r
@@ -101,10 +141,11 @@ function findProprietaire(li) {
 }\r
 \r
 function findBook(li) {\r
+\r
        var book = li.selectValue.split(' - ');\r
        if (book.length <= 1) {\r
                return;\r
        }\r
        var book_id = parseInt(book[0]);\r
-       $("#book").val(book_id);\r
+       $(this.input).next('input[type="hidden"]:first').val(book_id);\r
 }
\ No newline at end of file
index b68df448628ba937266292dbba4e0424299f69ee..7f044f3fd145a4d83bf3b2371e65089e178b891f 100644 (file)
@@ -593,11 +593,23 @@ th.stats_col{
        padding:5px;\r
 }\r
 \r
+#collection .min.nowrap{\r
+       padding:0 15px 0 0;\r
+}\r
+\r
 #collection h1{\r
        margin:5px 0 10px;\r
        padding:0;\r
 }\r
 \r
+#collection .group.empty{\r
+       display:none;\r
+}\r
+\r
+#collection .g{\r
+       padding:2px 6px;\r
+}\r
+\r
 #collection h3{margin:10px 0 10px 0 !important;}\r
 #collection .group,\r
 #collection .publication{\r
@@ -654,4 +666,8 @@ th.stats_col{
 #collection input,\r
 #collection select{\r
        width:auto;\r
+}\r
+\r
+#collection .submit{\r
+       float:right;\r
 }
\ No newline at end of file