/[openfoncier]/trunk/services/metier/metiermanager.php
ViewVC logotype

Diff of /trunk/services/metier/metiermanager.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 521 by mlimic, Thu Oct 18 10:04:05 2012 UTC revision 522 by mlimic, Thu Oct 18 16:37:15 2012 UTC
# Line 1  Line 1 
1  <?php  <?php
 //$Id: om_utilisateur.class.php 1579 2012-09-03 16:26:31Z rbeylerian $  
 //gen openMairie le 15/10/2010 15:55  
2    
3  require_once "../obj/utils.class.php";  /*
4  require_once "../obj/om_utilisateur.class.php";   * The base class for all of the xxxManagers used for processing the
5     * received requests.
6     *
7     * @author: Mirna Limic <[email protected]>
8     *
9     * Date: 15/10/2012
10     * Follow-up:
11     * Bugs: Unknown
12     *
13     */
14    
15    
16    
17    require_once ("../obj/utils.class.php");
18    require_once ("../obj/om_utilisateur.class.php");
19    
20  class MetierManager {  class MetierManager {
21    
22    
23        /**#@+
24         * @access protected
25         * @var string
26         */
27      var $KO = 'KO';      var $KO = 'KO';
28      var $OK = 'OK';      var $OK = 'OK';
29      var $DEBUG = 0;      var $DEBUG = 0;
30      var $GENERIC_ERROR = "Error during request processing";      var $GENERIC_ERROR = "Error during request processing";
31    
32      // Constructeur.      /*
33      function __construct() {       * Constructeur.
34         *
35         * Sets 'collectivite', and 'login' in the $_SESSION.
36         * @todo The value stored in the $_SESSION['collectivite'] needs to
37         * be obtained rather than hardcoded.
38         * @todo The value stored in the $_SESSION['login'] could be obtained
39         * rather than being hardcoded to "somelogin".
40         * @uses utils Uses the obj/utils.class.php to establish a DB connection.
41         * @uses application::connectDatabase() In this function the execution
42         * could terminate if the connection to DB cannot be established. The
43         * important thing to prevent this is to set the $_SESSION['login'] to
44         * value that is not empty and that is bogus.
45         */
46        public function __construct() {
47          session_start();          session_start();
48          // Setter les variables de $_SESSION pour la connexion avec BD          // Setter les variables de $_SESSION pour la connexion avec BD
49          $_SESSION['collectivite'] = 1; // Arles          $_SESSION['collectivite'] = 1; // Arles
50            // login has to be set to some value, i.e. it must not be empty,
51            // and $_SESSION['justlogin'] MUST NOT be set, otherwise
52            // isAuthenticated() inside of om_application will fail, and the
53            // the script will stop executing
54          $_SESSION['login'] = "somelogin";          $_SESSION['login'] = "somelogin";
55          // Genere une connexion a la base de donnees          // Genere une connexion a la base de donnees
56          $this->f = new utils("nohtml");          $this->f = new utils("nohtml");
57            // set the type of the DB to use
58          $this->f->db->phptype = 'pgsql';          $this->f->db->phptype = 'pgsql';
59            // save the reference to DB
60          $this->db = $this->f->db;                  $this->db = $this->f->db;        
61      }// fin constructeur      }// fin constructeur
62    
63      function __destruct() {      
64        /*
65         * Destructor
66         *
67         * Unsets the instance of the utils class.
68         * Unsets in the $_SESSION the key=>value pairs that were set in
69         * the constructor.
70         */
71        public function __destruct() {
72          unset($this->f);          unset($this->f);
73          unset($_SESSION['login']);          unset($_SESSION['login']);
74          unset($_SESSION['collectivite']);          unset($_SESSION['collectivite']);
75      }      }
76            
77      function requestValid() {      
78        /*
79         * Checks that the data received in the request is valid.
80         *
81         * To be overridden in the derived classes.
82         * @return bool Always return true.
83         */
84        protected function requestValid() {
85          // A etre implemente dans les classes derivees          // A etre implemente dans les classes derivees
86          return true;          return true;
87      }      }
88            
89      function filterOutHtmlTags($var) {      
90        /*
91         * Filters out the HTML tags from a string.
92         *
93         * @param string $var The string from which to filter out the HTML tags.
94         * @return string Returns $var without the HTML tags.
95         */
96        private function filterOutHtmlTags($var) {
97          $pattern = '/<[\/]*[\sa-zA-Z0-9="]*[\/]*>/';          $pattern = '/<[\/]*[\sa-zA-Z0-9="]*[\/]*>/';
98          $replacement = '';          $replacement = '';
99          return preg_replace($pattern, $replacement, $var);          return preg_replace($pattern, $replacement, $var);
100      }      }
101    
102      function ajouter(&$data) {      
103        /*
104         * Executes the insertion of a record into DB by calling the
105         * dbform::ajouter() method.
106         *
107         * Precondition: $this->metier_instance is not null.
108         *
109         * @uses dbform::ajouter() The method that does insertion of data
110         * into a DB
111         * @return string Returns 'OK' on success, error message set by the
112         * application (if it was set), a generic error message otherwise.
113         */
114        protected function ajouter(&$data) {
115          // essai d'ajout des donnees dans la base de donnees          // essai d'ajout des donnees dans la base de donnees
116          $this->metier_instance->ajouter($data, $this->db, $this->DEBUG);          $this->metier_instance->ajouter($data, $this->db, $this->DEBUG);
117          if ($this->metier_instance->correct == false) {          if ($this->metier_instance->correct == false) {
# Line 54  class MetierManager { Line 124  class MetierManager {
124          return $this->OK;          return $this->OK;
125      }      }
126    
127      function modifier(&$data) {  
128        /*
129         * Executes the update of a record in DB by calling the
130         * dbform::modifier() method.
131         *
132         * Precondition: $this->metier_instance is not null.
133         *
134         * @uses dbform::modifier() The method that does insertion of data
135         * into a DB
136         * @return string Returns 'OK' on success, error message set by the
137         * application (if it was set), a generic error message otherwise.
138         */    
139        protected function modifier(&$data) {
140          // essai de la modification des donnees dans la base de donnees          // essai de la modification des donnees dans la base de donnees
141          $ret = $this->metier_instance->modifier($data, $this->db, $this->DEBUG);          $ret = $this->metier_instance->modifier($data, $this->db, $this->DEBUG);
142          if ($this->metier_instance->correct == false) {          if ($this->metier_instance->correct == false) {
# Line 68  class MetierManager { Line 150  class MetierManager {
150      }      }
151    
152    
153      function supprimer(&$data) {      /*
154         * Executes the insertion of a record into DB by calling the
155         * dbform::supprimer() method.
156         *
157         * Precondition: $this->metier_instance is not null.
158         *
159         * @uses dbform::supprimer() The method that does insertion of data
160         * into a DB
161         * @return string Returns 'OK' on success, error message set by the
162         * application (if it was set), a generic error message otherwise.
163         */
164        protected function supprimer(&$data) {
165          // essai de la suppression des donnes dans la base de donnees          // essai de la suppression des donnes dans la base de donnees
166          $ret = $this->metier_instance->supprimer($data, $this->db, $this->DEBUG);          $ret = $this->metier_instance->supprimer($data, $this->db, $this->DEBUG);
167          if ($this->metier_instance->correct == false) {          if ($this->metier_instance->correct == false) {
# Line 82  class MetierManager { Line 175  class MetierManager {
175      }      }
176    
177      /*      /*
178       * Fonction overwritten par les classes derivees en cas d'une demande GET.       * This function is to be overwritten by the derived classes when a GET
179         * request is received.
180         *
181         * @return bool Always returns 'KO' to indicate that by default,
182         * extraction of data from the DB is not supported.
183       */       */
184      function extraire(&$data) {      protected function extraire(&$data) {
185          //          //
186          return $this->KO;          return $this->KO;
187      }      }
188    
189            
     /*  
      * Utilise pour le retour des donnes. Doit retourner un tableau.  
      */  
     //function getDataInArray() {  
     //    return array();  
     //}  
       
190  }// fin classe  }// fin classe
191  ?>  ?>

Legend:
Removed from v.521  
changed lines
  Added in v.522

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26