X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fpltableeditor.php;h=7cfc2e835cb56b67ce9e1f36abfed441f5cae4e7;hb=fa3300aa65242318a4874992da0747bfb3a50c77;hp=588ba9f59e37bccc0bbc66bfa89e7b03b3956895;hpb=c57685e7f4c392c19cf66b61d142be612a3d9a4d;p=platal.git diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index 588ba9f..7cfc2e8 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -1,6 +1,6 @@ sortfield = $idfield; $this->idfield_editable = $editid; $this->whereclause = '1'; - $r = XDB::iterator("SHOW COLUMNS FROM $table"); + $r = XDB::iterator("SHOW FULL COLUMNS FROM $table"); $this->vars = array(); while ($a = $r->next()) { // desc will be the title of the column @@ -97,6 +97,9 @@ class PLTableEditor elseif (substr($a['Type'],0,10) == 'timestamp(' || $a['Type'] == 'datetime') { $a['Type'] = 'timestamp'; } + elseif ($a['Comment'] == 'ip_address') { + $a['Type']='ip_address'; + } $this->vars[$a['Field']] = $a; } @@ -133,6 +136,10 @@ class PLTableEditor $date =& $entry[$field]; $date = preg_replace('/([0-9]{4})-?([0-9]{2})-?([0-9]{2})/', '\3/\2/\1', $date); } + if ($descr['Type'] == 'ip_address') { + $ip = & $entry[$field]; + $ip = long2ip($ip); + } } return $entry; } @@ -197,7 +204,7 @@ class PLTableEditor $page->trig($this->delete_message); } else { $page->trig("L'entrée ".$id." a été supprimée."); - } + } } else { $page->trig("Impossible de supprimer l'entrée."); } @@ -254,6 +261,9 @@ class PLTableEditor elseif ($descr['Type'] == 'date') { $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', $val); } + elseif ($descr['Type'] == 'ip_address') { + $val = ip2long($val); + } $val = "'".addslashes($val)."'"; } else { $cancel = true; @@ -272,7 +282,7 @@ class PLTableEditor $id = XDB::insertId(); } } else - $page->trig("Impossible de mette à jour."); + $page->trig("Impossible de mettre à jour."); if (!$this->auto_return) { return $this->apply($page, 'edit', $id); }