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