From 379f70f6be577699a1a2728c3948ec8853a12d72 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 15 Feb 2013 11:04:19 +0000 Subject: [PATCH] --- .../Controlleur/class.extranet.droits.php | 1 - inc/ws/Controlleur/class.ws.url.php | 53 ++++++++++++++++++- inc/ws/DAO/class.ws.dao.book.php | 15 ++++++ inc/ws/DAO/class.ws.dao.collection.php | 42 ++++++++++++++- inc/ws/Metier/class.ws.collection.php | 1 + style/ws/style.css | 7 +++ 6 files changed, 116 insertions(+), 3 deletions(-) diff --git a/inc/extranet/Controlleur/class.extranet.droits.php b/inc/extranet/Controlleur/class.extranet.droits.php index 9f623d1e1..9cbe23028 100644 --- a/inc/extranet/Controlleur/class.extranet.droits.php +++ b/inc/extranet/Controlleur/class.extranet.droits.php @@ -37,7 +37,6 @@ class extranetDroits { public static function projet($projet, $error) { - fb($projet); return self::verifDroits($projet->chef_id, 0, 'w', $error); } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 3274bed4a..bfec654c9 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -203,6 +203,57 @@ class wsUrl { return $res; } + public static function collection($args) { + global $core; + commonDroits::min(1); + + $dao = new wsDAOCollection($core->con); + $collection = $dao->selectById($args[1]); + + + $shortcuts = array(); + $shortcuts[] = '
Gestion de la collection « ' . $collection->nom . ' » # ' . $collection->collection_id . '
'; + $shortcuts[] = '' . $core->typo->Ajouter('Nouveau groupe') . ''; + + $res = commonPage::barre(null, null, null, $shortcuts); + $res .= commonPage::tMain(); + $res .= commonPage::bh(); + $res .= '
'; + $res .= self::collectionEdit($collection); + $res .= '
'; + $res .= commonPage::bf(); + $res .= commonPage::bMain(); + return $res; + } + + public static function collectionEdit($collection) { + global $core; + + $res = ''; + + $dao = new wsDAOCollection($core->con); + $books = $dao->getPublications($collection->collection_id); + + foreach ($collection->datas as $gid => $group) { + $res.='
'; + $res.='
'; + $g = 'group[' . $gid . ']'; + $res.=__('Nom du groupe') . ' ' . form::field(array($g . '[label]'), 20, 64, $group['label']); + $res.='
'; + foreach ($group['publications'] as $pid => $publication) { + $p = $g . '[publication][' . $pid . ']'; + $res.='
'; + $book = $books[$publication['id']]; + $res.=mb_strtoupper($book['lang']); + $res.='# ' . form::field($p . '[id]', 20, 64, $publication['id']) . ''; + $res.='' . __('Label') . ' ' . form::field($p . '[label]', 20, 64, $publication['label']) . ''; + $res.='
'; + } + $res.='
'; + } + return $res; + } + public static function listeCollections($dashboard = null, $settings = null) { global $core; @@ -251,7 +302,7 @@ class wsUrl { } $res .= ''; - $res .= '' . $btEdit . ''; + $res .= '' . $btEdit . ''; $res .= ''; $res .= ''; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index f01e7d1b4..da4a168d9 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -109,6 +109,21 @@ class wsDAOBook extends commonDAO { $this->con->select('UPDATE books SET demo_counter=demo_counter+1 WHERE book_id=\'' . $book_id . '\''); } + public function selectByIds($book_ids = array(), $simple = false) { + if ($simple) { + $table = 'books'; + } else { + $table = 'books_vue'; + } + $sql = 'SELECT * FROM ' . $table . ' WHERE book_id IN (' . implode(',', $book_ids) . ')'; + $books = $this->factory($this->con->select($sql)); + $res = array(); + foreach ($books as $book) { + $res[$book->book_id] = $book; + } + return $res; + } + public function selectById($book_id = null, $simple = false) { if (is_null($book_id)) { return $this->cree(); diff --git a/inc/ws/DAO/class.ws.dao.collection.php b/inc/ws/DAO/class.ws.dao.collection.php index 1a747d1cd..b85710ec5 100644 --- a/inc/ws/DAO/class.ws.dao.collection.php +++ b/inc/ws/DAO/class.ws.dao.collection.php @@ -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(); + } + } + } ?> diff --git a/inc/ws/Metier/class.ws.collection.php b/inc/ws/Metier/class.ws.collection.php index 66d04851c..0ae3f7d52 100644 --- a/inc/ws/Metier/class.ws.collection.php +++ b/inc/ws/Metier/class.ws.collection.php @@ -6,6 +6,7 @@ class wsCollection extends cubeMetier { protected $proprietaire; protected $proprietaire_nom; protected $proprietaire_utilisateur; + protected $datas; } ?> diff --git a/style/ws/style.css b/style/ws/style.css index 191ea4113..9818fb181 100644 --- a/style/ws/style.css +++ b/style/ws/style.css @@ -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;} .shortcut .step{margin-top:5px;} +.shortcut .label{ + margin:15px 20px 0 5px; + font-size: 16px; + font-family:UniversCondensedBold; + text-transform: uppercase; +} + /* Filtres */ .filtre{ color:#5f6162; -- 2.39.5