source: extensions/change_who_added_photo/initadmin.php @ 27558

Last change on this file since 27558 was 27480, checked in by ddtddt, 10 years ago

[extensions] - change_who_added_photo - sectect in user list

File size: 1.7 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        global $template;
15  $userslist = array(); 
16  $query = '
17SELECT 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 
37function 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 = '
51select 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?>
Note: See TracBrowser for help on using the repository browser.