source: extensions/change_who_added_photo/initadmin.php @ 30538

Last change on this file since 30538 was 29791, checked in by ddtddt, 10 years ago

[change_who_added_photo] check 2.7

File size: 1.8 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4load_language('plugin.lang', CWAP_PATH);
5
6global $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 
12function CWAP_loc_end_element_set_global()
13 {
14 load_language('plugin.lang', CWAP_PATH);
15        global $template;
16  $userslist = array(); 
17  $query = '
18SELECT 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(
30    'ID' => 'CWAP', 
31    'NAME' => l10n('Change who added photo'), 
32    'CONTENT' => $template->parse('CWAPPP', true)
33        ));
34 }
35
36
37 
38function CWAP_element_set_global_action($action, $collection)
39 {
40  load_language('plugin.lang', CWAP_PATH);
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 = '
53select 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?>
Note: See TracBrowser for help on using the repository browser.