1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | //add prefiter |
---|
6 | add_event_handler('loc_begin_admin', 'aun1', 55 ); |
---|
7 | |
---|
8 | function aun1() |
---|
9 | { |
---|
10 | load_language('plugin.lang', USERNOTES_PATH); |
---|
11 | load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); |
---|
12 | |
---|
13 | global $template, $prefixeTable; |
---|
14 | $template->set_prefilter('profile_content', 'aun2'); |
---|
15 | $template->set_filename('profile_aun', realpath(USERNOTES_PATH.'profile_addusersnotes.tpl')); |
---|
16 | |
---|
17 | if (isset($_GET['user_id'])) |
---|
18 | { |
---|
19 | $query = ' |
---|
20 | select user_id,note |
---|
21 | FROM ' . USERNOTES_TABLE . ' |
---|
22 | WHERE user_id = '.$_GET['user_id'].' |
---|
23 | ;'; |
---|
24 | $result = pwg_query($query); |
---|
25 | $row = mysql_fetch_array($result); |
---|
26 | $note=$row['note']; |
---|
27 | |
---|
28 | |
---|
29 | $template->assign( |
---|
30 | array( |
---|
31 | 'NOTESID' => $_GET['user_id'], |
---|
32 | 'NOTESCONTENT' => htmlspecialchars($note), |
---|
33 | )); |
---|
34 | } |
---|
35 | $template->assign_var_from_handle('PROFILE_AUN', 'profile_aun'); |
---|
36 | } |
---|
37 | |
---|
38 | function aun2($content, &$smarty) |
---|
39 | { |
---|
40 | |
---|
41 | $search = '<p class="bottomButtons">'; |
---|
42 | return str_replace($search, '{$PROFILE_AUN}'."\n".$search, $content); |
---|
43 | } |
---|
44 | |
---|
45 | add_event_handler('save_profile_from_post', 'aun3'); |
---|
46 | |
---|
47 | function aun3() |
---|
48 | { |
---|
49 | global $prefixeTable; |
---|
50 | |
---|
51 | $query = ' |
---|
52 | DELETE |
---|
53 | FROM ' . USERNOTES_TABLE . ' |
---|
54 | WHERE user_id = '.$_POST['inserID2'].' |
---|
55 | ;'; |
---|
56 | $result = pwg_query($query); |
---|
57 | |
---|
58 | $q = ' |
---|
59 | INSERT INTO ' . $prefixeTable . 'user_notes(user_id,note)VALUES ("'.$_POST['inserID2'].'","'.$_POST['inseraun'].'");'; |
---|
60 | pwg_query($q); |
---|
61 | } |
---|
62 | |
---|
63 | add_event_handler('delete_user', 'aun4'); |
---|
64 | |
---|
65 | function aun4($user_id) |
---|
66 | { |
---|
67 | global $prefixeTable; |
---|
68 | |
---|
69 | $query = ' |
---|
70 | DELETE |
---|
71 | FROM ' . USERNOTES_TABLE . ' |
---|
72 | WHERE user_id = '.$user_id.' |
---|
73 | ;'; |
---|
74 | $result = pwg_query($query); |
---|
75 | } |
---|
76 | |
---|
77 | add_event_handler('loc_visible_user_list', 'aun5'); |
---|
78 | |
---|
79 | |
---|
80 | function aun5($visible_user_list) |
---|
81 | { |
---|
82 | global $template; |
---|
83 | |
---|
84 | $template->append('plugin_user_list_column_titles', l10n('Notes')); |
---|
85 | |
---|
86 | $user_ids = array(); |
---|
87 | |
---|
88 | foreach ($visible_user_list as $i => $user) |
---|
89 | { |
---|
90 | $user_ids[$i] = $user['id']; |
---|
91 | } |
---|
92 | |
---|
93 | $user_nums = array_flip($user_ids); |
---|
94 | |
---|
95 | if (!empty($user_ids)) |
---|
96 | { |
---|
97 | $query = ' |
---|
98 | select u.id, un.note |
---|
99 | FROM ' . USERS_TABLE . ' AS u LEFT JOIN '.USERNOTES_TABLE.' AS un on u.id = un.user_id |
---|
100 | WHERE u.id IN ('.implode(',', $user_ids).') |
---|
101 | ;'; |
---|
102 | |
---|
103 | |
---|
104 | $result = pwg_query($query); |
---|
105 | |
---|
106 | while ($row = mysql_fetch_array($result)) |
---|
107 | { |
---|
108 | |
---|
109 | if (!empty($row['note'])) |
---|
110 | { |
---|
111 | $visible_user_list[$user_nums[$row['id']]]['plugin_columns'][] =$row['note'].' '; |
---|
112 | } |
---|
113 | if (empty($row['note'])) |
---|
114 | { |
---|
115 | load_language('plugin.lang', USERNOTES_PATH); |
---|
116 | load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); |
---|
117 | $noempty=l10n('no note'); |
---|
118 | $visible_user_list[$user_nums[$row['id']]]['plugin_columns'][] =$noempty; |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | } |
---|
123 | return $visible_user_list; |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | ?> |
---|