\r
public static function projet($projet, $error)\r
{\r
- fb($projet);\r
return self::verifDroits($projet->chef_id, 0, 'w', $error);\r
}\r
\r
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 « ' . $collection->nom . ' » <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
}\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
$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
$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;
}
$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;
}
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) . '\'');
}
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();
+ }
+ }
+
}
?>
protected $proprietaire;
protected $proprietaire_nom;
protected $proprietaire_utilisateur;
+ protected $datas;
}
?>
.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