/[openfoncier]/branches/cleanup-old-openfoncier/obj/utils.class.php
ViewVC logotype

Diff of /branches/cleanup-old-openfoncier/obj/utils.class.php

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

trunk/obj/utils.class.php revision 3976 by softime, Thu Apr 14 16:50:06 2016 UTC branches/cleanup-old-openfoncier/obj/utils.class.php revision 4675 by fmichon, Thu Jun 30 11:04:21 2016 UTC
# Line 37  require_once PATH_OPENMAIRIE."om_applica Line 37  require_once PATH_OPENMAIRIE."om_applica
37   */   */
38  class utils extends application {  class utils extends application {
39    
     // {{{  
       
40      /**      /**
41       *       * Gestion du favicon de l'application.
42         *
43         * @var mixed Configuration niveau application.
44       */       */
45      function isAccredited($obj = NULL, $operator = "AND") {      var $html_head_favicon = '../app/img/favicon.ico';
46          // Lorsque l'utilisateur a le login 'admin' alors il est authorisé à  
47          // accéder à toutes les fonctions du logiciel      // {{{
         // XXX à modifier pour changer ça vers un profil et non un login utilisateur  
         if ($_SESSION["login"] == "admin") {  
             return true;  
         }  
         // Fonctionnement standard  
         return parent::isAccredited($obj, $operator);  
     }  
48    
49      /**      /**
50       * SURCHARGE DE LA CLASSE OM_APPLICATION.       * SURCHARGE DE LA CLASSE OM_APPLICATION.
# Line 89  class utils extends application { Line 82  class utils extends application {
82          $idx_multi = $this->get_idx_collectivite_multi();          $idx_multi = $this->get_idx_collectivite_multi();
83    
84          if (isset($conf[$sig_externe][$collectivite_parameters['om_collectivite_idx']]) and          if (isset($conf[$sig_externe][$collectivite_parameters['om_collectivite_idx']]) and
85                isset($conf[$sig_externe]["sig_treatment_mod"]) and
86              isset($collectivite_parameters["option_sig"]) and              isset($collectivite_parameters["option_sig"]) and
87              $collectivite_parameters["option_sig"] == "sig_externe"              $collectivite_parameters["option_sig"] == "sig_externe"
88              ) {              ) {
89    
90              // Cas numéro 1 : conf sig définie sur la collectivité et option sig active              // Cas numéro 1 : conf sig définie sur la collectivité et option sig active
91              $collectivite_parameters["sig"] = $conf[$sig_externe][$collectivite_parameters['om_collectivite_idx']];              $collectivite_parameters["sig"] = $conf[$sig_externe][$collectivite_parameters['om_collectivite_idx']];
92                $collectivite_parameters["sig"]["sig_treatment_mod"] = $conf[$sig_externe]["sig_treatment_mod"];
93    
94          } elseif($idx_multi != '' and          } elseif($idx_multi != '' and
95                  isset($conf[$sig_externe][$idx_multi]) and                  isset($conf[$sig_externe][$idx_multi]) and
96                    isset($conf[$sig_externe]["sig_treatment_mod"]) and
97                  isset($collectivite_parameters["option_sig"]) and                  isset($collectivite_parameters["option_sig"]) and
98                  $collectivite_parameters["option_sig"] == "sig_externe") {                  $collectivite_parameters["option_sig"] == "sig_externe") {
99              // Cas numéro  : conf sig définie sur la collectivité multi et              // Cas numéro  : conf sig définie sur la collectivité multi et
100              // option_sig activé pour la collectivité mono              // option_sig activé pour la collectivité mono
101              $collectivite_parameters["sig"] = $conf[$sig_externe][$idx_multi];              $collectivite_parameters["sig"] = $conf[$sig_externe][$idx_multi];
102                $collectivite_parameters["sig"]["sig_treatment_mod"] = $conf[$sig_externe]["sig_treatment_mod"];
103          }          }
104    
105          //// END - SURCHARGE OPENADS          //// END - SURCHARGE OPENADS
# Line 464  class utils extends application { Line 461  class utils extends application {
461       * @return boolean true si il peut       * @return boolean true si il peut
462       */       */
463      function isInstrCanChangeDecision($idx) {      function isInstrCanChangeDecision($idx) {
464          if($this->isAccredited("instruction_changer_decision") === false) {          if($this->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === false) {
465              return false;              return false;
466          }          }
467    
# Line 1473  class utils extends application { Line 1470  class utils extends application {
1470          return true;          return true;
1471      }      }
1472    
1473        /**
1474         * Vérifie que l'option du SIG est activée.
1475         *
1476         * @return boolean
1477         */
1478        public function is_option_sig_enabled() {
1479            //
1480            $option = $this->getParameter("option_sig");
1481            //
1482            if ($option !== 'sig_externe' && $option !== 'sig_interne') {
1483                //
1484                return false;
1485            }
1486    
1487            //
1488            return true;
1489        }
1490    
1491        /**
1492         * Vérifie le niveau de la collectivité de l'utilisateur connecté
1493         *
1494         * @return boolean
1495         */
1496        function has_collectivite_multi() {
1497            $idx_multi = $this->get_idx_collectivite_multi();
1498            if (intval($_SESSION['collectivite']) === intval($idx_multi)) {
1499                return true;
1500            }
1501            return false;
1502        }
1503    
1504    
1505      /**      /**
1506       * Pour un path absolu donné, retourne le relatif à la racine de       * Pour un path absolu donné, retourne le relatif à la racine de
# Line 1506  class utils extends application { Line 1534  class utils extends application {
1534          return $match[1];          return $match[1];
1535      }      }
1536    
1537        /**
1538         * Compose un tableau et retourne son code HTML
1539         *
1540         * @param   string  $id       ID CSS du conteneur
1541         * @param   array   $headers  entêtes de colonnes
1542         * @param   array   $rows     lignes
1543         * @return  string            code HTML
1544         */
1545        public function compose_generate_table($id, $headers, $rows) {
1546            //
1547            $html = '';
1548            // Début conteneur
1549            $html .= '<div id="'.$id.'">';
1550            // Début tableau
1551            $html .= '<table class="tab-tab">';
1552            // Début entête
1553            $html .= '<thead>';
1554            $html .= '<tr class="ui-tabs-nav ui-accordion ui-state-default tab-title">';
1555            // Colonnes
1556            $nb_colonnes = count($headers);
1557            $index_last_col = $nb_colonnes - 1;
1558            foreach ($headers as $i => $header) {
1559                if ($i === 0) {
1560                    $col = ' firstcol';
1561                }
1562                if ($i === $index_last_col) {
1563                    $col = ' lastcol';
1564                }
1565                $html .= '<th class="title col-'.$i.$col.'">';
1566                    $html .= '<span class="name">';
1567                        $html .= $header;
1568                    $html .= '</span>';
1569                $html .= '</th>';
1570            }
1571            // Fin entête
1572            $html .= '</tr>';
1573            $html .= '</thead>';
1574            // Début corps
1575            $html .= '<tbody>';
1576            // Lignes
1577            foreach ($rows as $cells) {
1578                // Début ligne
1579                $html .= '<tr class="tab-data">';
1580                // Cellules
1581                foreach ($cells as $j => $cell) {
1582                    if ($j === 0) {
1583                    $col = ' firstcol';
1584                    }
1585                    if ($j === $index_last_col) {
1586                        $col = ' lastcol';
1587                    }
1588                    $html .= '<td class="title col-'.$j.$col.'">';
1589                        $html .= '<span class="name">';
1590                            $html .= $cell;
1591                        $html .= '</span>';
1592                    $html .= '</td>';
1593                }
1594                // Fin ligne
1595                $html .= "</tr>";
1596            }
1597            // Fin corps
1598            $html .= '</tbody>';
1599            // Fin tableau
1600            $html .= '</table>';
1601            // Fin conteneur
1602            $html .= '</div>';
1603            //
1604            return $html;
1605        }
1606    
1607        /**
1608         * Retourne le login de l'utilisateur connecté + entre parenthèses son nom
1609         * s'il en a un.
1610         *
1611         * @return  string  myLogin OU myLogin (myName)
1612         */
1613        public function get_connected_user_login_name() {
1614            // Requête et stockage des informations de l'user connecté
1615            $this->getUserInfos();
1616            // Si le nom existe et est défini on le récupère
1617            $nom = "";
1618            if (isset($this->om_utilisateur["nom"])
1619                && !empty($this->om_utilisateur["nom"])) {
1620                $nom = trim($this->om_utilisateur["nom"]);
1621            }
1622            // Définition de l'émetteur : obligatoirement son login
1623            $emetteur = $_SESSION['login'];
1624            // Définition de l'émetteur : + éventuellement son nom
1625            if ($nom != "") {
1626                $emetteur .= " (".$nom.")";
1627            }
1628            // Retour
1629            return $emetteur;
1630        }
1631    
1632        /**
1633         * Récupère la liste des identifiants des collectivités
1634         *
1635         * @param  string $return_type 'string' ou 'array' selon que l'on retourne
1636         *                             respectivement une chaîne ou un tableau
1637         * @param  string $separator   caractère(s) séparateur(s) employé(s) lorsque
1638         *                             l'on retourne une chaîne, inutilisé si tableau
1639         * @return mixed               possibilité de boolean/string/array :
1640         *                             false si erreur BDD sinon résultat
1641         */
1642        public function get_list_id_collectivites($return_type = 'string', $separator = ',') {
1643            $sql = "
1644            SELECT
1645            array_to_string(
1646                array_agg(om_collectivite),
1647                '".$separator."'
1648            ) as list_id_collectivites
1649            FROM ".DB_PREFIXE."om_collectivite";
1650            $list = $this->db->getone($sql);
1651            $this->addTolog(
1652                __FILE__." - ".__METHOD__." : db->getone(\"".$sql."\");",
1653                VERBOSE_MODE
1654            );
1655            if ($this->isDatabaseError($list, true)) {
1656                return false;
1657            }
1658            if ($return_type === 'array') {
1659                return explode($separator, $list);
1660            }
1661            return $list;
1662        }
1663  }  }
1664    
1665  ?>  ?>

Legend:
Removed from v.3976  
changed lines
  Added in v.4675

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26