Last change
on this file since 26003 was
22073,
checked in by ddtddt, 12 years ago
|
[extensions] - change_who_added_photo - First release
|
File size:
1.5 KB
|
Rev | Line | |
---|
[22073] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | load_language('plugin.lang', CWAP_PATH); |
---|
| 5 | |
---|
| 6 | global $prefilter; |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | add_event_handler('loc_end_element_set_global', 'CWAP_loc_end_element_set_global'); |
---|
| 10 | add_event_handler('element_set_global_action', 'CWAP_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
| 11 | |
---|
| 12 | function CWAP_loc_end_element_set_global() |
---|
| 13 | { |
---|
| 14 | global $template; |
---|
| 15 | $template->append('element_set_global_plugins_actions', array( |
---|
| 16 | 'ID' => 'CWAP', |
---|
| 17 | 'NAME' => l10n('Change who added photo'), |
---|
| 18 | 'CONTENT' => ' |
---|
| 19 | <input type="text" name="CWAP"> |
---|
| 20 | <input type="checkbox" name="check_CWAP"> '.l10n('confirm').' |
---|
| 21 | ', |
---|
| 22 | )); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | function CWAP_element_set_global_action($action, $collection) |
---|
| 26 | { |
---|
| 27 | if ($action == 'CWAP') |
---|
| 28 | { |
---|
| 29 | global $page; |
---|
| 30 | |
---|
| 31 | if (empty($_POST['check_CWAP'])) |
---|
| 32 | { |
---|
| 33 | array_push($page['warnings'], l10n('You need to confirm')); |
---|
| 34 | } |
---|
| 35 | else |
---|
| 36 | { |
---|
| 37 | |
---|
| 38 | $query = ' |
---|
| 39 | select id |
---|
| 40 | FROM ' . USERS_TABLE . ' |
---|
| 41 | WHERE username = \''.$_POST['CWAP'].'\' |
---|
| 42 | ;'; |
---|
| 43 | $result = pwg_query($query); |
---|
| 44 | $row = pwg_db_fetch_assoc($result); |
---|
| 45 | $CWAP=$row['id']; |
---|
| 46 | if ($row['id'] == 0) |
---|
| 47 | { |
---|
| 48 | array_push($page['warnings'], l10n('This user doesn\'t exist')); |
---|
| 49 | } |
---|
| 50 | else |
---|
| 51 | { |
---|
| 52 | $datas = array(); |
---|
| 53 | foreach ($collection as $image_id) |
---|
| 54 | { |
---|
| 55 | array_push( |
---|
| 56 | $datas, |
---|
| 57 | array( |
---|
| 58 | 'id' => $image_id, |
---|
| 59 | 'added_by' => $CWAP |
---|
| 60 | ) |
---|
| 61 | ); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | mass_updates( |
---|
| 65 | IMAGES_TABLE, |
---|
| 66 | array('primary' => array('id'), 'update' => array('added_by')), |
---|
| 67 | $datas |
---|
| 68 | ); |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.