Rev | Line | |
---|
[11819] | 1 | <?php |
---|
| 2 | |
---|
| 3 | // Replace all not assigned copyrights from a specific author, with the default copyright. |
---|
| 4 | function insert_default_CR($author) { |
---|
| 5 | global $prefixeTable; |
---|
| 6 | |
---|
| 7 | // Get all the images from this author that have no copyrights |
---|
| 8 | $query = sprintf( |
---|
| 9 | 'SELECT id |
---|
| 10 | FROM %s |
---|
| 11 | WHERE `author`=\'%s\' |
---|
| 12 | AND id NOT IN ( |
---|
| 13 | SELECT media_id AS id |
---|
| 14 | FROM %s |
---|
| 15 | ) |
---|
| 16 | ;', |
---|
| 17 | IMAGES, $author, COPYRIGHTS_MEDIA); |
---|
| 18 | $result = pwg_query($query); |
---|
| 19 | |
---|
| 20 | // Put them in an array |
---|
| 21 | $edits = array(); |
---|
| 22 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
| 23 | array_push( |
---|
| 24 | $edits, |
---|
| 25 | array( |
---|
| 26 | 'media_id' => $row['id'], |
---|
| 27 | 'cr_id' => -1, |
---|
| 28 | ) |
---|
| 29 | ); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | // Put that array in the database |
---|
| 33 | if (count($edits) > 0) { |
---|
| 34 | mass_inserts( |
---|
| 35 | COPYRIGHTS_MEDIA, |
---|
| 36 | array_keys($edits[0]), |
---|
| 37 | $edits |
---|
| 38 | ); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | // Delete all copyrights from an author |
---|
| 44 | function delete_default_CR($author) { |
---|
| 45 | global $prefixeTable; |
---|
| 46 | // Get all image_id's with default copyrights from this author |
---|
| 47 | $query = sprintf( |
---|
| 48 | 'SELECT id |
---|
| 49 | FROM %s |
---|
| 50 | WHERE (`author`=\'%s\' OR `author`=NULL) |
---|
| 51 | AND id IN ( |
---|
| 52 | SELECT media_id AS id |
---|
| 53 | FROM %s |
---|
| 54 | WHERE cr_id = -1 |
---|
| 55 | ) |
---|
| 56 | ;', |
---|
| 57 | IMAGES, $author, COPYRIGHTS_MEDIA); |
---|
| 58 | $result = pwg_query($query); |
---|
| 59 | |
---|
| 60 | // Put them in an array |
---|
| 61 | $deletes = array(); |
---|
| 62 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
| 63 | $deletes[] = $row['id']; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // Delete them |
---|
| 67 | if (count($deletes) > 0) { |
---|
| 68 | $query = sprintf( |
---|
| 69 | 'DELETE |
---|
| 70 | FROM %s |
---|
| 71 | WHERE media_id IN (%s) |
---|
| 72 | ;', |
---|
| 73 | COPYRIGHTS_MEDIA, implode(',', $deletes)); |
---|
| 74 | pwg_query($query); |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.