[ghelda-devel] [6] Add addresses management.

[ Thread Index | Date Index | More lists.tuxfamily.org/ghelda-devel Archives ]


Revision: 6
Author:   odyx
Date:     2008-11-26 19:16:22 +0100 (Wed, 26 Nov 2008)

Log Message:
-----------
Add addresses management.
Various cleaning and function rearrangement (to avoid too much code duplication).

Modified Paths:
--------------
    trunk/inc/Plugins_Handler.php
    trunk/inc/g_functions.php
    trunk/inc/outputs/xHTML.class.php
    trunk/locale/fr.UTF-8/LC_MESSAGES/People.po
    trunk/locale/fr.UTF-8/LC_MESSAGES/g_core.po
    trunk/locale/templates/People.pot
    trunk/locale/templates/g_core.pot
    trunk/plugins/People/config_core.php
    trunk/plugins/People.php
    trunk/style/main.css

Added Paths:
-----------
    trunk/locale/fr.UTF-8/LC_MESSAGES/Address.po
    trunk/plugins/Address/
    trunk/plugins/Address/config_core.php
    trunk/plugins/Address.php


Modified: trunk/inc/Plugins_Handler.php
===================================================================
--- trunk/inc/Plugins_Handler.php	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/inc/Plugins_Handler.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -96,6 +96,8 @@
 			// Create each instance
 			$this->pluginsList[$pluginName] =& new $pluginName(&$this,$pluginName);
 			
+			unset($confLoc);
+			unset($conf);
 			// Get its eventual configuration
 			// Include the standard configuration
 			$coreDomain = g_setDomain($pluginName);		// This ensures translation

Modified: trunk/inc/g_functions.php
===================================================================
--- trunk/inc/g_functions.php	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/inc/g_functions.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -33,4 +33,33 @@
 define('G_DB_PEOPLE_LOCALE','locale');
 define('G_DB_PEOPLE_ID','people_id');
 
+function g_getFormattedField($ArrayVals,$type,$fieldName,$fieldsSpec) {
+	// For dates
+	if(stripos($type,'date') !== false) {
+		// It's a date
+		if(empty($ArrayVals[$fieldName.'_year']) || empty($ArrayVals[$fieldName.'_month']) || empty($ArrayVals[$fieldName.'_day'])) {
+			return '0000-00-00';
+		} elseif(checkdate((int)$ArrayVals[$fieldName.'_month'],(int)$ArrayVals[$fieldName.'_day'],(int)$ArrayVals[$fieldName.'_year'])) {
+			return $ArrayVals[$fieldName.'_year'].'-'.$ArrayVals[$fieldName.'_month'].'-'.$ArrayVals[$fieldName.'_day'];
+		}
+	} elseif(array_key_exists('ereg',$fieldsSpec[$fieldName])) { // for fields which have a verification pattern
+		if(ereg($fieldsSpec[$fieldName]['ereg'],$ArrayVals[$fieldName]) || empty($ArrayVals[$fieldName])) {
+			return $ArrayVals[$fieldName];
+		}
+		return false;
+	} elseif(array_key_exists('preg',$fieldsSpec[$fieldName])) { // for fields which have a verification pattern
+		if(preg_match($fieldsSpec[$fieldName]['preg'],$ArrayVals[$fieldName])|| empty($ArrayVals[$fieldName])) {
+			return $ArrayVals[$fieldName];
+		} 
+	} else {
+		return $ArrayVals[$fieldName];
+	}
+	return false;
+}
+
+// log == inv(gol)
+function gol($text,$var) {
+	trigger_error($text.var_export($var,true),G_E_LOG);
+}
+
 ?>
\ No newline at end of file

Modified: trunk/inc/outputs/xHTML.class.php
===================================================================
--- trunk/inc/outputs/xHTML.class.php	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/inc/outputs/xHTML.class.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -247,6 +247,8 @@
 			if($fieldProperties['restricted'] == 'key') {	/* == 'id' */
 				$formKey = array('name' => $fieldName);
 				continue;
+			} elseif ($fieldProperties['noShow']) {
+				continue;
 			}
 			$line .= $this->tag('th',$fieldProperties['name']);
 		}
@@ -266,6 +268,9 @@
 			}
 			$this->url->removeQueryString('mode');
 			foreach($row as $fieldName => $fieldContent) {
+					if ($fieldsSpec[$fieldName]['noShow']) {
+						continue;
+					}
 					if(stripos($fieldsSpec[$fieldName]['type'],'date') !== false) { // If we have a date
 						$fieldContent = $this->formatDate($fieldContent);
 					}
@@ -393,13 +398,6 @@
 
 				$field = $this->textarea($value,$paramsArray);
 
-				// Add the "_old" hidden stag
-				$paramsArray['type'] = 'hidden';
-				$paramsArray['name'] = $fieldName.'_old';
-				$paramsArray['id'] = $fieldName.'_old';
-				$paramsArray['value'] = $value;
-				$field .= LB.$this->stag('input',$paramsArray);
-
 				// Stack the fields
 				$fields .= $this->mark('p',$label.LB.$field);
 
@@ -445,7 +443,9 @@
 	public function displayMenu($targets)
 	{	// Store the old querystring
 		$oldQS = $this->url->querystring;
+		// Use a pristine querystring
 		$this->url->querystring = '';
+		// Go along all the plugins
 		foreach($targets as $plugin => $pluginMenu) {
 			$this->url->addQueryString('plugin',$plugin);
 			if(array_key_exists('Tname',$pluginMenu)) {
@@ -455,13 +455,15 @@
 				$submenu = $this->$plugin.LB;
 			}
 			$submenu = $this->tag('a',$submenu,array('href'=> $this->url->getURL()));
+			// Reset the (subsub-)menu for each plugin
+			$subsubmenu = '';
 			foreach($pluginMenu as $target => $targetSpec) {
 				$this->url->addQueryString('mode',$target);
 				$link = $this->tag('a',$targetSpec['name'],array('href'=> $this->url->getURL()));
-				$menu .= $this->tag('li',$link,array(),true);
+				$subsubmenu .= $this->tag('li',$link,array(),true);
 			}
 			$this->url->removeQueryString('mode');
-			$submenu .= $this->mark('ul',$menu);
+			$submenu .= $this->mark('ul',$subsubmenu);
 			$modules .= $this->tag('li',$submenu);
 		}
 		// ReStore the old QS

Added: trunk/locale/fr.UTF-8/LC_MESSAGES/Address.po
===================================================================
--- trunk/locale/fr.UTF-8/LC_MESSAGES/Address.po	                        (rev 0)
+++ trunk/locale/fr.UTF-8/LC_MESSAGES/Address.po	2008-11-26 18:16:22 UTC (rev 6)
@@ -0,0 +1,114 @@
+#
+#  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
+#         - Online Hierarchical Handling Of Adresses
+#
+#  Copyright (C) 2008  Didier Raboud
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: People\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-11-26 19:13+0100\n"
+"PO-Revision-Date: 2008-09-24 22:02+0200\n"
+"Last-Translator: Didier Raboud <didier@xxxxxxxxxx>\n"
+"Language-Team:  <fr@xxxxxx>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n>1;\n"
+
+#: plugins/Address/config_core.php:23
+msgid "Identifier"
+msgstr "Identifiant"
+
+#: plugins/Address/config_core.php:30
+msgid "Address"
+msgstr "Adresse"
+
+#: plugins/Address/config_core.php:34
+msgid "Postal Box"
+msgstr "Bote Postale"
+
+#: plugins/Address/config_core.php:38
+msgid "City"
+msgstr "Ville"
+
+#: plugins/Address/config_core.php:42
+msgid "Region"
+msgstr "Région (Canton)"
+
+#: plugins/Address/config_core.php:46
+msgid "Zip Code"
+msgstr "NPA"
+
+#: plugins/Address/config_core.php:50
+msgid "Country"
+msgstr "Pays"
+
+#: plugins/Address/config_core.php:54
+msgid "Phone number"
+msgstr "Numéro de téléphone"
+
+#: plugins/Address/config_core.php:58
+msgid "Fax number"
+msgstr "Numéro de fax"
+
+#: plugins/Address.php:57
+msgid "Addresses"
+msgstr "Adresses"
+
+#: plugins/Address.php:58
+msgid "New"
+msgstr "Nouvelle adresse"
+
+#: plugins/Address.php:59
+msgid "List"
+msgstr "Liste"
+
+#: plugins/Address.php:72
+msgid "Intrusion tentative detected: "
+msgstr "Tentative d'intrusion détectée: "
+
+#: plugins/Address.php:72
+msgid "Don't try to use undefined mode names!"
+msgstr "N'essayez pas d'utiliser des noms de mode indéfinis !"
+
+#: plugins/Address.php:129
+msgid "Edit"
+msgstr "Éditer"
+
+#: plugins/Address.php:131
+msgid "Delete"
+msgstr "Détruire"
+
+#: plugins/Address.php:219
+msgid "New address"
+msgstr "Nouvelle adresse"
+
+#: plugins/Address.php:228
+msgid "Execute"
+msgstr "Exécuter"
+
+#: plugins/Address.php:264
+msgid "Confirm deletion"
+msgstr "Confirmer l'effacement"
+
+#: plugins/Address.php:264
+msgid "Do you really want to delete the following entry?"
+msgstr "Voulez-vous vraiment effacer l'adresse suivante ?"
+
+#~ msgid "New entry"
+#~ msgstr "Nouvelle adresse"

Modified: trunk/locale/fr.UTF-8/LC_MESSAGES/People.po
===================================================================
--- trunk/locale/fr.UTF-8/LC_MESSAGES/People.po	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/locale/fr.UTF-8/LC_MESSAGES/People.po	2008-11-26 18:16:22 UTC (rev 6)
@@ -21,7 +21,7 @@
 msgstr ""
 "Project-Id-Version: People\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-26 09:43+0100\n"
+"POT-Creation-Date: 2008-11-26 19:13+0100\n"
 "PO-Revision-Date: 2008-09-24 22:02+0200\n"
 "Last-Translator: Didier Raboud <didier@xxxxxxxxxx>\n"
 "Language-Team:  <fr@xxxxxx>\n"
@@ -35,55 +35,55 @@
 msgid "Identifier"
 msgstr "Identifiant"
 
-#: plugins/People/config_core.php:28
+#: plugins/People/config_core.php:29
 msgid "Username"
 msgstr "Nom d'utilisateur"
 
-#: plugins/People/config_core.php:34
+#: plugins/People/config_core.php:35
 msgid "Password"
 msgstr "Mot de passe"
 
-#: plugins/People/config_core.php:35
+#: plugins/People/config_core.php:36
 msgid "Repeat the password"
 msgstr "Répétez le mot de passe"
 
-#: plugins/People/config_core.php:41
+#: plugins/People/config_core.php:42
 msgid "E-mail"
 msgstr "Courriel"
 
-#: plugins/People/config_core.php:48
+#: plugins/People/config_core.php:49
 msgid "Name"
 msgstr "Nom"
 
-#: plugins/People/config_core.php:52
+#: plugins/People/config_core.php:53
 msgid "Surname"
 msgstr "Prénom"
 
-#: plugins/People/config_core.php:56
+#: plugins/People/config_core.php:57
 msgid "Genre"
 msgstr "Genre"
 
-#: plugins/People/config_core.php:57
+#: plugins/People/config_core.php:58
 msgid "female - ♀"
 msgstr "femme - ♀"
 
-#: plugins/People/config_core.php:58
+#: plugins/People/config_core.php:59
 msgid "male - ♂"
 msgstr "homme - ♂"
 
-#: plugins/People/config_core.php:62
+#: plugins/People/config_core.php:63
 msgid "Date of birth"
 msgstr "Date de naissance"
 
-#: plugins/People/config_core.php:66
+#: plugins/People/config_core.php:67
 msgid "Mobile phone number"
 msgstr "Numéro de Natel"
 
-#: plugins/People/config_core.php:71
+#: plugins/People/config_core.php:72
 msgid "New Social Security Number"
 msgstr "Nouveau numéro de Sécurité Sociale"
 
-#: plugins/People/config_core.php:77
+#: plugins/People/config_core.php:78
 msgid "Comment"
 msgstr "Commentaire"
 
@@ -100,8 +100,8 @@
 msgstr "Paramètres de connexion"
 
 #: plugins/People.php:44
-msgid "New entry"
-msgstr "Nouvelle entrée"
+msgid "New"
+msgstr "Nouveau"
 
 #: plugins/People.php:45
 msgid "List"
@@ -127,35 +127,38 @@
 msgid "Delete"
 msgstr "Destruction"
 
-#: plugins/People.php:154
+#: plugins/People.php:165
 msgid "The provided username is empty!"
 msgstr "Le nom d'utilisateur fourni est vide !"
 
-#: plugins/People.php:171
+#: plugins/People.php:186
 msgid "The provided username is already defined."
 msgstr "Le nom d'utilisateur fourni existe déjà."
 
-#: plugins/People.php:186
+#: plugins/People.php:201
 msgid "The provided password is empty (a random one has been provided)."
 msgstr ""
 "Le mot de passe fourni est vide (un mot de passe aléatoire a été généré)."
 
-#: plugins/People.php:197
+#: plugins/People.php:212
 msgid "The two provided passwords are different."
 msgstr "Les deux mots de passe fournis sont différents."
 
-#: plugins/People.php:305
+#: plugins/People.php:285
+msgid "New person"
+msgstr "Nouvelle personne"
+
+#: plugins/People.php:293
 msgid "Execute"
 msgstr "Exécuter"
 
-#: plugins/People.php:310
-msgid "New person"
-msgstr "Nouvelle personne"
-
-#: plugins/People.php:348
+#: plugins/People.php:329
 msgid "Confirm deletion"
 msgstr "Confirmer la destruction"
 
-#: plugins/People.php:348
+#: plugins/People.php:329
 msgid "Do you really want to delete the following entry?"
 msgstr "Voulez-vous vraiment détruire la fiche suivante ?"
+
+#~ msgid "New entry"
+#~ msgstr "Nouvelle entrée"

Modified: trunk/locale/fr.UTF-8/LC_MESSAGES/g_core.po
===================================================================
--- trunk/locale/fr.UTF-8/LC_MESSAGES/g_core.po	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/locale/fr.UTF-8/LC_MESSAGES/g_core.po	2008-11-26 18:16:22 UTC (rev 6)
@@ -1,28 +1,27 @@
- #
- #  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
- #         - Online Hierarchical Handling Of Adresses
- #
- #  Copyright (C) 2008  Didier Raboud
- #
- #  This program is free software: you can redistribute it and/or modify
- #  it under the terms of the GNU Affero General Public License as published by
- #  the Free Software Foundation, either version 3 of the License, or
- #  (at your option) any later version.
- #
- #  This program is distributed in the hope that it will be useful,
- #  but WITHOUT ANY WARRANTY; without even the implied warranty of
- #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- #  GNU Affero General Public License for more details.
- #
- #  You should have received a copy of the GNU Affero General Public License
- #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- #
-
+#
+#  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
+#         - Online Hierarchical Handling Of Adresses
+#
+#  Copyright (C) 2008  Didier Raboud
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 msgid ""
 msgstr ""
 "Project-Id-Version: g_core\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-25 15:26+0100\n"
+"POT-Creation-Date: 2008-11-26 19:13+0100\n"
 "PO-Revision-Date: 2008-09-25 11:30+0200\n"
 "Last-Translator: Didier Raboud <didier@xxxxxxxxxx>\n"
 "Language-Team:  <fr@xxxxxx>\n"
@@ -70,17 +69,17 @@
 msgid "Select your language"
 msgstr "Sélectionnez votre langue"
 
-#: inc/outputs/xHTML.class.php:476 inc/g_output.inc.php:62
+#: inc/outputs/xHTML.class.php:478 inc/g_output.inc.php:62
 #, php-format
 msgid "Total computation time: %.3f seconds."
 msgstr "Temps pour la génération de la page : %.3f secondes."
 
-#: inc/outputs/xHTML.class.php:477 inc/g_output.inc.php:63
+#: inc/outputs/xHTML.class.php:479 inc/g_output.inc.php:63
 #, php-format
 msgid "Powered by Ghelda, version %s"
 msgstr "Motorisé par Ghelda, version %s"
 
-#: inc/outputs/xHTML.class.php:585 inc/outputs/xHTML.class.php:604
+#: inc/outputs/xHTML.class.php:587 inc/outputs/xHTML.class.php:606
 msgid "%YEAR%-%MONTH%-%DAY%"
 msgstr "%DAY% %MONTH% %YEAR%"
 

Modified: trunk/locale/templates/People.pot
===================================================================
--- trunk/locale/templates/People.pot	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/locale/templates/People.pot	2008-11-26 18:16:22 UTC (rev 6)
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-26 09:44+0100\n"
+"POT-Creation-Date: 2008-11-26 19:14+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -20,55 +20,55 @@
 msgid "Identifier"
 msgstr ""
 
-#: plugins/People/config_core.php:28
+#: plugins/People/config_core.php:29
 msgid "Username"
 msgstr ""
 
-#: plugins/People/config_core.php:34
+#: plugins/People/config_core.php:35
 msgid "Password"
 msgstr ""
 
-#: plugins/People/config_core.php:35
+#: plugins/People/config_core.php:36
 msgid "Repeat the password"
 msgstr ""
 
-#: plugins/People/config_core.php:41
+#: plugins/People/config_core.php:42
 msgid "E-mail"
 msgstr ""
 
-#: plugins/People/config_core.php:48
+#: plugins/People/config_core.php:49
 msgid "Name"
 msgstr ""
 
-#: plugins/People/config_core.php:52
+#: plugins/People/config_core.php:53
 msgid "Surname"
 msgstr ""
 
-#: plugins/People/config_core.php:56
+#: plugins/People/config_core.php:57
 msgid "Genre"
 msgstr ""
 
-#: plugins/People/config_core.php:57
+#: plugins/People/config_core.php:58
 msgid "female - ♀"
 msgstr ""
 
-#: plugins/People/config_core.php:58
+#: plugins/People/config_core.php:59
 msgid "male - ♂"
 msgstr ""
 
-#: plugins/People/config_core.php:62
+#: plugins/People/config_core.php:63
 msgid "Date of birth"
 msgstr ""
 
-#: plugins/People/config_core.php:66
+#: plugins/People/config_core.php:67
 msgid "Mobile phone number"
 msgstr ""
 
-#: plugins/People/config_core.php:71
+#: plugins/People/config_core.php:72
 msgid "New Social Security Number"
 msgstr ""
 
-#: plugins/People/config_core.php:77
+#: plugins/People/config_core.php:78
 msgid "Comment"
 msgstr ""
 
@@ -85,7 +85,7 @@
 msgstr ""
 
 #: plugins/People.php:44
-msgid "New entry"
+msgid "New"
 msgstr ""
 
 #: plugins/People.php:45
@@ -112,34 +112,34 @@
 msgid "Delete"
 msgstr ""
 
-#: plugins/People.php:154
+#: plugins/People.php:165
 msgid "The provided username is empty!"
 msgstr ""
 
-#: plugins/People.php:171
+#: plugins/People.php:186
 msgid "The provided username is already defined."
 msgstr ""
 
-#: plugins/People.php:186
+#: plugins/People.php:201
 msgid "The provided password is empty (a random one has been provided)."
 msgstr ""
 
-#: plugins/People.php:197
+#: plugins/People.php:212
 msgid "The two provided passwords are different."
 msgstr ""
 
-#: plugins/People.php:305
-msgid "Execute"
+#: plugins/People.php:285
+msgid "New person"
 msgstr ""
 
-#: plugins/People.php:310
-msgid "New person"
+#: plugins/People.php:293
+msgid "Execute"
 msgstr ""
 
-#: plugins/People.php:348
+#: plugins/People.php:329
 msgid "Confirm deletion"
 msgstr ""
 
-#: plugins/People.php:348
+#: plugins/People.php:329
 msgid "Do you really want to delete the following entry?"
 msgstr ""

Modified: trunk/locale/templates/g_core.pot
===================================================================
--- trunk/locale/templates/g_core.pot	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/locale/templates/g_core.pot	2008-11-26 18:16:22 UTC (rev 6)
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-26 09:44+0100\n"
+"POT-Creation-Date: 2008-11-26 19:14+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -55,17 +55,17 @@
 msgid "Select your language"
 msgstr ""
 
-#: inc/outputs/xHTML.class.php:476 inc/g_output.inc.php:62
+#: inc/outputs/xHTML.class.php:478 inc/g_output.inc.php:62
 #, php-format
 msgid "Total computation time: %.3f seconds."
 msgstr ""
 
-#: inc/outputs/xHTML.class.php:477 inc/g_output.inc.php:63
+#: inc/outputs/xHTML.class.php:479 inc/g_output.inc.php:63
 #, php-format
 msgid "Powered by Ghelda, version %s"
 msgstr ""
 
-#: inc/outputs/xHTML.class.php:585 inc/outputs/xHTML.class.php:604
+#: inc/outputs/xHTML.class.php:587 inc/outputs/xHTML.class.php:606
 msgid "%YEAR%-%MONTH%-%DAY%"
 msgstr ""
 

Added: trunk/plugins/Address/config_core.php
===================================================================
--- trunk/plugins/Address/config_core.php	                        (rev 0)
+++ trunk/plugins/Address/config_core.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -0,0 +1,61 @@
+<?php
+/*
+ *  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
+ *         - Online Hierarchical Handling Of Adresses
+ *
+ *  Copyright (C) <year>  <name of authors>
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+// Required
+$conf['fields']['address_id']['type'] = 'INT( 10 )';
+$conf['fields']['address_id']['name'] = T_('Identifier');
+$conf['fields']['address_id']['restricted'] = 'key';
+$conf['fields']['address_id']['order'] = 1000;	// Has to be the highest
+
+
+// Optional
+$conf['fields']['Address']['type'] = 'TEXT';
+$conf['fields']['Address']['name'] = T_('Address');
+$conf['fields']['Address']['order'] = 50;
+
+$conf['fields']['PostalBox']['type'] = 'VARCHAR( 256 )';
+$conf['fields']['PostalBox']['name'] = T_('Postal Box');
+$conf['fields']['PostalBox']['order'] = 45;
+
+$conf['fields']['City']['type'] = 'VARCHAR( 256 )';
+$conf['fields']['City']['name'] = T_('City');
+$conf['fields']['City']['order'] = 40;
+
+$conf['fields']['Region']['type'] = 'VARCHAR( 256 )';
+$conf['fields']['Region']['name'] = T_('Region');
+$conf['fields']['Region']['order'] = 30;
+
+$conf['fields']['ZipCode']['type'] = 'VARCHAR( 10 )';
+$conf['fields']['ZipCode']['name'] = T_('Zip Code');
+$conf['fields']['ZipCode']['order'] = 45;
+
+$conf['fields']['Country_iso2']['type'] = 'CHAR( 2 )';
+$conf['fields']['Country_iso2']['name'] = T_('Country');
+$conf['fields']['Country_iso2']['order'] = 20;
+
+$conf['fields']['Phone']['type'] = 'VARCHAR( 16 )';
+$conf['fields']['Phone']['name'] = T_('Phone number');
+$conf['fields']['Phone']['order'] = 15;
+
+$conf['fields']['Fax']['type'] = 'VARCHAR( 16 )';
+$conf['fields']['Fax']['name'] = T_('Fax number');
+$conf['fields']['Fax']['order'] = 10;
+
+?>
\ No newline at end of file

Added: trunk/plugins/Address.php
===================================================================
--- trunk/plugins/Address.php	                        (rev 0)
+++ trunk/plugins/Address.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -0,0 +1,268 @@
+<?php
+/*
+ *  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
+ *         - Online Hierarchical Handling Of Adresses
+ *
+ *  Copyright (C) 2008 Didier Raboud
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('G_ADDRESS_URL_MODE','mode');
+define('G_ADDRESS_DEFAULT_MODE','list');
+define('G_ADDRESS_ID_NEW','-1');
+define('G_ADDRESS_ID','address_id');
+
+class Address extends Plugin {
+	// List of the modes
+	private $modes = array('edit','list','new','del');
+	// Actual mode
+	private $mode;
+	// List of the fields
+	private $fields = array();
+	// List of the fields
+	private $fieldsCore = array();
+	// List of the fields
+	private $fieldsAll = array();
+	// Name of the table
+	private $tableName;
+	// Name of the link table
+	private $linkPeopleTableName;
+	
+	//! Constructor
+	public function __construct(&$parentRef,$name)
+	{
+		$to_return = parent::__construct(&$parentRef,$name);
+
+		$this->tableName = $this->configH['DB']['prefix'].'address';
+		$this->linkPeopleTableName = $this->configH['DB']['prefix'].'people_address';
+	
+		return $to_return;
+	}
+
+	function modesMenu()
+	{
+		$this->startTrad();
+		$targets['Tname'] = T_('Addresses');
+		$targets['new']['name']  = T_('New');
+		$targets['list']['name'] = T_('List');
+		$this->stopTrad();
+		return $targets;
+	}
+
+	function main()
+	{	$this->startTrad();
+
+		// Take the mode from the URL or take the default mode
+		$this->mode = array_key_exists(G_ADDRESS_URL_MODE,$this->url->querystring) ? $this->url->querystring[G_ADDRESS_URL_MODE] : G_ADDRESS_DEFAULT_MODE;
+		
+		// If the mode is not know, trigger an error
+		if(array_search($this->mode,$this->modes) === false) {
+			trigger_error(T_('Intrusion tentative detected: ').T_("Don't try to use undefined mode names!"), G_E_LOG);
+			return false;
+		}
+
+		$this->fields		= $this->configH[$this->name]['fields'];
+
+		$i = 0;
+		// Sort the fields in descending Order 
+		foreach( $this->fields as $fieldName => $field ) {
+			$orderArray[$fieldName] = !empty($field['order']) ? $field['order'] : $i--;
+		}
+		array_multisort($orderArray,SORT_DESC,$this->fields);
+
+		// Only execute if the user is authentified
+		if($this->authH->getAuth()) {
+			// From here, we are in know mode
+			// Get the Id from a query or edit myself
+			$address_id = array_key_exists(G_ADDRESS_ID,$_GET) ? $_GET[G_ADDRESS_ID] : G_ADDRESS_ID_NEW;
+
+			switch($this->mode) {
+				case 'edit':		$this->m_edit($address_id,$this->fields);					break;
+				case 'list':		$this->m_list();										break;
+				case 'new':			$this->m_edit(G_ADDRESS_ID_NEW,$this->fields);		break;
+				case 'del':			$this->m_del($address_id);	break;
+			}
+		}
+		$this->stopTrad();
+	}
+
+	function functionality($funcStr,$funcArgs)
+	{
+		switch($funcStr) {
+			case "main":	$this->main();		break;
+		}
+	}
+
+	private function m_list()
+	{
+		// Get the formatted fields list and Add 'id' (mandatory)
+		$desiredFields = array_keys($this->fields);
+		
+		// Prepare it for MySQL
+		$formattedFields = implode($desiredFields,'`,`');
+		$query = sprintf("SELECT `%s` FROM `%s` ORDER BY `%s` ASC LIMIT 0 , 30",	// FIXME: No limit and no Selection of Columns
+			$formattedFields,
+			$this->tableName,
+			end($desiredFields));
+
+		$fieldsContents = $this->db->getAssoc($query);
+		if(PEAR::isError($fieldsContents))
+			return false;
+
+		$this->url->addQueryString(G_ADDRESS_URL_MODE,'edit');
+		// Select only the useful fields
+		$fieldsSpec = array_intersect_key($this->fields,array_flip($desiredFields));
+		
+		$modes['edit']	= array(
+				'name' => T_('Edit'),
+				'image' => 'pen');
+		$modes['del'] =array('name' =>T_('Delete'),'image' => 'cross');
+		$this->output->displayList($fieldsSpec,$fieldsContents,array('id'=>'People_list'),$modes);
+	}	
+
+	private function m_edit($id,&$fieldsSpec)
+	{
+		// Modification asked
+		if($_POST[$this->configH['URL']['action']] == 'change') {
+
+			// Get the fields from the keyed array
+			$fields = array_keys($fieldsSpec);
+
+			// Go along the fields
+			foreach($fields as $fieldName) {
+				// Jump the non-modified ones (and if we are creating a new user)
+				if(	$id != G_ADDRESS_ID_NEW &&
+					isset($_POST[$fieldName]) &&
+					$_POST[$fieldName] == $_POST[$fieldName.'_old']) {
+					continue;
+				}
+				// Get the type of the field and store its value
+				$type = $fieldsSpec[$fieldName]['type'];
+				$fieldValue = $_POST[$fieldName];
+
+				// Jump id (No insert nor check)
+				if($fieldName == G_ADDRESS_ID ) {
+					continue;
+				}
+
+				$fieldContent = g_getFormattedField($_POST,$type,$fieldName,$fieldsSpec);
+				if( $fieldContent === false ) { // The given date is false
+					$fieldsSpec[$fieldName]['error'] = true;
+					$newError = true;
+					continue;
+				}
+				$fieldsContents[$fieldName] = $fieldContent;
+				$formattedFields .= "`$fieldName` = '".$fieldContent."', ";
+			}
+			// Strip the two last characters (border issue)
+			$formattedFields = substr($formattedFields,0,-2);
+			// If we are updating (thus not making a new entry)
+			if($id <> G_ADDRESS_ID_NEW) {
+				$query = sprintf("UPDATE `%s` SET %s WHERE `%s` = '%s' LIMIT 1",
+					$this->authH->storage_options['table'],
+					$formattedFields,
+					G_ADDRESS_ID,
+					$id);
+				$queryR =& $this->db->query($query);
+				if(PEAR::isError($queryR)) return false;
+
+			} elseif ($newError !== true) { // Creating new entry iff we have not had any error before.
+				$query = sprintf("INSERT INTO `%s` SET %s",
+					$this->tableName,
+					$formattedFields,
+					G_ADDRESS_ID,
+					$id);
+				$queryR =& $this->db->query($query);
+				if(PEAR::isError($queryR))
+					return false;
+				// Get the just produced ID (per client => thread-safe)
+				$query = "SELECT LAST_INSERT_ID()";
+				$queryR =& $this->db->query($query);
+				$id =& current($queryR->fetchRow());
+				// Success => mode = 'edit'
+				$this->mode = 'edit';
+			}
+			$this->url->removeQueryString($this->configH['URL']['action']);
+		}
+
+		// Display the edited user
+
+		// If we are not creating a new address
+		if( $id <> G_ADDRESS_ID_NEW ) {
+			// Get the formatted fields list
+			$formattedFields = array_keys($fieldsSpec);
+			$formattedFields = implode($formattedFields,'`,`');
+			$query = sprintf("SELECT `%s` FROM `%s` WHERE `%s` = '%s' LIMIT 1",
+				$formattedFields,
+				$this->tableName,
+				G_ADDRESS_ID,
+				$id);
+			$queryR =& $this->db->query($query);
+			if(PEAR::isError($queryR))
+				return false;
+			$fieldsContents =& $queryR->fetchRow();
+		} else { // We are creating a new user
+			// Set the ID to the special one
+			$fieldsContents[G_ADDRESS_ID] = $id;
+			$displayOptions['title'] = T_('New address');
+		}
+		// Make the URL OK
+		$this->url->addQueryString(G_ADDRESS_URL_MODE,$this->mode);
+		$this->url->addQueryString(G_ADDRESS_ID,$id);
+
+		$fieldsContents[G_ADDRESS_ID] = $id;
+
+		$displayOptions['id']		= 'Address_view';
+		$displayOptions['command']	= T_('Execute');
+		$displayOptions['target']	= $this->url->getURL();
+		$displayOptions['action']	= 'change';
+
+		$this->output->displayFields($fieldsSpec,$fieldsContents,$displayOptions);
+	}
+
+	private function m_del($id)
+	{
+		// Delete the given id (seek for confirmation)
+		
+		// In case of confirmation
+		if($_POST[$this->configH['URL']['action']] == 'confirm') {
+			$query = sprintf("DELETE FROM `%s` WHERE `%s` = %d LIMIT 1",
+				$this->tableName,
+				G_ADDRESS_ID,
+				$id);
+			$queryR =& $this->db->query($query);
+			if(PEAR::isError($queryR))
+				return false;
+			$this->m_list();
+		} else {
+			// Seek the data
+			$formattedFields = array_keys($this->fields);
+			$formattedFields = implode($formattedFields,'`,`');
+			$query = sprintf("SELECT `%s` FROM `%s` WHERE `%s` = '%s' LIMIT 1",
+				$formattedFields,
+				$this->tableName,
+				G_ADDRESS_ID,
+				$id);
+			$queryR =& $this->db->query($query);
+			if(PEAR::isError($queryR))
+				return false;
+			$fieldsContents =& $queryR->fetchRow();
+
+			// Display the fields and launch the command to confirm
+			$this->output->displayFields($this->fields,$fieldsContents,array('id'=>'Address_view','command'=>T_('Confirm deletion'),'target'=>$this->url->getURL(),'action'=>'confirm','title'=>T_('Do you really want to delete the following entry?')));
+		}
+	}
+}
+?>
\ No newline at end of file

Modified: trunk/plugins/People/config_core.php
===================================================================
--- trunk/plugins/People/config_core.php	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/plugins/People/config_core.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -3,7 +3,7 @@
  *  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
  *         - Online Hierarchical Handling Of Adresses
  *
- *  Copyright (C) <year>  <name of authors>
+ *  Copyright (C) 2008 Didier Raboud
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU Affero General Public License as published by
@@ -22,6 +22,7 @@
 $conf['fields_core'][G_DB_PEOPLE_ID]['type'] = 'INT( 10 )';
 $conf['fields_core'][G_DB_PEOPLE_ID]['name'] = T_('Identifier');
 $conf['fields_core'][G_DB_PEOPLE_ID]['restricted'] = 'key';
+$conf['fields_core'][G_DB_PEOPLE_ID]['order'] = 1000; // Has to be big
 
 // Required
 $conf['fields_core'][G_DB_PEOPLE_USERNAME]['type'] = 'VARCHAR( 50 )';

Modified: trunk/plugins/People.php
===================================================================
--- trunk/plugins/People.php	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/plugins/People.php	2008-11-26 18:16:22 UTC (rev 6)
@@ -3,7 +3,7 @@
  *  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
  *         - Online Hierarchical Handling Of Adresses
  *
- *  Copyright (C) <year>  <name of authors>
+ *  Copyright (C) 2008 Didier Raboud
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU Affero General Public License as published by
@@ -19,9 +19,9 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-define('G_MEM_URL_MODE','mode');
-define('G_MEM_DEFAULT_MODE','edit');
-define('G_MEM_ID_NEW','-1');
+define('G_PEOPLE_URL_MODE','mode');
+define('G_PEOPLE_DEFAULT_MODE','list');
+define('G_PEOPLE_ID_NEW','-1');
 
 class People extends Plugin {
 	// List of the modes
@@ -41,7 +41,7 @@
 		$targets['Tname'] = T_('People');
 		$targets['edit']['name'] = T_('My Data');
 		$targets['edit_base']['name'] = T_('Connection settings');
-		$targets['new']['name']  = T_('New entry');
+		$targets['new']['name']  = T_('New');
 		$targets['list']['name'] = T_('List');
 		$this->stopTrad();
 		return $targets;
@@ -51,7 +51,7 @@
 	{	$this->startTrad();
 
 		// Take the mode from the URL or take the default mode
-		$this->mode = array_key_exists(G_MEM_URL_MODE,$this->url->querystring) ? $this->url->querystring[G_MEM_URL_MODE] : G_MEM_DEFAULT_MODE;
+		$this->mode = array_key_exists(G_PEOPLE_URL_MODE,$this->url->querystring) ? $this->url->querystring[G_PEOPLE_URL_MODE] : G_PEOPLE_DEFAULT_MODE;
 		
 		// If the mode is not know, trigger an error
 		if(array_search($this->mode,$this->modes) === false) {
@@ -83,7 +83,7 @@
 				case 'edit':		$this->m_edit($id,$this->fieldsAll);					break;
 				case 'edit_base':	$this->m_edit($id,$this->fieldsCore,true);				break;
 				case 'list':		$this->m_list();										break;
-				case 'new':			$this->m_edit(G_MEM_ID_NEW,$this->fieldsAll);			break;
+				case 'new':			$this->m_edit(G_PEOPLE_ID_NEW,$this->fieldsAll);		break;
 				case 'del':			$this->m_del($this->url->querystring[G_DB_PEOPLE_ID]);	break;
 			}
 		}
@@ -100,20 +100,20 @@
 	private function m_list()
 	{
 		// Get the formatted fields list and Add 'id' (mandatory)
-		$desiredFields = array_merge(array(G_DB_PEOPLE_ID),$this->configH[$this->name]['list']['fields']);
+		$desiredFields = array_keys($this->fieldsAll);
 		
 		// Prepare it for MySQL
 		$formattedFields = implode($desiredFields,'`,`');
 		$query = sprintf("SELECT `%s` FROM `%s` WHERE `username` IS NOT NULL ORDER BY `%s` ASC LIMIT 0 , 30",	// FIXME: No limit and no Selection of Columns
 			$formattedFields,
 			$this->authH->storage_options['table'],
-			$desiredFields[1]);
+			G_DB_PEOPLE_ID);
 
 		$fieldsContents = $this->db->getAssoc($query);
 		if(PEAR::isError($fieldsContents))
 			return false;
 
-		$this->url->addQueryString(G_MEM_URL_MODE,'edit');
+		$this->url->addQueryString(G_PEOPLE_URL_MODE,'edit');
 		// Select only the useful fields
 		$fieldsSpec = array_intersect_key($this->fieldsAll,array_flip($desiredFields));
 		
@@ -133,62 +133,77 @@
 			unset($fieldsSpec[G_DB_PEOPLE_PASSWORD]['noShow']);
 		}
 
-		// In case of modification
+		// Modification asked
 		if($_POST[$this->configH['URL']['action']] == 'change') {
+
 			// Get the fields from the keyed array
 			$fields = array_keys($fieldsSpec);
 
+			// Go along the fields
 			foreach($fields as $fieldName) {
-				// Jump the non-modified ones
-				if($id != G_MEM_ID_NEW && isset($_POST[$fieldName]) && $_POST[$fieldName] == $_POST[$fieldName.'_old'])	continue;
-
+				// Jump the non-modified ones (and if we are creating a new user)
+				if(	$id != G_PEOPLE_ID_NEW &&
+					array_key_exists($fieldName.'_old',$_POST) && 
+					$_POST[$fieldName] == $_POST[$fieldName.'_old']) {
+					continue;
+				}
+				// Get the type of the field and store its value
 				$type = $fieldsSpec[$fieldName]['type'];
+				$fieldValue = $_POST[$fieldName];
+
 				// Jump id (No insert nor check)
-				if($fieldName == G_DB_PEOPLE_ID) continue;
+				if($fieldName == G_DB_PEOPLE_ID ) {
+					continue;
+				}
+
 				// For the username
-				if($fieldName == G_DB_PEOPLE_USERNAME) {
+				if( $fieldName == G_DB_PEOPLE_USERNAME ) {
 					// If we are creating a new user
-					if($id == G_MEM_ID_NEW || $editBase) { // We are creating a new one or modifying => check its uniqueness and size
-						if(empty($_POST[$fieldName])) {
-							// Trigger the error
+					if( $id == G_PEOPLE_ID_NEW || $editBase ) { // We are creating a new one or editing an existing one
+						if( empty( $fieldValue ) ) {
+							// Trigger an error
 							trigger_error(T_('The provided username is empty!'), G_E_DISPLAY);
-							// Mark it
-							$fieldsSpec[$fieldName]['error'] = true;
+							// Mark it as "error"
+							$fieldsSpec[G_DB_PEOPLE_USERNAME]['error'] = true;
 							// And allow re-writing it
 							unset($fieldsSpec[G_DB_PEOPLE_USERNAME]['restricted']);
 							$newError = true;
-							// Proposition
+
+							// Proposition (which should be unique)
 							$fieldsContents[G_DB_PEOPLE_USERNAME] = md5(md5(microtime()));
+							// Done
 							continue;
-						} else {
-							$query = sprintf("SELECT COUNT( * ) FROM `%s` WHERE `username` = '%s'",$this->authH->storage_options['table'],$_POST[$fieldName]);
+						} else { // We are not creating a new one => check its uniqueness and size
+							$query = sprintf("SELECT COUNT( * ) FROM `%s` WHERE `username` = '%s'",$this->authH->storage_options['table'],$fieldValue);
 							$queryR =& $this->db->query($query);
 							if(PEAR::isError($queryR))
 								return false;
 							$result =& $queryR->fetchRow();
 							if(current($result) <> 0) {	// If the only result (the counting) is different from zero, we already have something
+								// Error
 								$fieldsSpec[$fieldName]['error'] = true;
+								// Warning
 								trigger_error(T_('The provided username is already defined.'), G_E_DISPLAY);
+								// Allow rewriting to it
 								unset($fieldsSpec[G_DB_PEOPLE_USERNAME]['restricted']);
 								$newError = true;
+								// Done
 								continue;
 							}
-							$fieldContent = $_POST[$fieldName];
+							// In absence of error => attribute value
+							$fieldContent = $fieldValue;
 						}
-					} else {
-						$fieldContent = $_POST[$fieldName];
-						continue;
-					}
+					} else 	continue;
 				} elseif ($fieldName == G_DB_PEOPLE_PASSWORD) { // If we have one password entry, we have two
-					if($id == G_MEM_ID_NEW || $editBase) { // We are creating a new one or modifying => check its uniqueness and size
-						if(empty($_POST[$fieldName])) {
+					if($id == G_PEOPLE_ID_NEW || $editBase) { // We are creating a new one or editing an existing one
+						if( empty( $fieldValue ) ) {	// Provided password is empty
 							$fieldsSpec[$fieldName]['error'] = true;
 							trigger_error(T_('The provided password is empty (a random one has been provided).'), G_E_DISPLAY);
 							unset($fieldsSpec[$fieldName]['noShow']);
 							$newError = true;
 							$fieldsContents[G_DB_PEOPLE_PASSWORD] = md5(microtime());
 							continue;
-						} elseif ($_POST[$fieldName] == $_POST[$fieldName.'_repeat']) { // Both passwords are the same
+						} elseif ($_POST[$fieldName] == $_POST[$fieldName.'_repeat'] && !empty($_POST[$fieldName])) { // Both passwords are the same and non-empty
 							// Get the hashing algorithm
 							$hash = $this->configH['Auth']['cryptType'];
 							$fieldContent = $hash($_POST[$fieldName]);
@@ -203,57 +218,28 @@
 						}
 					} else continue;
 				} else {
-					// for dates
-					if(stripos($type,'date') !== false) {
-						if(empty($_POST[$fieldName.'_year']) || empty($_POST[$fieldName.'_month']) || empty($_POST[$fieldName.'_day'])) {
-							$fieldContent = '0000-00-00';
-						} elseif(checkdate((int)$_POST[$fieldName.'_month'],(int)$_POST[$fieldName.'_day'],(int)$_POST[$fieldName.'_year'])) {
-							$fieldContent = $_POST[$fieldName.'_year'].'-'.$_POST[$fieldName.'_month'].'-'.$_POST[$fieldName.'_day'];
-						} else { // The given date is false
-							$fieldsSpec[$fieldName]['error'] = true;
-							$newError = true;
-							continue;
-						}
-					} elseif(array_key_exists('ereg',$fieldsSpec[$fieldName])) { // for fields which have a verification pattern
-						if(ereg($fieldsSpec[$fieldName]['ereg'],$_POST[$fieldName]) || empty($_POST[$fieldName])) {
-							$fieldContent = $_POST[$fieldName];
-						} else { // Error...
-							$fieldsSpec[$fieldName]['error'] = true;
-							$newError = true;
-							continue;
-						}
-					} elseif(array_key_exists('preg',$fieldsSpec[$fieldName])) { // for fields which have a verification pattern
-						if(preg_match($fieldsSpec[$fieldName]['preg'],$_POST[$fieldName])|| empty($_POST[$fieldName])) {
-							$fieldContent = $_POST[$fieldName];
-						} else { // Error...
-							$fieldsSpec[$fieldName]['error'] = true;
-							$newError = true;
-							continue;
-						}
-					} else {
-						$fieldContent = $_POST[$fieldName];
+					$fieldContent = g_getFormattedField($_POST,$type,$fieldName,$fieldsSpec);
+					if( $fieldContent === false ) { // The given date is false
+						$fieldsSpec[$fieldName]['error'] = true;
+						$newError = true;
+						continue;
 					}
 				}
-				$formattedFields .= "`$fieldName` = '".$fieldContent."', ";
-				// Fill the $fieldsContents variable with the 
 				$fieldsContents[$fieldName] = $fieldContent;
+				$formattedFields .= "`$fieldName` = '".$fieldContent."', ";
 			}
-			// Strip the two last characters
+			// Strip the two last characters (border issue)
 			$formattedFields = substr($formattedFields,0,-2);
 			// If we are updating (thus not making a new entry)
-			if($id <> G_MEM_ID_NEW) {
-				if(true) {
-					$query = sprintf("UPDATE `%s` SET %s WHERE `%s` = '%s' LIMIT 1",
-						$this->authH->storage_options['table'],
-						$formattedFields,
-						G_DB_PEOPLE_ID,
-						$id);
-					$queryR =& $this->db->query($query);
-					if(PEAR::isError($queryR)) return false;
+			if($id <> G_PEOPLE_ID_NEW) {
+				$query = sprintf("UPDATE `%s` SET %s WHERE `%s` = '%s' LIMIT 1",
+					$this->authH->storage_options['table'],
+					$formattedFields,
+					G_DB_PEOPLE_ID,
+					$id);
+				$queryR =& $this->db->query($query);
+				if(PEAR::isError($queryR)) return false;
 
-					// If the username has been modified, please warn everybody
-					
-				} else return false;
 			} elseif ($newError !== true) { // Creating new entry iff we have not had any error before.
 				$query = sprintf("INSERT INTO `%s` SET %s",
 					$this->authH->storage_options['table'],
@@ -267,6 +253,8 @@
 				$query = "SELECT LAST_INSERT_ID()";
 				$queryR =& $this->db->query($query);
 				$id =& current($queryR->fetchRow());
+				// Success => mode = 'edit'
+				$this->mode = 'edit';
 // 			} else {	// We had errors while preparing the new user
 			}
 			$this->url->removeQueryString($this->configH['URL']['action']);
@@ -275,7 +263,7 @@
 		// Display the edited user
 
 		// If we are not creating a new user
-		if($id <> G_MEM_ID_NEW) {
+		if($id <> G_PEOPLE_ID_NEW) {
 			// Get the formatted fields list
 			$formattedFields = array_keys($fieldsSpec);
 			$formattedFields = implode($formattedFields,'`,`');
@@ -294,26 +282,19 @@
 			// Allow some stuff to be edited.
 			unset($fieldsSpec[G_DB_PEOPLE_USERNAME]['restricted']);
 			unset($fieldsSpec[G_DB_PEOPLE_PASSWORD]['noShow']);
+			$displayOptions['title'] = T_('New person');
 		}
-		$this->url->addQueryString(G_MEM_URL_MODE,$this->mode);
+		$this->url->addQueryString(G_PEOPLE_URL_MODE,$this->mode);
+		$this->url->addQueryString(G_DB_PEOPLE_ID,$id);
 
 		$fieldsContents[G_DB_PEOPLE_ID] = $id;
 
-// 		trigger_error(' => ' .var_export($fieldsContents,true),G_E_LOG);
-
 		$displayOptions['id']		= 'People_view';
 		$displayOptions['command']	= T_('Execute');
 		$displayOptions['target']	= $this->url->getURL();
 		$displayOptions['action']	= 'change';
 
-		if( $id == G_MEM_ID_NEW ) {
-			$displayOptions['title'] = T_('New person');
-		}
-
 		$this->output->displayFields($fieldsSpec,$fieldsContents,$displayOptions);
-
-		// Call the functionality
-		$this->_parent->functionality('People.edit.bottom',$fieldsContents);
 	}
 
 	private function m_del($id)
@@ -322,7 +303,7 @@
 		
 		// In case of confirmation
 		if($_POST[$this->configH['URL']['action']] == 'confirm') {
-			$query = sprintf("UPDATE `%s` SET `username` = NULL WHERE `%s` = '%s' LIMIT 1 ;",
+			$query = sprintf("DELETE FROM `%s` WHERE `%s` = %d LIMIT 1",
 				$this->authH->storage_options['table'],
 				G_DB_PEOPLE_ID,
 				$id);

Modified: trunk/style/main.css
===================================================================
--- trunk/style/main.css	2008-11-26 08:45:52 UTC (rev 5)
+++ trunk/style/main.css	2008-11-26 18:16:22 UTC (rev 6)
@@ -2,7 +2,7 @@
  *  Ghelda - Gestion Hiérarchisée En Ligne D'Adresses
  *         - Online Hierarchical Handling Of Adresses
  *
- *  Copyright (C) <year>  <name of authors>
+ *  Copyright (C) 2008 Didier Raboud
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU Affero General Public License as published by


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/