Hello.

The following patch allows to configure glpi for an utf8-encoded ocs
database, for people using related patches, while still defaulting to
latin1 for compatibility with standard latin1-encode database.
-- 
BOFH excuse #324:

Your packets were eaten by the terminator
diff -Naur -x '*~' -x files glpi/inc/dbmysql.class.php 
glpi-allow-ocs-database-encoding-configuration//inc/dbmysql.class.php
--- glpi/inc/dbmysql.class.php  2010-07-07 14:44:34.000000000 +0200
+++ glpi-allow-ocs-database-encoding-configuration//inc/dbmysql.class.php       
2010-08-27 21:53:09.794385185 +0200
@@ -52,7 +52,7 @@
          $this->dbuser = $data["ocs_db_user"];
          $this->dbpassword = rawurldecode($data["ocs_db_passwd"]);
          $this->dbdefault = $data["ocs_db_name"];
-         $this->dbenc="latin1";
+         $this->dbenc = $data["ocs_db_utf8"] ? "utf8" : "latin1";
          parent::__construct();
       }
    }
@@ -609,4 +609,4 @@
       return ($this->res ? $this->conn->numrows($this->res) : 0);
    }
 }
-?>
\ Pas de fin de ligne à la fin du fichier.
+?>
diff -Naur -x '*~' -x files glpi/inc/ocsserver.class.php 
glpi-allow-ocs-database-encoding-configuration//inc/ocsserver.class.php
--- glpi/inc/ocsserver.class.php        2010-07-07 14:44:34.000000000 +0200
+++ glpi-allow-ocs-database-encoding-configuration//inc/ocsserver.class.php     
2010-08-27 22:46:28.609725694 +0200
@@ -458,7 +458,7 @@
          return false;
       }
 
-      $rowspan=5;
+      $rowspan=6;
       //If no ID provided, or if the server is created using an existing 
template
       if (empty ($ID)) {
          $this->getEmpty();
@@ -493,6 +493,7 @@
                     $this->fields["ocs_db_user"] . "\"></td></tr>\n";
       $out .= "<tr class='tab_bg_1'><td class='center'>" . 
$LANG['ocsconfig'][3] . "&nbsp;: </td>\n";
       $out .= "<td><input type='password' name='ocs_db_passwd' value='' 
autocomplete='off'></td>";
+
       if (!empty ($ID)) {
          $out .= "<td>".$LANG['common'][26]."&nbsp;: </td>";
          $out .= "<td>";
@@ -501,6 +502,15 @@
 
       }
       $out .= "</tr>\n";
+      $out .= "<tr class='tab_bg_1'><td class='center'>" . 
$LANG['ocsconfig'][7] . "&nbsp;: </td>\n";
+      $out .= "<td><select name='ocs_db_utf8'>".
+             "<option value='0'" .
+             ($this->fields["ocs_db_utf8"] ? "" : "selected") .
+             ">" . $LANG['choice'][0] . "</option>".
+             "<option value='1'" .
+             ($this->fields["ocs_db_utf8"] ? "selected" : "") .
+             ">" . $LANG['choice'][1] . "</option>".
+             "</select></td></tr>\n";
       echo $out;
       $this->showFormButtons($options);
       $this->addDivForTabs();
@@ -1679,7 +1689,7 @@
             if (!in_array("operatingsystems_id", $computer_updates)) {
                $osname=$line["OSNAME"];
                // Hack for OCS encoding problems
-               if (!seems_utf8($osname)) {
+               if (!$cfg_ocs["ocs_db_utf8"] && !seems_utf8($osname)) {
                   $osname=encodeInUtf8($osname);
                }
                $compupdate["operatingsystems_id"] = 
Dropdown::importExternal('OperatingSystem',
@@ -3902,12 +3912,12 @@
                $data2 = 
clean_cross_side_scripting_deep(addslashes_deep($data2));
                $initname = $data2["INITNAME"];
                // Hack for OCS encoding problems
-               if (!seems_utf8($initname)) {
+               if (!$cfg_ocs["ocs_db_utf8"] && !seems_utf8($osname)) {
                   $initname=encodeInUtf8($initname);
                }
                $name = $data2["NAME"];
                // Hack for OCS encoding problems
-               if (!seems_utf8($name)) {
+               if (!$cfg_ocs["ocs_db_utf8"] && !seems_utf8($osname)) {
                   $name=encodeInUtf8($name);
                }
                $version = $data2["VERSION"];
diff -Naur -x '*~' -x files glpi/install/mysql/glpi-0.78-empty.sql 
glpi-allow-ocs-database-encoding-configuration//install/mysql/glpi-0.78-empty.sql
--- glpi/install/mysql/glpi-0.78-empty.sql      2010-07-07 14:44:34.000000000 
+0200
+++ 
glpi-allow-ocs-database-encoding-configuration//install/mysql/glpi-0.78-empty.sql
   2010-08-27 21:36:14.519385821 +0200
@@ -2545,6 +2545,7 @@
   `ocs_db_passwd` varchar(255) collate utf8_unicode_ci default NULL,
   `ocs_db_host` varchar(255) collate utf8_unicode_ci default NULL,
   `ocs_db_name` varchar(255) collate utf8_unicode_ci default NULL,
+  `ocs_db_utf8` tinyint(1) NOT NULL default '0',
   `checksum` int(11) NOT NULL default '0',
   `import_periph` tinyint(1) NOT NULL default '0',
   `import_monitor` tinyint(1) NOT NULL default '0',
diff -Naur -x '*~' -x files glpi/locales/en_GB.php 
glpi-allow-ocs-database-encoding-configuration//locales/en_GB.php
--- glpi/locales/en_GB.php      2010-07-07 14:44:34.000000000 +0200
+++ glpi-allow-ocs-database-encoding-configuration//locales/en_GB.php   
2010-08-27 21:45:07.022616092 +0200
@@ -1126,6 +1126,7 @@
 $LANG['ocsconfig'][4]="Name of the OCSNG database"; 
 $LANG['ocsconfig'][5]="Import Options"; 
 $LANG['ocsconfig'][6]="Ignore in OCSNG import"; 
+$LANG['ocsconfig'][7]="UTF8 OCSNG database"; 
 $LANG['ocsconfig'][9]="Exclude the following tags (separator $, nothing for 
all)"; 
 $LANG['ocsconfig'][10]="Global import"; 
 $LANG['ocsconfig'][11]="No import"; 
@@ -1935,4 +1936,4 @@
 $LANG['validation'][31]="Update the validation request to"; 
 $LANG['validation'][32]="An answer to a validation request was performed"; 
 $LANG['validation'][33]="Tickets are awaiting your approval"; 
-?>
\ Pas de fin de ligne à la fin du fichier.
+?>
diff -Naur -x '*~' -x files glpi/locales/fr_FR.php 
glpi-allow-ocs-database-encoding-configuration//locales/fr_FR.php
--- glpi/locales/fr_FR.php      2010-07-07 14:44:34.000000000 +0200
+++ glpi-allow-ocs-database-encoding-configuration//locales/fr_FR.php   
2010-08-27 21:51:41.307343971 +0200
@@ -1282,6 +1282,7 @@
 $LANG['ocsconfig'][4]="Nom de la base de données OCSNG";
 $LANG['ocsconfig'][5]="Options d'importation";
 $LANG['ocsconfig'][6]="Ignorer lors de l'import OCSNG";
+$LANG['ocsconfig'][7]="Base de données OCSNG en UTF8";
 $LANG['ocsconfig'][9]="Exclure les tags suivants (séparateur $, rien pour 
aucun)";
 $LANG['ocsconfig'][10]="Import global";
 $LANG['ocsconfig'][11]="Pas d'import";

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev

Reply via email to