Changeset 11656 for extensions/Copyrights/admin.php
- Timestamp:
- Jul 7, 2011, 1:27:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Copyrights/admin.php
r11635 r11656 32 32 check_status(ACCESS_ADMINISTRATOR); 33 33 34 // Default is to create , if changed to 1, showedit page34 // Default is to create a copyright, if changed to 1, show the edit page 35 35 $edit = 0; 36 36 … … 44 44 // Do managing of copyrights 45 45 if (isset($_GET['tab'])) { 46 // Create a new copyright 46 47 if ($_GET['tab'] == 'create') { 48 // Fetch the values from the form 47 49 $name = pwg_db_real_escape_string($_REQUEST['name']); 48 50 $url = pwg_db_real_escape_string($_REQUEST['url']); 49 51 $descr = pwg_db_real_escape_string($_REQUEST['descr']); 50 52 $visible = (isset($_REQUEST['visible']) ? 1 : 0); 53 54 // Check whether a copyright with such a name exists 55 // Therefore count the number of copyrights with that name 51 56 $query = sprintf( 52 57 'SELECT COUNT(*) … … 56 61 COPYRIGHTS_ADMIN, $name); 57 62 list($counter) = pwg_db_fetch_row(pwg_query($query)); 58 if ($counter != 0) { 63 64 if ($counter != 0) { // The copyright exists already 59 65 array_push($page['errors'], l10n('This copyright already exists')); 60 } else { 66 } else { // The copyright did not yet exist 67 // Compose a query to insert the copyright 61 68 $query = sprintf( 62 69 'INSERT INTO %s … … 65 72 ;', 66 73 COPYRIGHTS_ADMIN, $name, $url, $descr, $visible); 67 pwg_query($query); 74 pwg_query($query); // Execute the query 68 75 } 69 76 } 70 77 78 // Edit an existing copyright 71 79 if ($_GET['tab'] == 'edit') { 72 $edit = 1; 73 $CRid = $_REQUEST['id']; 80 $edit = 1; // Show the edit page 81 $CRid = $_REQUEST['id']; // Fetch the id of the copyright to be edited 82 83 // Fetch the current attributes to the copyright 74 84 $query = sprintf( 75 85 'SELECT * … … 80 90 $result = pwg_query($query); 81 91 $row = pwg_db_fetch_assoc($result); 92 93 // Save the attributes in convenient variables 82 94 $CRname = $row['name']; 83 95 $CRurl = $row['url']; … … 86 98 } 87 99 100 // Update an existing copyright 88 101 if ($_GET['tab'] == 'update') { 102 // Fetch the values from the edit form 89 103 $id = pwg_db_real_escape_string($_REQUEST['id']); 90 104 $name = pwg_db_real_escape_string($_REQUEST['name']); … … 92 106 $descr= pwg_db_real_escape_string($_REQUEST['descr']); 93 107 $visible = (isset($_REQUEST['visible']) ? 1 : 0); 108 109 // Compose a query to update the copyright 94 110 $query = sprintf( 95 111 'UPDATE %s … … 98 114 ;', 99 115 COPYRIGHTS_ADMIN, $name, $url, $descr, $visible, $id); 100 pwg_query($query); 116 pwg_query($query); // Execute the query 101 117 } 102 118 119 // Delete an existing copyright 103 120 if ($_GET['tab'] == 'delete') { 104 $id = $_REQUEST['id']; 121 $id = $_REQUEST['id']; // Fetch the id of the copyright to be deleted 122 123 // Compose a query to delete the copyright 105 124 $query = sprintf( 106 125 'DELETE FROM %s … … 108 127 ;', 109 128 COPYRIGHTS_ADMIN, $id); 110 pwg_query($query); 129 pwg_query($query); // Execute the query 111 130 } 112 131 } 113 132 114 / / Create page template133 /* Assign variables to the template */ 115 134 global $template; 116 135 136 // Add the admin.tpl template 117 137 $template->set_filenames( 118 138 array( … … 121 141 ); 122 142 143 // Select the existing copyrights 123 144 $query = sprintf( 124 145 'SELECT * … … 128 149 $result = pwg_query($query); 129 150 151 // Append the copyrights to the Smarty array 130 152 while ($row = pwg_db_fetch_assoc($result)) { 131 153 $template->append( … … 141 163 } 142 164 165 // Assign the path for URL forming 143 166 $template->assign( 144 167 'COPYRIGHTS_PATH', … … 146 169 ); 147 170 171 // Assign all the variables we constructed above 148 172 $template->assign('edit', $edit); 149 173 $template->assign('CRid', $CRid); … … 153 177 $template->assign('CRvisible', $CRvisible); 154 178 179 // Get it up and running 155 180 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 156 181
Note: See TracChangeset
for help on using the changeset viewer.