]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 15 Feb 2013 11:04:19 +0000 (11:04 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 15 Feb 2013 11:04:19 +0000 (11:04 +0000)
inc/extranet/Controlleur/class.extranet.droits.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/Metier/class.ws.collection.php
style/ws/style.css

index 9f623d1e1b168240d22c3a2b8fefcc944e450655..9cbe230284a507440da648b7b679b90cce2825db 100644 (file)
@@ -37,7 +37,6 @@ class extranetDroits {
 \r
        public static function projet($projet, $error)\r
        {\r
-               fb($projet);\r
                return self::verifDroits($projet->chef_id, 0, 'w', $error);\r
        }\r
 \r
index 3274bed4a1bd2b9c2b27c5a39ceace37c167104d..bfec654c94acb981fb32dc8914324d441542eb54 100644 (file)
@@ -203,6 +203,57 @@ class wsUrl {
                return $res;\r
        }\r
 \r
+       public static function collection($args) {\r
+               global $core;\r
+               commonDroits::min(1);\r
+\r
+               $dao = new wsDAOCollection($core->con);\r
+               $collection = $dao->selectById($args[1]);\r
+\r
+\r
+               $shortcuts = array();\r
+               $shortcuts[] = '<div class="label">Gestion de la collection &laquo; ' . $collection->nom . ' &raquo; <em># ' . $collection->collection_id . '</em></div>';\r
+               $shortcuts[] = '<a href="#">' . $core->typo->Ajouter('Nouveau groupe') . '</a>';\r
+\r
+               $res = commonPage::barre(null, null, null, $shortcuts);\r
+               $res .= commonPage::tMain();\r
+               $res .= commonPage::bh();\r
+               $res .= '<div id="collection">';\r
+               $res .= self::collectionEdit($collection);\r
+               $res .= '</div>';\r
+               $res .= commonPage::bf();\r
+               $res .= commonPage::bMain();\r
+               return $res;\r
+       }\r
+\r
+       public static function collectionEdit($collection) {\r
+               global $core;\r
+\r
+               $res = '';\r
+\r
+               $dao = new wsDAOCollection($core->con);\r
+               $books = $dao->getPublications($collection->collection_id);\r
+\r
+               foreach ($collection->datas as $gid => $group) {\r
+                       $res.='<div class="group">';\r
+                       $res.='<div class="g">';\r
+                       $g = 'group[' . $gid . ']';\r
+                       $res.=__('Nom du groupe') . ' ' . form::field(array($g . '[label]'), 20, 64, $group['label']);\r
+                       $res.='</div>';\r
+                       foreach ($group['publications'] as $pid => $publication) {\r
+                               $p = $g . '[publication][' . $pid . ']';\r
+                               $res.='<div class="publication">';\r
+                               $book = $books[$publication['id']];\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.='</div>';\r
+                       }\r
+                       $res.='</div>';\r
+               }\r
+               return $res;\r
+       }\r
+\r
        public static function listeCollections($dashboard = null, $settings = null) {\r
                global $core;\r
 \r
@@ -251,7 +302,7 @@ class wsUrl {
                        }\r
 \r
                        $res .= '<td class="bouton"><!--<a href="#" class="normallink voir btbook">' . $btVoir . '</a>--></td>';\r
-                       $res .= '<td class="bouton"><a href="/collection/'.$collection->collection_id.'" class="normallink edit btbook">' . $btEdit . '</a></td>';\r
+                       $res .= '<td class="bouton"><a href="/collection/' . $collection->collection_id . '" class="normallink edit btbook">' . $btEdit . '</a></td>';\r
                        $res .= '<td class="bouton"><!--<a href="#" class="normallink download btbook">' . $btDownload . '</a>--></td>';\r
                        $res .= '<td class="bouton"><!--<a href="#" class="normallink suppr btbook">' . $btDel . '</a>--></td>';\r
 \r
index f01e7d1b4284bef0764ec1867d85496298bcadd7..da4a168d92097e90f1dfca51f86c23d086c42ce4 100644 (file)
@@ -109,6 +109,21 @@ class wsDAOBook extends commonDAO {
                $this->con->select('UPDATE books SET demo_counter=demo_counter+1 WHERE book_id=\'' . $book_id . '\'');\r
        }\r
 \r
+       public function selectByIds($book_ids = array(), $simple = false) {\r
+               if ($simple) {\r
+                       $table = 'books';\r
+               } else {\r
+                       $table = 'books_vue';\r
+               }\r
+               $sql = 'SELECT * FROM ' . $table . ' WHERE book_id IN (' . implode(',', $book_ids) . ')';\r
+               $books = $this->factory($this->con->select($sql));\r
+               $res = array();\r
+               foreach ($books as $book) {\r
+                       $res[$book->book_id] = $book;\r
+               }\r
+               return $res;\r
+       }\r
+\r
        public function selectById($book_id = null, $simple = false) {\r
                if (is_null($book_id)) {\r
                        return $this->cree();\r
index 1a747d1cde9ef9f11727a7324040325f2e6a0d90..b85710ec5db7aac0503170ce98c2a0221a1941a7 100644 (file)
@@ -9,6 +9,11 @@ class wsDAOCollection extends commonDAO {
                $collection->proprietaire = $r->proprietaire;
                $collection->proprietaire_nom = $r->proprietaire_nom;
                $collection->proprietaire_utilisateur = $r->proprietaire_utilisateur;
+               if (CubeIT_Util_Json::isJson($r->datas)) {
+                       $collection->datas = CubeIT_Util_Json::decode($r->datas, CubeIT_Util_Json::TYPE_ARRAY);
+               } else {
+                       $collection->datas = $this->_emptyCollection();
+               }
                return $collection;
        }
 
@@ -17,12 +22,28 @@ class wsDAOCollection extends commonDAO {
                $collection->collection_id = 'new';
                $collection->nom = '';
                $collection->proprietaire = 0;
+               $collection->datas = $this->_emptyCollection();
                return $collection;
        }
 
+       protected function _emptyCollection() {
+               return array($this->_emptyGroup());
+       }
+
+       protected function _emptyGroup() {
+               return array('label' => '', 'publications' => array($this->_emptyPublication()));
+       }
+
+       protected function _emptyPublication() {
+               return array('id' => '', 'label' => '', 'online' => false);
+       }
+
        public function sauve($data, $createur = null) {
                $c = $this->con->openCursor('book_collection');
                $c->nom = $data['nom'];
+               if (isset($data['datas'])) {
+                       $c->datas = CubeIT_Util_Json::encode($data['datas']);
+               }
                if (!is_null($createur) && $data['collection_id'] == 'new') {
                        $c->proprietaire = $createur;
                }
@@ -75,7 +96,7 @@ class wsDAOCollection extends commonDAO {
 
        public function setProprietaire($collection_id, $proprietaire) {
                $c = $this->con->openCursor('book_collection');
-               $c->proprietaire=$proprietaire;
+               $c->proprietaire = $proprietaire;
                $c->update('WHERE collection_id=\'' . $this->con->escape($collection_id) . '\'');
        }
 
@@ -83,6 +104,25 @@ class wsDAOCollection extends commonDAO {
                return '1=1';
        }
 
+       public function getPublications($collection_id) {
+               $collection = $this->selectById($collection_id);
+               $ids = array();
+               foreach ($collection->datas as $group) {
+                       foreach ($group['publications'] as $publication) {
+                               if ($publication->id != '') {
+                                       $ids[] = $publication->id;
+                               }
+                       }
+               }
+
+               if (count($ids) > 0) {
+                       $dao = new wsDAOBook($this->con);
+                       return $dao->selectByIds($ids);
+               } else {
+                       return array();
+               }
+       }
+
 }
 
 ?>
index 66d04851c694777456cea717d45d2f49d1c814cc..0ae3f7d5209a616969c6a4a972bdb2dab5b0a11b 100644 (file)
@@ -6,6 +6,7 @@ class wsCollection extends cubeMetier {
        protected $proprietaire;
        protected $proprietaire_nom;
        protected $proprietaire_utilisateur;
+       protected $datas;
 }
 
 ?>
index 191ea41132b35b468c89827d30f0ed437ef4061b..9818fb1814bf0390b4b88d9f662aa6a27a2f7d36 100644 (file)
@@ -245,6 +245,13 @@ input[type="text"],input[type="password"],input[type="email"],input[type="search
 .shortcut{float:left;margin-left:5px;margin-top:3px;}\r
 .shortcut .step{margin-top:5px;}\r
 \r
+.shortcut .label{\r
+       margin:15px 20px 0 5px;\r
+       font-size: 16px;\r
+       font-family:UniversCondensedBold;\r
+       text-transform: uppercase;\r
+}\r
+\r
 /* Filtres */\r
 .filtre{\r
        color:#5f6162;\r