[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 | { |
---|
[29791] | 14 | load_language('plugin.lang', CWAP_PATH); |
---|
[27480] | 15 | global $template; |
---|
| 16 | $userslist = array(); |
---|
| 17 | $query = ' |
---|
| 18 | SELECT id, username |
---|
| 19 | FROM '.USERS_TABLE.' |
---|
| 20 | ORDER BY username ASC |
---|
| 21 | ;'; |
---|
| 22 | $result = pwg_query($query); |
---|
| 23 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 24 | { |
---|
| 25 | $userslist[$row['username']] = $row['username']; |
---|
| 26 | } |
---|
| 27 | $template->set_filename('CWAPPP', realpath(CWAP_PATH.'cwap.tpl')); |
---|
| 28 | $template->assign('userslist', $userslist); |
---|
| 29 | $template->append('element_set_global_plugins_actions', array( |
---|
[22073] | 30 | 'ID' => 'CWAP', |
---|
| 31 | 'NAME' => l10n('Change who added photo'), |
---|
[27480] | 32 | 'CONTENT' => $template->parse('CWAPPP', true) |
---|
[22073] | 33 | )); |
---|
| 34 | } |
---|
| 35 | |
---|
[27480] | 36 | |
---|
| 37 | |
---|
[22073] | 38 | function CWAP_element_set_global_action($action, $collection) |
---|
| 39 | { |
---|
[29791] | 40 | load_language('plugin.lang', CWAP_PATH); |
---|
[22073] | 41 | if ($action == 'CWAP') |
---|
| 42 | { |
---|
| 43 | global $page; |
---|
| 44 | |
---|
| 45 | if (empty($_POST['check_CWAP'])) |
---|
| 46 | { |
---|
| 47 | array_push($page['warnings'], l10n('You need to confirm')); |
---|
| 48 | } |
---|
| 49 | else |
---|
| 50 | { |
---|
| 51 | |
---|
| 52 | $query = ' |
---|
| 53 | select id |
---|
| 54 | FROM ' . USERS_TABLE . ' |
---|
| 55 | WHERE username = \''.$_POST['CWAP'].'\' |
---|
| 56 | ;'; |
---|
| 57 | $result = pwg_query($query); |
---|
| 58 | $row = pwg_db_fetch_assoc($result); |
---|
| 59 | $CWAP=$row['id']; |
---|
| 60 | $datas = array(); |
---|
| 61 | foreach ($collection as $image_id) |
---|
| 62 | { |
---|
| 63 | array_push( |
---|
| 64 | $datas, |
---|
| 65 | array( |
---|
| 66 | 'id' => $image_id, |
---|
| 67 | 'added_by' => $CWAP |
---|
| 68 | ) |
---|
| 69 | ); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | mass_updates( |
---|
| 73 | IMAGES_TABLE, |
---|
| 74 | array('primary' => array('id'), 'update' => array('added_by')), |
---|
| 75 | $datas |
---|
| 76 | ); |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | ?> |
---|