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