]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 11 May 2011 09:09:53 +0000 (09:09 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 11 May 2011 09:09:53 +0000 (09:09 +0000)
inc/commons/class.common.core.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/DAO/class.ws.dao.document.php
inc/ws/Metier/class.ws.book.php

index b655155c41f3e00044a786ebd0f8973c4fcfd123..c0e927ffa422e12dfb8ad529ea9766f5ec53b888 100644 (file)
@@ -1,20 +1,22 @@
 <?php\r
+\r
 class commonCore extends cubeCore {\r
+\r
        public $grades;\r
        public $user;\r
        public $agences;\r
        public $categories;\r
        public $ws_grades;\r
-       public function __construct()\r
-       {\r
+\r
+       public function __construct() {\r
                parent::__construct();\r
                $this->dbSync();\r
 \r
                cubeLang::set();\r
                try {\r
                        $this->authentifie();\r
-               }\r
-               catch(Exception $e) {\r
+               } catch (Exception $e) {\r
+                       \r
                }\r
 \r
                if ($this->user) {\r
@@ -61,8 +63,7 @@ class commonCore extends cubeCore {
         *\r
         * @return\r
         */\r
-       protected function authentifie()\r
-       {\r
+       protected function authentifie() {\r
                // On regarde si user_email et user_password ont été postées\r
                // Si c'est le cas, on les copie dans la session\r
                $_SESSION['errorLogin'] = false;\r
@@ -100,8 +101,7 @@ class commonCore extends cubeCore {
         *\r
         * @return\r
         */\r
-       public function dbSync()\r
-       {\r
+       public function dbSync() {\r
                $cache = ROOT . '/cache/DB_SYNC';\r
                $todo = ROOT . '/cache/DB_TODO';\r
                if (!file_exists($cache)) {\r
@@ -366,6 +366,8 @@ class commonCore extends cubeCore {
                $db->books->chapters('text', 0, false);\r
                $db->books->extras('text', 0, false);\r
                $db->books->traductions('text', 0, false);\r
+               $db->books->specialLinks('text', 0, false);\r
+               $db->books->specialRulers('text', 0, false);\r
                $db->books->date('integer', 0, false);\r
                $db->books->numerotation('text', 0, false);\r
                $db->books->changedate('integer', 0, false);\r
@@ -433,8 +435,7 @@ class commonCore extends cubeCore {
                try {\r
                        $dbi = new CubeDbStruct($this->con);\r
                        $dbi->synchronize($db);\r
-               }\r
-               catch(Exception $e) {\r
+               } catch (Exception $e) {\r
                        fb($e);\r
                        return;\r
                }\r
@@ -442,133 +443,129 @@ class commonCore extends cubeCore {
                $this->views->createView('equipiers', 'SELECT * FROM utilisateurs WHERE grade>=1');\r
                $this->views->createView('gerants', 'SELECT * FROM utilisateurs WHERE grade=2');\r
                $this->views->createView('impayes_entreprises', 'SELECT SUM(total_ht) AS impaye, u.entreprise AS entreprise '\r
-                        . 'FROM utilisateurs u LEFT JOIN projets p ON u.utilisateur_id=p.client LEFT JOIN factures f ON f.projet=p.projet_id '\r
-                        . 'WHERE f.status=1 GROUP BY u.entreprise');\r
+                               . 'FROM utilisateurs u LEFT JOIN projets p ON u.utilisateur_id=p.client LEFT JOIN factures f ON f.projet=p.projet_id '\r
+                               . 'WHERE f.status=1 GROUP BY u.entreprise');\r
                $this->views->createView('entreprises_inter', 'SELECT e.*,'\r
-                        . 'SUM(f.total_ht) AS ca '\r
-                        . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND grade=0 '\r
-                        . 'LEFT JOIN projets p ON p.client=u.utilisateur_id '\r
-                        . 'LEFT JOIN factures f ON f.projet=p.projet_id AND f.status IN(1,2) '\r
-                        . 'GROUP BY e.entreprise_id');\r
+                               . 'SUM(f.total_ht) AS ca '\r
+                               . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND grade=0 '\r
+                               . 'LEFT JOIN projets p ON p.client=u.utilisateur_id '\r
+                               . 'LEFT JOIN factures f ON f.projet=p.projet_id AND f.status IN(1,2) '\r
+                               . 'GROUP BY e.entreprise_id');\r
                $this->views->createView('entreprises_vue', 'SELECT e.*,i.impaye AS impaye '\r
-                        . 'FROM entreprises_inter e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise');\r
+                               . 'FROM entreprises_inter e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise');\r
                $this->views->createView('entreprises_ws', 'SELECT e.*, a.prenom AS administrateur, r.nom AS revendeur,a.utilisateur_id AS ws_super_admin '\r
-                        . 'FROM entreprises e '\r
-                        . 'LEFT JOIN ws_entreprises_tree ri ON ri.entreprise_id=e.entreprise_id '\r
-                        . 'LEFT JOIN utilisateurs ur ON e.ws_admin=ur.utilisateur_id '\r
-                        . 'LEFT JOIN entreprises r ON ur.entreprise=r.entreprise_id '\r
-                        . 'LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id ');\r
+                               . 'FROM entreprises e '\r
+                               . 'LEFT JOIN ws_entreprises_tree ri ON ri.entreprise_id=e.entreprise_id '\r
+                               . 'LEFT JOIN utilisateurs ur ON e.ws_admin=ur.utilisateur_id '\r
+                               . 'LEFT JOIN entreprises r ON ur.entreprise=r.entreprise_id '\r
+                               . 'LEFT JOIN utilisateurs a ON ri.administrateur_id=a.utilisateur_id ');\r
                $this->views->createView('clients_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation '\r
-                        . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0');\r
+                               . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0');\r
                $this->views->createView('utilisateurs_entreprise', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, '\r
-                        . 'e.ws_grade, e.ws_admin, e.ws_signatures AS ws_signatures '\r
-                        . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id');\r
+                               . 'e.ws_grade, e.ws_admin, e.ws_signatures AS ws_signatures '\r
+                               . 'FROM entreprises e LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id');\r
                $this->views->createView('clients', 'SELECT u.*,e.nom AS rs, e.adresse_facturation AS adresse_facturation, i.impaye, '\r
-                        . 'SUM(f.total_ht) AS ca '\r
-                        . 'FROM entreprises e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0 LEFT JOIN projets p ON p.client=u.utilisateur_id LEFT JOIN factures f ON f.projet=p.projet_id AND f.status IN(1,2) '\r
-                        . 'GROUP BY u.utilisateur_id', 'TEMPTABLE');\r
+                               . 'SUM(f.total_ht) AS ca '\r
+                               . 'FROM entreprises e LEFT JOIN impayes_entreprises i ON e.entreprise_id=i.entreprise LEFT JOIN utilisateurs u ON u.entreprise=e.entreprise_id AND u.grade=0 LEFT JOIN projets p ON p.client=u.utilisateur_id LEFT JOIN factures f ON f.projet=p.projet_id AND f.status IN(1,2) '\r
+                               . 'GROUP BY u.utilisateur_id', 'TEMPTABLE');\r
                $this->views->createView('taches_vue', 'SELECT taches.tache_id,taches.nom,taches.categorie,taches.type,taches.budget,taches.projet,taches.taux_journalier, '\r
-                        . '(SUM(timereport.heures)/' . JOURNEE . ') AS jours_consommes, ((SUM(timereport.heures)/' . JOURNEE . ')/(taches.budget/taches.taux_journalier))*100 AS progression,(taches.budget/taches.taux_journalier) AS jours_prevus '\r
-                        . 'FROM taches LEFT JOIN timereport ON taches.tache_id=timereport.tache_id '\r
-                        . 'GROUP BY taches.tache_id');\r
+                               . '(SUM(timereport.heures)/' . JOURNEE . ') AS jours_consommes, ((SUM(timereport.heures)/' . JOURNEE . ')/(taches.budget/taches.taux_journalier))*100 AS progression,(taches.budget/taches.taux_journalier) AS jours_prevus '\r
+                               . 'FROM taches LEFT JOIN timereport ON taches.tache_id=timereport.tache_id '\r
+                               . 'GROUP BY taches.tache_id');\r
                $this->views->createView('taches_projet', 'SELECT projet, '\r
-                        . 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget,'\r
-                        . 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression '\r
-                        . 'FROM taches_vue GROUP BY projet');\r
+                               . 'SUM(jours_prevus) AS jours_prevus,SUM(budget) AS budget,'\r
+                               . 'SUM(jours_consommes) AS jours_consommes, (SUM(jours_consommes)/SUM(jours_prevus))*100 AS progression '\r
+                               . 'FROM taches_vue GROUP BY projet');\r
                $this->views->createView('devis_vue', 'SELECT devis.devis_id,devis.nom,devis.lignes,devis.status,devis.total_ht,devis.date_creation,devis.email,clients.utilisateur_id AS client_id,clients.rs AS client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id,devis.adresse '\r
-                        . 'FROM devis,clients,equipiers '\r
-                        . 'WHERE devis.client=clients.utilisateur_id AND devis.createur=equipiers.utilisateur_id');\r
+                               . 'FROM devis,clients,equipiers '\r
+                               . 'WHERE devis.client=clients.utilisateur_id AND devis.createur=equipiers.utilisateur_id');\r
                $this->views->createView('factures_payees', 'SELECT * FROM factures WHERE status=2');\r
                $this->views->createView('factures_valides', 'SELECT * FROM factures WHERE status IN(1,2)');\r
                $this->views->createView('projets_inter', 'SELECT projets.projet_id,projets.nom,projets.status,projets.date_debut,projets.date_fin,projets.date_creation,projets.deadline,projets.devis,'\r
-                        . 'YEAR(FROM_UNIXTIME(projets.date_debut)) AS annee_debut,'\r
-                        . 'IF(date_fin=0,YEAR(NOW()),YEAR(FROM_UNIXTIME(projets.date_fin))) AS annee_fin,'\r
-                        . 'clients.rs AS client,equipiers.prenom AS chef,equipiers.utilisateur_id AS chef_id,clients.utilisateur_id AS client_id '\r
-                        . 'FROM projets JOIN clients_entreprise clients ON projets.client=clients.utilisateur_id '\r
-                        . 'JOIN equipiers ON projets.chef=equipiers.utilisateur_id');\r
+                               . 'YEAR(FROM_UNIXTIME(projets.date_debut)) AS annee_debut,'\r
+                               . 'IF(date_fin=0,YEAR(NOW()),YEAR(FROM_UNIXTIME(projets.date_fin))) AS annee_fin,'\r
+                               . 'clients.rs AS client,equipiers.prenom AS chef,equipiers.utilisateur_id AS chef_id,clients.utilisateur_id AS client_id '\r
+                               . 'FROM projets JOIN clients_entreprise clients ON projets.client=clients.utilisateur_id '\r
+                               . 'JOIN equipiers ON projets.chef=equipiers.utilisateur_id');\r
                $this->views->createView('projets_facturation', 'SELECT projet,SUM(IF(status IN(1,2),total_ht,0)) AS montant_facture, SUM(IF(status=2,total_ht,0)) AS montant_paye FROM factures GROUP BY projet');\r
                $this->views->createView('projets_vue', 'SELECT p.*,f.montant_facture,f.montant_paye, '\r
-                        . 't.jours_prevus,t.jours_consommes,t.progression,t.budget AS budget, '\r
-                        . 'IF(t.budget>0,f.montant_paye/t.budget,1) AS rapport_paiement, '\r
-                        . 'IF(t.budget>0,f.montant_facture/t.budget,1) AS rapport_facturation '\r
-                        . 'FROM projets_inter p '\r
-                        . 'LEFT JOIN projets_facturation f ON  f.projet=p.projet_id '\r
-                        . 'LEFT JOIN taches_projet t ON p.projet_id=t.projet');\r
+                               . 't.jours_prevus,t.jours_consommes,t.progression,t.budget AS budget, '\r
+                               . 'IF(t.budget>0,f.montant_paye/t.budget,1) AS rapport_paiement, '\r
+                               . 'IF(t.budget>0,f.montant_facture/t.budget,1) AS rapport_facturation '\r
+                               . 'FROM projets_inter p '\r
+                               . 'LEFT JOIN projets_facturation f ON  f.projet=p.projet_id '\r
+                               . 'LEFT JOIN taches_projet t ON p.projet_id=t.projet');\r
                $this->views->createView('factures_vue', 'SELECT factures.facture_id,factures.nom,factures.lignes,factures.status,factures.total_ht,factures.date_creation,factures.texte_complementaire,factures.informations_paiement,factures.date_paiement,factures.adresse,factures.avoir,'\r
-                        . 'projets.projet_id AS projet_id,projets.nom AS projet,clients.utilisateur_id AS client_id,clients.rs as client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id '\r
-                        . 'FROM factures,projets,equipiers,clients '\r
-                        . 'WHERE factures.projet=projets.projet_id AND clients.utilisateur_id=projets.client AND factures.createur=equipiers.utilisateur_id AND (factures.facture_id>=0 OR factures.status=1)  ');\r
+                               . 'projets.projet_id AS projet_id,projets.nom AS projet,clients.utilisateur_id AS client_id,clients.rs as client,equipiers.prenom AS createur,equipiers.utilisateur_id AS createur_id '\r
+                               . 'FROM factures,projets,equipiers,clients '\r
+                               . 'WHERE factures.projet=projets.projet_id AND clients.utilisateur_id=projets.client AND factures.createur=equipiers.utilisateur_id AND (factures.facture_id>=0 OR factures.status=1)  ');\r
                $this->views->createView('projets_timereport', 'SELECT * FROM projets_vue WHERE status=0');\r
                $this->views->createView('order_timereport', 'SELECT utilisateur_id,projet AS projet_id,MAX(date) AS derniere_activite FROM timereport,taches,projets WHERE taches.tache_id=timereport.tache_id AND taches.projet=projets.projet_id AND projets.status=0 GROUP BY utilisateur_id,taches.projet ORDER BY utilisateur_id ASC,MAX(date) DESC');\r
                $this->views->createView('ca', 'SELECT SUM(total_ht) AS ca, YEAR(FROM_UNIXTIME(date_creation)) annee FROM factures WHERE status IN(1,2) GROUP BY annee');\r
                $this->views->createView('ftpaccess', 'SELECT email AS userid,password AS passwd,utilisateur_id AS uid,'\r
-                        . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell '\r
-                        . 'FROM utilisateurs WHERE grade=0 '\r
-                        . 'UNION '\r
-                        . 'SELECT email AS userid,ws_password AS passwd,utilisateur_id AS uid,'\r
-                        . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell '\r
-                        . 'FROM utilisateurs WHERE grade=0 AND ws_password!=\'\'');\r
+                               . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell '\r
+                               . 'FROM utilisateurs WHERE grade=0 '\r
+                               . 'UNION '\r
+                               . 'SELECT email AS userid,ws_password AS passwd,utilisateur_id AS uid,'\r
+                               . '\'1000\' AS gid,CONCAT(\'' . FTPROOT . '\',utilisateur_id) AS homedir, \'/bin/false\' AS shell '\r
+                               . 'FROM utilisateurs WHERE grade=0 AND ws_password!=\'\'');\r
                $this->views->createView('chiffres_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.budget) AS ca '\r
-                        . 'FROM projets_vue p, taches_vue t '\r
-                        . 'WHERE t.projet=p.projet_id '\r
-                        . 'GROUP BY t.categorie,p.annee_fin');\r
+                               . 'FROM projets_vue p, taches_vue t '\r
+                               . 'WHERE t.projet=p.projet_id '\r
+                               . 'GROUP BY t.categorie,p.annee_fin');\r
                $this->views->createView('temps_categories', 'SELECT p.annee_fin AS annee, t.categorie, SUM(t.jours_consommes) AS jours_consommes,SUM(t.jours_prevus) AS jours_prevus '\r
-                        . 'FROM projets_vue p, taches_vue t '\r
-                        . 'WHERE t.projet=p.projet_id '\r
-                        . 'GROUP BY t.categorie,p.annee_fin');\r
+                               . 'FROM projets_vue p, taches_vue t '\r
+                               . 'WHERE t.projet=p.projet_id '\r
+                               . 'GROUP BY t.categorie,p.annee_fin');\r
                $this->views->createView('books_vue', 'SELECT b.*,b.proprietaire AS proprietaire_id,'\r
-                        . 'CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS proprietaire_nom,'\r
-                        . 'CONCAT(c.prenom,\' \',c.nom) AS proprietaire_utilisateur,c.ws_admin,'\r
-                        . 'f.rs AS facturable, t.facturable_id AS facturable_id, ta.projet AS projet,'\r
-                        . 'IF(c.ws_grade>=5,c.utilisateur_id,a.utilisateur_id) AS super_admin '\r
-                        . 'FROM books b '\r
-                        . 'LEFT JOIN utilisateurs_entreprise c ON b.proprietaire=c.utilisateur_id '\r
-                        . 'LEFT JOIN ws_users_tree t ON t.utilisateur_id=c.utilisateur_id '\r
-                        . 'LEFT JOIN utilisateurs a ON t.administrateur_id=a.utilisateur_id '\r
-                        . 'LEFT JOIN utilisateurs_entreprise f ON t.facturable_id=f.utilisateur_id '\r
-                        . 'LEFT JOIN taches ta ON ta.tache_id=b.tache' ,\r
-                       'TEMPTABLE');\r
+                               . 'CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS proprietaire_nom,'\r
+                               . 'CONCAT(c.prenom,\' \',c.nom) AS proprietaire_utilisateur,c.ws_admin,'\r
+                               . 'f.rs AS facturable, t.facturable_id AS facturable_id, ta.projet AS projet,'\r
+                               . 'IF(c.ws_grade>=5,c.utilisateur_id,a.utilisateur_id) AS super_admin '\r
+                               . 'FROM books b '\r
+                               . 'LEFT JOIN utilisateurs_entreprise c ON b.proprietaire=c.utilisateur_id '\r
+                               . 'LEFT JOIN ws_users_tree t ON t.utilisateur_id=c.utilisateur_id '\r
+                               . 'LEFT JOIN utilisateurs a ON t.administrateur_id=a.utilisateur_id '\r
+                               . 'LEFT JOIN utilisateurs_entreprise f ON t.facturable_id=f.utilisateur_id '\r
+                               . 'LEFT JOIN taches ta ON ta.tache_id=b.tache', 'TEMPTABLE');\r
                $this->views->createView('themes_books_nb', 'SELECT theme,COUNT(*) AS nb FROM books GROUP BY theme');\r
                $this->views->createView('themes_vue', 'SELECT t.*, b.nb as nbBooks, CONCAT(e.prenom,\' \',e.nom,\' (\',e.rs,\')\') AS proprietaire_nom '\r
-                        . 'FROM themes t '\r
-                        . 'LEFT JOIN themes_books_nb b ON t.theme_id=b.theme '\r
-                        . 'LEFT JOIN utilisateurs_entreprise e ON t.proprietaire=e.utilisateur_id');\r
+                               . 'FROM themes t '\r
+                               . 'LEFT JOIN themes_books_nb b ON t.theme_id=b.theme '\r
+                               . 'LEFT JOIN utilisateurs_entreprise e ON t.proprietaire=e.utilisateur_id');\r
                $this->views->createView('demandes_vue', 'SELECT d.*, CONCAT(c.rs,\' (\',c.prenom,\' \',c.nom,\')\') AS utilisateur_nom, CONCAT(r.rs,\' (\',r.prenom,\' \',r.nom,\')\') AS revendeur_nom, c.entreprise AS entreprise, a.prenom AS administrateur_nom '\r
-                        . 'FROM demandes d '\r
-                        . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id '\r
-                        . 'LEFT JOIN utilisateurs_entreprise c ON d.utilisateur=c.utilisateur_id '\r
-                        . 'LEFT JOIN utilisateurs a ON d.administrateur=a.utilisateur_id');\r
+                               . 'FROM demandes d '\r
+                               . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id '\r
+                               . 'LEFT JOIN utilisateurs_entreprise c ON d.utilisateur=c.utilisateur_id '\r
+                               . 'LEFT JOIN utilisateurs a ON d.administrateur=a.utilisateur_id');\r
                // cubeDb::mysqlConvert($this->con);\r
                touch($cache);\r
        }\r
 \r
-       public function sauvePreferencesUtilisateur()\r
-       {\r
+       public function sauvePreferencesUtilisateur() {\r
                $dao = new commonDAOUtilisateur($this->con);\r
                $dao->sauvePreferences($this->user);\r
        }\r
 \r
-       public function refreshWSUsersTree()\r
-       {\r
+       public function refreshWSUsersTree() {\r
                $t = new wsUsersTree($this->con);\r
                $t->refreshWSUsersTree();\r
        }\r
 \r
-       public function loadExtranetClasses()\r
-       {\r
+       public function loadExtranetClasses() {\r
                global $__autoload;\r
                require_once(dirname(__FILE__) . '/../extranet/Metier/_common.php');\r
                require_once(dirname(__FILE__) . '/../extranet/Controlleur/_common.php');\r
                require_once(dirname(__FILE__) . '/../extranet/DAO/_common.php');\r
        }\r
 \r
-       public function loadWSClasses()\r
-       {\r
+       public function loadWSClasses() {\r
                global $__autoload;\r
                require_once(dirname(__FILE__) . '/../ws/Metier/_common.php');\r
                require_once(dirname(__FILE__) . '/../ws/Controlleur/_common.php');\r
                require_once(dirname(__FILE__) . '/../ws/DAO/_common.php');\r
        }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file
index 051dfc85aa159d5ef5308289f88bf84f6893eb52..0900f80aef1f00c9caad2c7b4ffcc7b4c1881883 100644 (file)
@@ -25,6 +25,8 @@ class wsDAOBook extends commonDAO {
                $book->pages = array();\r
                $book->chapters = $r->chapters;\r
                $book->traductions = $r->traductions;\r
+               $book->specialLinks = $r->specialLinks;\r
+               $book->specialRulers = $r->specialRulers;\r
                $book->parametres = $r->parametres;\r
                $book->extras = $r->extras;\r
                $book->numerotation = $r->numerotation;\r
@@ -329,6 +331,14 @@ class wsDAOBook extends commonDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
+       public function setSpecialLinksAndRulers($book_id, $links, $rulers) {\r
+               $c = $this->con->openCursor('books');\r
+               $c->specialLinks = json_encode(json_decode($links, false));\r
+               $c->specialRulers = json_encode(json_decode($rulers, false));\r
+               $c->changedate = TIME;\r
+               $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+       }\r
+\r
        public function setTheme($book_id, $theme) {\r
                $c = $this->con->openCursor('books');\r
                $c->theme = $theme;\r
index 2eba9d29b86acfe3492a66ee877cc48b9078d6c0..af39e9976212940df4c7218791d16217ba948c5c 100644 (file)
@@ -1,15 +1,16 @@
 <?php\r
+\r
 class wsDAODocument extends commonDAO {\r
+\r
        public static $normal = array('document_id', 'file', 'proprietaire', 'pages', 'date', 'numberSections', 'version');\r
        public static $complex = array('localInfos', 'bookmarks', 'generalInfos', 'conversionInfos', 'trim');\r
 \r
-       public function singleton($r)\r
-       {\r
+       public function singleton($r) {\r
                $document = new wsDocument();\r
-               foreach(self::$normal as $k) {\r
+               foreach (self::$normal as $k) {\r
                        $document->$k = $r->$k;\r
                }\r
-               foreach(self::$complex as $k) {\r
+               foreach (self::$complex as $k) {\r
                        if ($r->$k != '') {\r
                                $document->$k = unserialize($r->$k);\r
                        }\r
@@ -18,29 +19,26 @@ class wsDAODocument extends commonDAO {
                return $document;\r
        }\r
 \r
-       public function setFluidbookLinksFromCSV($book_id)\r
-       {\r
+       public function setFluidbookLinksFromCSV($book_id) {\r
                $daoBook = new wsDAOBook($this->con);\r
                $pages = $daoBook->getPagesOfBook($book_id);\r
 \r
-               foreach($pages as $page => $infos) {\r
+               foreach ($pages as $page => $infos) {\r
                        $docs[] = $infos['document_id'];\r
                }\r
 \r
                $docs = array_unique($docs);\r
-               foreach($docs as $document_id) {\r
+               foreach ($docs as $document_id) {\r
                        $this->putLinksFromCSV($document_id);\r
                }\r
        }\r
 \r
-       public function restoreLinksVersion($book_id, $update)\r
-       {\r
+       public function restoreLinksVersion($book_id, $update) {\r
                $sql = 'INSERT INTO document_links_versions SELECT document_id,links,rulers,' . TIME . ' FROM document_links_versions WHERE `update`=' . $update . ' AND document_id IN (SELECT document_id FROM book_pages WHERE book_id=' . $book_id . ')';\r
                $this->con->execute($sql);\r
        }\r
 \r
-       public function putLinksFromCSV($document_id)\r
-       {\r
+       public function putLinksFromCSV($document_id) {\r
                $log = array('Copie des liens du PDF vers la base de données');\r
                $document = $this->selectById($document_id);\r
 \r
@@ -51,7 +49,7 @@ class wsDAODocument extends commonDAO {
                $c = $this->con->openCursor('document_links_versions');\r
                $c->document_id = $document->document_id;\r
 \r
-               for($page = 1;$page <= $document->generalInfos['pages'];$page++) {\r
+               for ($page = 1; $page <= $document->generalInfos['pages']; $page++) {\r
                        $links[$page] = array();\r
 \r
                        $csv = WS_DOCS . '/' . $document->document_id . '/p' . $page . '.csv';\r
@@ -78,7 +76,7 @@ class wsDAODocument extends commonDAO {
                                $link = array();\r
                                $cols = array('page' => '', 'type' => '', 'to' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'infobulle' => '', 'numerotation' => 'physical');\r
                                $k = 0;\r
-                               foreach($cols as $col => $default) {\r
+                               foreach ($cols as $col => $default) {\r
                                        if (isset($line[$k])) {\r
                                                if (in_array($k, $booleans)) {\r
                                                        $link[$col] = ($line[$k] == '1');\r
@@ -104,8 +102,7 @@ class wsDAODocument extends commonDAO {
                return implode("\n", $log);\r
        }\r
 \r
-       public function setLinksAndRulers($book_id, $links, $rulers)\r
-       {\r
+       public function setLinksAndRulers($book_id, $links, $rulers) {\r
                $daoBook = new wsDAOBook($this->con);\r
                $pages = $daoBook->getPagesOfBook($book_id);\r
 \r
@@ -114,13 +111,13 @@ class wsDAODocument extends commonDAO {
 \r
                $t = array();\r
 \r
-               foreach($links as $link) {\r
+               foreach ($links as $link) {\r
                        if (!isset($t[$link->page])) {\r
                                $t[$link->page] = array('links' => array(), 'rulers' => array());\r
                        }\r
                        $t[$link->page]['links'][] = $link;\r
                }\r
-               foreach($rulers as $ruler) {\r
+               foreach ($rulers as $ruler) {\r
                        if (!isset($t[$ruler->page])) {\r
                                $t[$ruler->page] = array('links' => array(), 'rulers' => array());\r
                        }\r
@@ -130,7 +127,7 @@ class wsDAODocument extends commonDAO {
                $links = array();\r
                $rulers = array();\r
 \r
-               foreach($t as $page => $tt) {\r
+               foreach ($t as $page => $tt) {\r
                        $infos = $pages[$page];\r
                        $doc_id = $infos['document_id'];\r
                        $doc_page = $infos['document_page'];\r
@@ -144,11 +141,11 @@ class wsDAODocument extends commonDAO {
                                $rulers[$doc_id][$doc_page] = array();\r
                        }\r
 \r
-                       foreach($tt['links'] as $link) {\r
+                       foreach ($tt['links'] as $link) {\r
                                $links[$doc_id][$doc_page][] = $link;\r
                        }\r
 \r
-                       foreach($tt['rulers'] as $ruler) {\r
+                       foreach ($tt['rulers'] as $ruler) {\r
                                $rulers[$doc_id][$doc_page][] = $ruler;\r
                        }\r
                }\r
@@ -156,7 +153,7 @@ class wsDAODocument extends commonDAO {
                $c = $this->con->openCursor('document_links_versions');\r
                $c->update = TIME;\r
 \r
-               foreach($links as $document_id => $dummy) {\r
+               foreach ($links as $document_id => $dummy) {\r
                        $c->document_id = $document_id;\r
                        $c->links = json_encode($links[$document_id]);\r
                        $c->rulers = json_encode($rulers[$document_id]);\r
@@ -168,18 +165,16 @@ class wsDAODocument extends commonDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
-       public function copyLinks($from, $to)\r
-       {\r
+       public function copyLinks($from, $to) {\r
                $sql = 'REPLACE INTO document_links_versions (`document_id`,`links`,`rulers`,`update`) '\r
-                . 'SELECT \'' . $to . '\',`links`,`rulers`,`update` FROM document_links_versions WHERE document_id=\'' . $from . '\'';\r
+                               . 'SELECT \'' . $to . '\',`links`,`rulers`,`update` FROM document_links_versions WHERE document_id=\'' . $from . '\'';\r
 \r
                fb($sql);\r
 \r
                $this->con->execute($sql);\r
        }\r
 \r
-       public function setLinksFromOldFluidbook($book_id)\r
-       {\r
+       public function setLinksFromOldFluidbook($book_id) {\r
                $daoBook = new wsDAOBook($this->con);\r
                $pages = $daoBook->getPagesOfBook($book_id);\r
                $book = $daoBook->selectById($book_id);\r
@@ -190,15 +185,15 @@ class wsDAODocument extends commonDAO {
 \r
                $res = array();\r
                $lpages = array();\r
-               foreach($links as $l) {\r
-                       if ((string)$l->page == '') {\r
+               foreach ($links as $l) {\r
+                       if ((string) $l->page == '') {\r
                                continue;\r
                        }\r
 \r
-                       $left = floatval((string)$l->startX);\r
-                       $right = floatval((string)$l->endX);\r
-                       $top = floatval((string)$l->startY);\r
-                       $bottom = floatval((string)$l->endY);\r
+                       $left = floatval((string) $l->startX);\r
+                       $right = floatval((string) $l->endX);\r
+                       $top = floatval((string) $l->startY);\r
+                       $bottom = floatval((string) $l->endY);\r
 \r
                        $lwidth = abs($right - $left);\r
                        $lheight = abs($bottom - $top);\r
@@ -207,7 +202,7 @@ class wsDAODocument extends commonDAO {
                        $top = min($top, $bottom);\r
 \r
                        $link = array();\r
-                       $link['page'] = (string)$l->page;\r
+                       $link['page'] = (string) $l->page;\r
                        $link['numerotation'] = false;\r
                        $link['left'] = $left;\r
                        $link['width'] = $lwidth;\r
@@ -220,12 +215,12 @@ class wsDAODocument extends commonDAO {
                        $link['height'] = $lheight;\r
                        $link['infobulle'] = '';\r
                        $link['target'] = '_blank';\r
-                       $link['to'] = (string)$l->linkTo;\r
-                       $link['type'] = intval((string)$l->linkType);\r
-                       $link['video_loop'] = ((string)$l->loopFlag == '1');\r
+                       $link['to'] = (string) $l->linkTo;\r
+                       $link['type'] = intval((string) $l->linkType);\r
+                       $link['video_loop'] = ((string) $l->loopFlag == '1');\r
                        $link['video_auto_start'] = true;\r
-                       $link['video_controls'] = ((string)$l->playerActive == '1');\r
-                       $link['video_sound_on'] = ((string)$l->soundOn == '1');\r
+                       $link['video_controls'] = ((string) $l->playerActive == '1');\r
+                       $link['video_sound_on'] = ((string) $l->soundOn == '1');\r
 \r
                        if ($link['type'] == '4' || $link['type'] == '6') {\r
                                if (!stristr($link['to'], ':/')) {\r
@@ -244,7 +239,7 @@ class wsDAODocument extends commonDAO {
                }\r
 \r
                $links = array();\r
-               foreach($pages as $p => $infos) {\r
+               foreach ($pages as $p => $infos) {\r
                        if (!isset($links[$infos['document_id']])) {\r
                                $links[$infos['document_id']] = array();\r
                        }\r
@@ -257,7 +252,7 @@ class wsDAODocument extends commonDAO {
                $c = $this->con->openCursor('document_links_versions');\r
                $c->update = TIME;\r
 \r
-               foreach($links as $document_id => $l) {\r
+               foreach ($links as $document_id => $l) {\r
                        $c->document_id = $infos['document_id'];\r
                        $c->links = json_encode($l);\r
 \r
@@ -270,12 +265,11 @@ class wsDAODocument extends commonDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
-       public function getLinksAndRulers($book_id, &$links, &$rulers)\r
-       {\r
+       public function getLinksAndRulers($book_id, &$links, &$rulers) {\r
                $daoBook = new wsDAOBook($this->con);\r
                $pages = $daoBook->getPagesOfBook($book_id);\r
 \r
-               foreach($pages as $p => $infos) {\r
+               foreach ($pages as $p => $infos) {\r
                        $documents[] = $infos['document_id'];\r
                }\r
                $documents = array_unique($documents);\r
@@ -286,7 +280,7 @@ class wsDAODocument extends commonDAO {
                $links = array();\r
                $rulers = array();\r
 \r
-               foreach($documents as $d) {\r
+               foreach ($documents as $d) {\r
                        $r = $this->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $d . ' ORDER BY `update` DESC LIMIT 1');\r
 \r
                        if (mb_substr($r->links, 1, 1) == ':') {\r
@@ -304,8 +298,8 @@ class wsDAODocument extends commonDAO {
                foreach ($pages as $p => $infos) {\r
                        if (isset($tlinks[$infos['document_id']][$infos['document_page']])) {\r
                                $l = $tlinks[$infos['document_id']][$infos['document_page']];\r
-                               foreach($l as $link) {\r
-                                       $link = (array)$link;\r
+                               foreach ($l as $link) {\r
+                                       $link = (array) $link;\r
                                        $link['page'] = $p;\r
                                        $link['id'] = $i;\r
                                        $links[] = $link;\r
@@ -313,16 +307,21 @@ class wsDAODocument extends commonDAO {
                        }\r
                        if (isset($trulers[$infos['document_id']][$infos['document_page']])) {\r
                                $ru = $trulers[$infos['document_id']][$infos['document_page']];\r
-                               foreach($ru as $ruler) {\r
+                               foreach ($ru as $ruler) {\r
                                        $ruler['page'] = $p;\r
                                        $rulers[] = $ruler;\r
                                }\r
                        }\r
                }\r
+\r
+               $daoBook = new wsDAOBook($this->con);\r
+               $book = $daoBook->selectById($book_id);\r
+\r
+               $rulers = array_merge($rulers, $book->specialRulers);\r
+               $links = array_merge($links, $book->specialLinks);\r
        }\r
 \r
-       public function getLinksVersions($book_id)\r
-       {\r
+       public function getLinksVersions($book_id) {\r
                $res = array();\r
                $r = $this->con->select('SELECT * FROM document_links_versions WHERE document_id IN(SELECT document_id FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\')');\r
                while ($r->fetch()) {\r
@@ -330,19 +329,18 @@ class wsDAODocument extends commonDAO {
                                $res[$r->update] = array('links' => 0, 'rulers' => 0);\r
                        }\r
                        $ll = json_decode($r->links);\r
-                       foreach($ll as $lll) {\r
+                       foreach ($ll as $lll) {\r
                                $res[$r->update]['links'] += count($lll);\r
                        }\r
                        $rr = json_decode($r->rulers);\r
-                       foreach($rr as $rrr) {\r
+                       foreach ($rr as $rrr) {\r
                                $res[$r->update]['rulers'] += count($rrr);\r
                        }\r
                }\r
                return $res;\r
        }\r
 \r
-       public function getNextId()\r
-       {\r
+       public function getNextId() {\r
                $r = $this->con->select('SELECT MAX(document_id) AS document_id FROM documents');\r
                if ($r->document_id < 100000) {\r
                        return 100000;\r
@@ -350,26 +348,22 @@ class wsDAODocument extends commonDAO {
                return $r->document_id + 1;\r
        }\r
 \r
-       public function selectById($document_id)\r
-       {\r
+       public function selectById($document_id) {\r
                $r = $this->con->select('SELECT * FROM documents WHERE document_id=\'' . $this->con->escape($document_id) . '\'');\r
                return $this->singleton($r);\r
        }\r
 \r
-       public function selectByBookId($book_id)\r
-       {\r
+       public function selectByBookId($book_id) {\r
                $r = $this->con->select('SELECT * FROM documents WHERE document_id IN(SELECT document_id FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\')');\r
                return $this->factory($r);\r
        }\r
 \r
-       public function selectInList($documents_id)\r
-       {\r
+       public function selectInList($documents_id) {\r
                $r = $this->con->select('SELECT * FROM documents WHERE document_id IN(' . implode(',', $documents_id) . ')');\r
                return $this->factory($r);\r
        }\r
 \r
-       public function cree()\r
-       {\r
+       public function cree() {\r
                $document = new wsDocument();\r
                $document->document_id = 'new';\r
                $document->file = '';\r
@@ -381,19 +375,18 @@ class wsDAODocument extends commonDAO {
                return $document;\r
        }\r
 \r
-       public function sauve($data)\r
-       {\r
+       public function sauve($data) {\r
                if (!isset($data['document_id'])) {\r
                        $data['document_id'] = 'new';\r
                }\r
                $c = $this->con->openCursor('documents');\r
 \r
-               foreach(self::$normal as $k) {\r
+               foreach (self::$normal as $k) {\r
                        if (isset($data[$k])) {\r
                                $c->$k = $data[$k];\r
                        }\r
                }\r
-               foreach(self::$complex as $k) {\r
+               foreach (self::$complex as $k) {\r
                        if (isset($data[$k])) {\r
                                $c->$k = serialize($data[$k]);\r
                        }\r
@@ -414,24 +407,23 @@ class wsDAODocument extends commonDAO {
                return $doc;\r
        }\r
 \r
-       public function updateField($document_id, $fieldName, $value)\r
-       {\r
+       public function updateField($document_id, $fieldName, $value) {\r
                $c = $this->con->openCursor('documents');\r
                $c->$fieldName = $value;\r
                $c->update('WHERE document_id=\'' . $this->con->escape($document_id) . '\'');\r
        }\r
 \r
-       public function updateFromObject($document)\r
-       {\r
+       public function updateFromObject($document) {\r
                $data = array();\r
-               foreach(self::$normal as $k) {\r
+               foreach (self::$normal as $k) {\r
                        $data[$k] = $document->$k;\r
                }\r
-               foreach(self::$complex as $k) {\r
+               foreach (self::$complex as $k) {\r
                        $data[$k] = $document->$k;\r
                }\r
                return $this->sauve($data);\r
        }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file
index 53427eca5dcf66d01a2d156e7599df0a8b06ab99..fbc30f62710905e47cfaa5dbffac9ca313680a65 100644 (file)
@@ -1,51 +1,44 @@
 <?php\r
+\r
 class wsBook extends cubeMetier {\r
+\r
        protected $book_id;\r
        protected $nom;\r
-\r
        protected $lang;\r
-\r
        protected $theme;\r
-\r
        protected $proprietaire;\r
        protected $proprietaire_id;\r
        protected $proprietaire_utilisateur;\r
-\r
        protected $facturable;\r
        protected $facturable_id;\r
        protected $hash;\r
        protected $compteur_visites;\r
-\r
        protected $tache;\r
        protected $projet;\r
-\r
        protected $status;\r
        protected $date_status;\r
-\r
        protected $date;\r
-\r
        protected $parametres;\r
-\r
        protected $pages;\r
-\r
        protected $chapters;\r
        protected $extras;\r
        protected $traductions;\r
        protected $numerotation;\r
-\r
+       protected $specialLinks;\r
+       protected $specialRulers;\r
        protected $changedate;\r
        protected $compiledate;\r
        protected $syncv1;\r
 \r
-       public function __get($varname)\r
-       {\r
+       public function __get($varname) {\r
                if (!property_exists($this, $varname)) {\r
                        $msg = 'You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists';\r
                        trigger_error($msg, E_USER_ERROR);\r
                        throw new Exception($msg);\r
                }\r
 \r
-               $classic = array('chapters');\r
+               $classic = array('chapters', 'specialLinks','specialRulers', 'traductions');\r
+               $assoc=array('specialLinks','specialRulers');\r
 \r
                if (in_array($varname, $classic)) {\r
                        if (is_array($this->$varname) || is_object($this->$varname)) {\r
@@ -54,18 +47,7 @@ class wsBook extends cubeMetier {
                        if ($this->$varname == '') {\r
                                $this->$varname = array();\r
                        } else {\r
-                               $this->$varname = json_decode($this->$varname, false);\r
-                       }\r
-                       return $this->$varname;\r
-               }\r
-               if ($varname == 'traductions') {\r
-                       if (is_array($this->$varname) || is_object($this->$varname)) {\r
-                               return $this->$varname;\r
-                       }\r
-                       if ($this->$varname == '') {\r
-                               $this->$varname = array();\r
-                       } else {\r
-                               $this->$varname = json_decode($this->$varname, true);\r
+                               $this->$varname = json_decode($this->$varname,in_array($varname,$assoc));\r
                        }\r
                        return $this->$varname;\r
                }\r
@@ -86,6 +68,7 @@ class wsBook extends cubeMetier {
 \r
                return $this->$varname;\r
        }\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file