Changeset 12390 for extensions/Extended_author
- Timestamp:
- Oct 8, 2011, 8:38:30 PM (12 years ago)
- Location:
- extensions/Extended_author
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Extended_author/admin.php
r11819 r12390 3 3 // | Piwigo - a PHP based picture gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-20 09Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 39 39 $EAid = 0; 40 40 $EAname = ''; 41 $EAcode = ''; 41 42 $EAurl = ''; 42 43 $EAdescr = ''; … … 65 66 // Fetch the values from the form 66 67 $name = pwg_db_real_escape_string($_REQUEST['name']); 68 $code = pwg_db_real_escape_string($_REQUEST['code']); 67 69 $url = pwg_db_real_escape_string($_REQUEST['url']); 68 70 $descr = pwg_db_real_escape_string($_REQUEST['descr']); 69 71 $copyright = pwg_db_real_escape_string($_REQUEST['copyrightID']); 70 72 71 // Check whether an author with such a name exists72 // Therefore count the number of authors with that name 73 // Check whether an author with such a name or code exists 74 // Therefore count the number of authors with that name or code 73 75 $query = sprintf( 74 76 'SELECT COUNT(*) 75 77 FROM %s 76 78 WHERE `name` = \'%s\' 77 ;', 78 AUTHORS, $name); 79 list($counter) = pwg_db_fetch_row(pwg_query($query)); 80 79 OR `code` = \'%s\' 80 ;', 81 AUTHORS, $name, $code); 82 $result = pwg_query($query); 83 $counter = pwg_db_num_rows($result); 84 81 85 if ($counter != 0) { 82 86 // The author exists already … … 87 91 $query = sprintf( 88 92 'INSERT INTO %s 89 (`name`,` url`,`descr`,`copyright`) VALUES90 ("%s","%s","%s", %d)93 (`name`,`code`,`url`,`descr`,`copyright`) VALUES 94 ("%s","%s","%s","%s",%d) 91 95 ;', 92 AUTHORS, $name, $ url, $descr, $copyright);96 AUTHORS, $name, $code, $url, $descr, $copyright); 93 97 pwg_query($query); // Execute the query 94 98 } … … 112 116 // Save the attributes in convenient variables 113 117 $EAname = $row['name']; 118 $EAcode = $row['code']; 114 119 $EAurl = $row['url']; 115 120 $EAdescr = $row['descr']; … … 122 127 $id = pwg_db_real_escape_string($_REQUEST['id']); 123 128 $name = pwg_db_real_escape_string($_REQUEST['name']); 129 $code = pwg_db_real_escape_string($_REQUEST['code']); 124 130 $url = pwg_db_real_escape_string($_REQUEST['url']); 125 131 $descr = pwg_db_real_escape_string($_REQUEST['descr']); 126 132 $copyright = pwg_db_real_escape_string($_REQUEST['copyrightID']); 127 133 128 // Compose a query to update the author 129 $query = sprintf( 130 'UPDATE %s 131 SET `name`="%s", `url`="%s", `descr`="%s", `copyright`=%d 132 WHERE `author_id`=%d 133 ;', 134 AUTHORS, $name, $url, $descr, $copyright, $id); 135 pwg_query($query); // Execute the query 134 // Check whether an author with such a name or code exists 135 // Therefore count the number of authors with that name or code 136 $query = sprintf( 137 'SELECT COUNT(*) 138 FROM %s 139 WHERE `name` = \'%s\' 140 OR `code` = \'%s\' 141 ;', 142 AUTHORS, $name, $code); 143 $result = pwg_query($query); 144 $counter = pwg_db_num_rows($result); 145 146 if ($counter != 0) { 147 // The author exists already 148 array_push($page['errors'], l10n('This author already exists.')); 149 } else { 150 // The author did not yet exist 151 // Compose a query to update the author 152 $query = sprintf( 153 'UPDATE %s 154 SET `name`="%s", `code`="%s", `url`="%s", `descr`="%s", `copyright`=%d 155 WHERE `author_id`=%d 156 ;', 157 AUTHORS, $name, $code, $url, $descr, $copyright, $id); 158 pwg_query($query); // Execute the query 159 } 136 160 } 137 161 … … 197 221 'author_id' => $row['author_id'], 198 222 'name' => $row['name'], 223 'code' => $row['code'], 199 224 'url' => $row['url'], 200 225 'descr' => $row['descr'], … … 214 239 $template->assign('EAid', $EAid); 215 240 $template->assign('EAname', $EAname); 241 $template->assign('EAcode', $EAcode); 216 242 $template->assign('EAurl', $EAurl); 217 243 $template->assign('EAdescr', $EAdescr); -
extensions/Extended_author/admin.tpl
r11819 r12390 17 17 <td>{'Name'|@translate}</td> 18 18 <td><input type='text' name='name' id='name' value='{$EAname}' /></td> 19 </tr> 20 <tr> 21 <td>{'Code'|@translate}</td> 22 <td><input type='text' name='code' id='code' value='{$EAcode}' /></td> 19 23 </tr> 20 24 <tr> … … 52 56 <!-- create a nice header row --> 53 57 <th>{'Name'|@translate}</th> 58 <th>{'Code'|@translate}</th> 54 59 <th>{'URL'|@translate}</th> 55 60 <th>{'Description'|@translate}</th> … … 64 69 table rows --> 65 70 <td>{$EA.name}</td> 71 <td>{$EA.code}</td> 66 72 <td><a href="{$EA.url}">{$EA.url}</a></td> 67 73 <td>{$EA.descr}</td> -
extensions/Extended_author/maintain.inc.php
r11846 r12390 3 3 // | Piwigo - a PHP based picture gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-20 09Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 49 49 author_id int(11) NOT NULL AUTO_INCREMENT, 50 50 name varchar(255) UNIQUE NOT NULL, 51 code varchar (4) UNIQUE NOT NULL, 51 52 url varchar(255), 52 53 descr text DEFAULT NULL,
Note: See TracChangeset
for help on using the changeset viewer.