From: vincent@cubedesigners.com Date: Mon, 26 Apr 2010 13:11:07 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=6d186bcc55d380bb28700a8d0561991f30d6027a;p=cubeextranet.git --- diff --git a/importWs.php b/importWs.php index db233aa9b..831a9b3bd 100644 --- a/importWs.php +++ b/importWs.php @@ -6,11 +6,12 @@ cubePHP::neverStop(); $utilisateurs = false; $documents = false; $books = false; -$tables = array('books', 'book_pages', 'dashboard', 'devis', 'documents', 'document_pages', 'entreprises', 'factures', 'icones', 'langues', 'projets', 'signatures', 'taches', 'themes', 'timereport', 'utilisateurs'); +$tables = array('books', 'book_pages', 'dashboard', 'devis', 'documents', 'document_pages', 'entreprises', 'factures', 'icones', 'langues', 'projets', 'signatures', 'taches', 'themes', 'timereport', 'utilisateurs', 'themes_droits'); foreach($tables as $t) { $core->con->execute('ALTER TABLE ' . $t . ' DISABLE KEYS'); } +$core->con->execute('TRUNCATE TABLE themes_droits'); $core->con->execute('TRUNCATE TABLE themes'); $core->con->execute('TRUNCATE TABLE icones'); $core->con->execute('TRUNCATE TABLE signatures'); @@ -164,7 +165,7 @@ while ($r->fetch()) { } // Import des thèmes $r = $core->con->select('SELECT * FROM ws.theme'); -$theme=new wsTheme(); +$theme = new wsTheme(); while ($r->fetch()) { $c = $core->con->openCursor('themes'); $c->theme_id = $r->tid; @@ -175,10 +176,20 @@ while ($r->fetch()) { $c->signature = $r->sigid; $parametres = new wsThemeParametres($theme); $parametres->fromRecord($r); - $parametres->iconSet=$r->iid; + $parametres->iconSet = $r->iid; $c->parametres = serialize($parametres); $c->insert(); } +$r = $core->con->select('SELECT * FROM ws.theme_user'); +$c = $core->con->openCursor('themes_droits'); +while ($r->fetch()) { + $c->utilisateur_id = $r->uid; + $c->theme_id = $r->tid; + try{ + $c->insert(); + }catch(Exception $e){ + } +} // Importe les langues $trad = array(); $r = $core->con->select('SELECT * FROM ws.lang_trad,ws.lang_ord WHERE lang_trad.idlt=lang_ord.idlt'); diff --git a/inc/config.inc.php b/inc/config.inc.php index 2be73b447..883cca2ca 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -23,6 +23,7 @@ if (in_array($_SERVER['HTTP_HOST'], array_merge($localrel, $localabs))) { define('SITE_PATH', WEBROOT . '/'); } define('CONVERTER_PATH', ROOT . '/tools/'); + define('FTPROOT','/'); } else { // Définition des variables dans l'environnement de production define('DB_HOST', 'localhost'); diff --git a/inc/extranet/Controlleur/class.extranet.core.php b/inc/extranet/Controlleur/class.extranet.core.php index d0ffe450d..0f025a917 100644 --- a/inc/extranet/Controlleur/class.extranet.core.php +++ b/inc/extranet/Controlleur/class.extranet.core.php @@ -152,7 +152,7 @@ class extranetCore extends cubeCore { $db->entreprises->site('varchar', 256, false); // Clés $db->entreprises->primary('pk_entreprises', 'entreprise_id'); - $db->entreprises->index('index_entreprises_nom','BTREE', 'nom'); + $db->entreprises->index('index_entreprises_nom', 'BTREE', 'nom'); // . // Table projets $db->projets->projet_id('integer', 0, false); @@ -284,6 +284,13 @@ class extranetCore extends cubeCore { $db->themes->reference('fk_themes_icones', 'icones', 'icones', 'icone_id'); $db->themes->reference('fk_themes_signature', 'signature', 'signatures', 'signature_id'); $db->themes->reference('fk_themes_proprietaires', 'proprietaire', 'utilisateurs', 'utilisateur_id'); + // Table des droits des themes + $db->themes_droits->theme_id('integer', 0, false); + $db->themes_droits->utilisateur_id('integer', 0, false); + // Clés + $db->themes_droits->primary('pk_themes_droits', 'theme_id', 'utilisateur_id'); + $db->themes_droits->reference('fk_themes_droits_theme_id', 'theme_id', 'themes', 'theme_id'); + $db->themes_droits->reference('fk_themes_droits_utilisateur_id', 'utilisateur_id', 'utilisateurs', 'utilisateur_id'); // Table des langues $db->langues->lang('varchar', 20, false); $db->langues->nom('varchar', 256, false); @@ -445,6 +452,11 @@ class extranetCore extends cubeCore { . 'GROUP BY t.categorie,p.annee_fin'); $this->createView('books_vue', 'SELECT b.*,b.proprietaire AS proprietaire_id,c.rs AS proprietaire_nom,c.ws_admin,c.facturable_id,c.facturable ' . 'FROM books b, ws_clients c WHERE b.proprietaire=c.utilisateur_id'); + $this->createView('themes_vue', 'SELECT t.*,GROUP_CONCAT(b.book_id ORDER BY b.book_id ASC) AS books, GROUP_CONCAT(DISTINCT d.utilisateur_id ORDER BY d.utilisateur_id ASC) AS utilisateurs ' + . 'FROM themes t ' + . 'LEFT JOIN themes_droits d ON t.theme_id=d.theme_id ' + . 'LEFT JOIN books b ON t.theme_id=b.theme ' + . 'GROUP BY b.theme, d.theme_id'); // cubeDb::mysqlConvert($this->con); touch($cache); } diff --git a/inc/extranet/DAO/class.extranet.dao.utilisateur.php b/inc/extranet/DAO/class.extranet.dao.utilisateur.php index 37dc303ea..6ad83bcbc 100644 --- a/inc/extranet/DAO/class.extranet.dao.utilisateur.php +++ b/inc/extranet/DAO/class.extranet.dao.utilisateur.php @@ -40,6 +40,7 @@ class extranetDAOUtilisateur extends extranetDAO { $utilisateur->notes = $r->notes; $utilisateur->entreprise = $r->entreprise; $utilisateur->collegues = array(); + $utilisateur->ws_grade = $r->ws_grade; return $utilisateur; } @@ -66,6 +67,7 @@ class extranetDAOUtilisateur extends extranetDAO { $utilisateur->settings = array(); $utilisateur->notes = ''; $utilisateur->entreprise = 0; + $utilisateur->ws_grade=0; return $utilisateur; } diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 880d75462..e0fdfa587 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -141,18 +141,32 @@ class wsFlash extends cubeFlashGateway { { global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); + if (isset($this->args['book_id'])) { + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + } $dao = new wsDAOTheme($core->con); - $themes = $dao->getAllThemes('ORDER BY theme_id DESC'); + $themes = $dao->getAllThemes($core->user, 'ORDER BY theme_id DESC'); foreach($themes as $theme) { $t = $this->xml->addChild('theme'); $t->addAttribute('id', $theme->theme_id); $t->addAttribute('nom', $theme->nom); - if ($theme->theme_id == $book->theme) { + if (isset($book) && $theme->theme_id == $book->theme) { $t->addAttribute('selected', '1'); } + if ($core->user->ws_grade == 4) { + $right = 'w'; + } else if ($core->user->ws_grade == 2) { + $right = 'r'; + } else if ($core->user->ws_grade == 3) { + $right = ($core->user->utilisateur_id == $theme->proprietaire)?'w':'r'; + } else { + $right = '-'; + } + $t->addAttribute('right', $right); + $t->addAttribute('books', count($theme->books)); + $t->addAttribute('utilisateurs', count($theme->utilisateurs)); } } diff --git a/inc/ws/DAO/class.ws.dao.theme.php b/inc/ws/DAO/class.ws.dao.theme.php index 357d34aa7..dc4021e96 100644 --- a/inc/ws/DAO/class.ws.dao.theme.php +++ b/inc/ws/DAO/class.ws.dao.theme.php @@ -7,12 +7,14 @@ class wsDAOTheme extends extranetDAO { $theme->nom = $r->nom; $theme->date = $r->date; $theme->proprietaire = $r->proprietaire; + $theme->utilisateurs = explode(',', $r->utilisateurs); + $theme->books = explode(',', $r->books); $theme->signature = $r->signature; $theme->icones = $r->icones; $p = unserialize($r->parametres); if (!$p) { $p = new wsThemeParametres($theme); - }else{ + } else { $p->setParent($theme); } $theme->parametres = $p; @@ -22,19 +24,28 @@ class wsDAOTheme extends extranetDAO { public function selectById($theme_id) { - $r = $this->con->select('SELECT * FROM themes WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1'); + $r = $this->con->select('SELECT * FROM themes_vue WHERE theme_id=\'' . $this->con->escape($theme_id) . '\' LIMIT 1'); return $this->singleton($r); } public function getThemeOfBook($book_id) { - $r = $this->con->select('SELECT * FROM themes WHERE theme_id IN (SELECT theme FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\') LIMIT 1'); + $r = $this->con->select('SELECT * FROM themes_vue WHERE FIND_IN_SET(\'' . $this->con->escape($book_id) . '\'books) LIMIT 1'); return $this->singleton($r); } - public function getAllThemes($order='') + public function getAllThemes($user, $order = '') { - $r = $this->con->select('SELECT * FROM themes '.$order); + fb($user); + if ($user->ws_grade >= 3) { + $sql = 'SELECT * FROM themes_vue'; + } else if ($user->ws_grade == 2) { + $sql = 'SELECT * FROM themes_vue WHERE FIND_IN_SET(utilisateurs,\'' . $core->con->escape($user->utilisateur_id) . '\')'; + } else { + return array(); + } + + $r = $this->con->select($sql . ' ' . $order); return $this->factory($r); } } diff --git a/inc/ws/Metier/class.ws.theme.php b/inc/ws/Metier/class.ws.theme.php index bdc04f57e..71e8fda73 100644 --- a/inc/ws/Metier/class.ws.theme.php +++ b/inc/ws/Metier/class.ws.theme.php @@ -14,6 +14,8 @@ class wsTheme extends cubeMetier { protected $nom; protected $date; protected $parametres; + protected $utilisateurs; + protected $books; } ?> \ No newline at end of file