Changeset 11675 for extensions/Copyrights/modify.php
- Timestamp:
- Jul 9, 2011, 3:30:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Copyrights/modify.php
r11638 r11675 3 3 // Add a prefilter 4 4 add_event_handler('loc_begin_admin', 'CR_set_prefilter_modify', 50 ); 5 add_event_handler('loc_ end_admin', 'CR_modify_submit', 50 );5 add_event_handler('loc_begin_admin', 'CR_modify_submit', 50 ); 6 6 7 7 // Change the variables used by the function that changes the template 8 add_event_handler('loc_ end_admin', 'CR_add_modify_vars_to_template');8 add_event_handler('loc_begin_admin', 'CR_add_modify_vars_to_template'); 9 9 10 10 function CR_set_prefilter_modify() … … 23 23 <select id="copyright" name="copyright"> 24 24 <option value="0">--</option> 25 {html_options options=$CRoptions selected=$CR copyrights[$CRid]}25 {html_options options=$CRoptions selected=$CRid} 26 26 </select> 27 27 </td> … … 36 36 function CR_add_modify_vars_to_template() 37 37 { 38 global $template; 38 // Check if we are at the modify page (the problem is that this will send the stuff to every admin page that has an ?image_id... 39 if (isset($_GET['image_id'])) 40 { 41 global $template; 39 42 40 load_language('plugin.lang', dirname(__FILE__).'/');43 load_language('plugin.lang', dirname(__FILE__).'/'); 41 44 42 // Fetch all the copyrights and assign them to the template43 $query = sprintf(44 'SELECT `cr_id`,`name`45 FROM %s46 WHERE `visible`<>047 ;',48 COPYRIGHTS_ADMIN);49 $result = pwg_query($query);45 // Fetch all the copyrights and assign them to the template 46 $query = sprintf( 47 'SELECT `cr_id`,`name` 48 FROM %s 49 WHERE `visible`<>0 50 ;', 51 COPYRIGHTS_ADMIN); 52 $result = pwg_query($query); 50 53 51 $CRoptions = array(); 52 while ($row = pwg_db_fetch_assoc($result)) { 53 $CRoptions[$row['cr_id']] = $row['name']; 54 $CRoptions = array(); 55 while ($row = pwg_db_fetch_assoc($result)) { 56 $CRoptions[$row['cr_id']] = $row['name']; 57 } 58 $template->assign('CRoptions', $CRoptions); 59 60 // Get the current Copyright 61 $image_id = $_GET['image_id']; 62 $query = sprintf( 63 'SELECT `media_id`, `cr_id` 64 FROM %s 65 WHERE `media_id` = %d 66 ;', 67 COPYRIGHTS_MEDIA, $image_id); 68 $result = pwg_query($query); 69 70 $CRid = 0; // Default is '--' 71 while ($row = pwg_db_fetch_assoc($result)) { 72 $CRid = $row['cr_id']; 73 } 74 $template->assign('CRid', $CRid); 54 75 } 55 $template->assign('CRoptions', $CRoptions);56 57 // Get the current Copyright58 $image_id = $_GET['image_id']);59 $query = sprintf(60 'SELECT `media_id`, `cr_id`61 FROM %s62 WHERE `media_id` = %d63 ;',64 COPYRIGHTS_MEDIA, $image_id);65 $result = pwg_query($query);66 67 $CRid = 0; // Default is '--'68 while ($row = pwg_db_fetch_assoc($result)) {69 $CRid = $row['cr_id'];70 }71 $template->assign('CRid', $CRid);72 76 } 73 77 74 78 function CR_modify_submit() 75 79 { 76 if (isset($_POST['submit'])) 80 // Check if we are at the modify page (the problem is that this will send the stuff to every admin page that has an ?image_id... 81 if (isset($_GET['image_id'])) 77 82 { 78 // The data from the submit 79 $image_id = $_GET['image_id']); 80 $CRid = $_POST['copyright']; 83 if (isset($_POST['submit'])) 84 { 85 // The data from the submit 86 $image_id = $_GET['image_id']; 87 $CRid = $_POST['copyright']; 81 88 82 // Delete the Copyright if it allready exists 89 // Delete the Copyright if it allready exists 90 $query = sprintf( 91 'DELETE 92 FROM %s 93 WHERE `media_id` = %d 94 ;', 95 COPYRIGHTS_MEDIA, $image_id); 96 pwg_query($query); 97 98 // Insert the Copyright 83 99 $query = sprintf( 84 'DELETE 85 FROM %s 86 WHERE `media_id` = %d 87 ;', 88 COPYRIGHTS_MEDIA, $image_id); 100 'INSERT INTO %s 101 VALUES (%d, %d) 102 ;', 103 COPYRIGHTS_MEDIA, $image_id, $CRid); 89 104 pwg_query($query); 90 91 // Insert the Copyright 92 $query = sprintf( 93 'INSERT INTO %s 94 VALUES (%d, %d) 95 ;', 96 COPYRIGHTS_MEDIA, $image_id, $CRid); 97 pwg_query($query); 105 } 98 106 } 99 107 }
Note: See TracChangeset
for help on using the changeset viewer.