Index: /extensions/Extended_author/admin.php
===================================================================
--- /extensions/Extended_author/admin.php	(revision 12389)
+++ /extensions/Extended_author/admin.php	(revision 12390)
@@ -3,5 +3,5 @@
 // | Piwigo - a PHP based picture gallery                                  |
 // +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
@@ -39,4 +39,5 @@
 $EAid = 0;
 $EAname = '';
+$EAcode = '';
 $EAurl = '';
 $EAdescr = '';
@@ -65,18 +66,21 @@
 		// Fetch the values from the form
 		$name = pwg_db_real_escape_string($_REQUEST['name']);
+		$code = pwg_db_real_escape_string($_REQUEST['code']);
 		$url = pwg_db_real_escape_string($_REQUEST['url']);
 		$descr = pwg_db_real_escape_string($_REQUEST['descr']);
 		$copyright = pwg_db_real_escape_string($_REQUEST['copyrightID']);
 
-		// Check whether an author with such a name exists
-		// Therefore count the number of authors with that name
+		// Check whether an author with such a name or code exists
+		// Therefore count the number of authors with that name or code
 		$query = sprintf(
 			'SELECT COUNT(*)
 			FROM %s
 			WHERE `name` = \'%s\'
-			;',
-			AUTHORS, $name);
-		list($counter) = pwg_db_fetch_row(pwg_query($query));
-
+			OR `code` = \'%s\'
+			;',
+			AUTHORS, $name, $code);
+		$result = pwg_query($query);
+		$counter = pwg_db_num_rows($result);
+		
 		if ($counter != 0) {
 			// The author exists already
@@ -87,8 +91,8 @@
 			$query = sprintf(
 				'INSERT INTO %s
-				(`name`,`url`,`descr`,`copyright`) VALUES
-				("%s","%s","%s",%d)
+				(`name`,`code`,`url`,`descr`,`copyright`) VALUES
+				("%s","%s","%s","%s",%d)
 				;',
-				AUTHORS, $name, $url, $descr, $copyright);
+				AUTHORS, $name, $code, $url, $descr, $copyright);
 			pwg_query($query); // Execute the query
 		}
@@ -112,4 +116,5 @@
 		// Save the attributes in convenient variables
 		$EAname = $row['name'];
+		$EAcode = $row['code'];
 		$EAurl = $row['url'];
 		$EAdescr = $row['descr'];
@@ -122,16 +127,35 @@
 		$id = pwg_db_real_escape_string($_REQUEST['id']);
 		$name = pwg_db_real_escape_string($_REQUEST['name']);
+		$code = pwg_db_real_escape_string($_REQUEST['code']);
 		$url = pwg_db_real_escape_string($_REQUEST['url']);
 		$descr = pwg_db_real_escape_string($_REQUEST['descr']);
 		$copyright = pwg_db_real_escape_string($_REQUEST['copyrightID']);
 
-		// Compose a query to update the author
-		$query = sprintf(
-			'UPDATE %s
-			SET `name`="%s", `url`="%s", `descr`="%s", `copyright`=%d
-			WHERE `author_id`=%d
-			;',
-			AUTHORS, $name, $url, $descr, $copyright, $id);
-		pwg_query($query); // Execute the query
+		// Check whether an author with such a name or code exists
+		// Therefore count the number of authors with that name or code
+		$query = sprintf(
+			'SELECT COUNT(*)
+			FROM %s
+			WHERE `name` = \'%s\'
+			OR `code` = \'%s\'
+			;',
+			AUTHORS, $name, $code);
+		$result = pwg_query($query);
+		$counter = pwg_db_num_rows($result);
+		
+		if ($counter != 0) {
+			// The author exists already
+			array_push($page['errors'], l10n('This author already exists.'));
+		} else {
+			// The author did not yet exist
+			// Compose a query to update the author
+			$query = sprintf(
+				'UPDATE %s
+				SET `name`="%s", `code`="%s", `url`="%s", `descr`="%s", `copyright`=%d
+				WHERE `author_id`=%d
+				;',
+				AUTHORS, $name, $code, $url, $descr, $copyright, $id);
+			pwg_query($query); // Execute the query
+		}
 	}
 
@@ -197,4 +221,5 @@
 			'author_id' => $row['author_id'],
 			'name'      => $row['name'],
+			'code'      => $row['code'],
 			'url'       => $row['url'],
 			'descr'     => $row['descr'],
@@ -214,4 +239,5 @@
 $template->assign('EAid', $EAid);
 $template->assign('EAname', $EAname);
+$template->assign('EAcode', $EAcode);
 $template->assign('EAurl', $EAurl);
 $template->assign('EAdescr', $EAdescr);
Index: /extensions/Extended_author/admin.tpl
===================================================================
--- /extensions/Extended_author/admin.tpl	(revision 12389)
+++ /extensions/Extended_author/admin.tpl	(revision 12390)
@@ -17,4 +17,8 @@
           <td>{'Name'|@translate}</td>
           <td><input type='text' name='name' id='name' value='{$EAname}' /></td>
+        </tr>
+        <tr>
+          <td>{'Code'|@translate}</td>
+          <td><input type='text' name='code' id='code' value='{$EAcode}' /></td>
         </tr>
         <tr>
@@ -52,4 +56,5 @@
         <!-- create a nice header row -->
         <th>{'Name'|@translate}</th>
+        <th>{'Code'|@translate}</th>
         <th>{'URL'|@translate}</th>
         <th>{'Description'|@translate}</th>
@@ -64,4 +69,5 @@
                                                    table rows -->
         <td>{$EA.name}</td>
+        <td>{$EA.code}</td>
         <td><a href="{$EA.url}">{$EA.url}</a></td>
         <td>{$EA.descr}</td>
Index: /extensions/Extended_author/maintain.inc.php
===================================================================
--- /extensions/Extended_author/maintain.inc.php	(revision 12389)
+++ /extensions/Extended_author/maintain.inc.php	(revision 12390)
@@ -3,5 +3,5 @@
 // | Piwigo - a PHP based picture gallery                                  |
 // +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
@@ -49,4 +49,5 @@
 	  author_id int(11) NOT NULL AUTO_INCREMENT,
       name varchar(255) UNIQUE NOT NULL,
+	  code varchar (4) UNIQUE NOT NULL,
       url varchar(255),
       descr text DEFAULT NULL,
