Hook into specific user in view/edit in ACP
Destroy666 Offline
Junior Member
**
Posts: 27
Joined: Jul 2012
Post: #1
Hook into specific user in view/edit in ACP
I'd like to add another $user item here:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
		while($user = $db->fetch_array($query))
		{
			$comma = $groups_list = '';
			$user['view']['username'] = "<a href=\"index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}\">".format_name($user['username'], $user['usergroup'], $user['displaygroup'])."</a>";
			$user['view']['usergroup'] = $usergroups[$user['usergroup']]['title'];
			if($user['additionalgroups'])
			{
				$additional_groups = explode(",", $user['additionalgroups']);

				foreach($additional_groups as $group)
				{
					$groups_list .= "{$comma}{$usergroups[$group]['title']}";
					$comma = $lang->comma;
				}
			}
			if(!$groups_list)
			{
				$groups_list = $lang->none;
			}
			$user['view']['additionalgroups'] = "<small>{$groups_list}</small>";
			$user['view']['email'] = "<a href=\"mailto:".htmlspecialchars_uni($user['email'])."\">".htmlspecialchars_uni($user['email'])."</a>";
			$user['view']['regdate'] = my_date($mybb->settings['dateformat'], $user['regdate']).", ".my_date($mybb->settings['timeformat'], $user['regdate']);
			$user['view']['lastactive'] = my_date($mybb->settings['dateformat'], $user['lastactive']).", ".my_date($mybb->settings['timeformat'], $user['lastactive']);

			// Build popup menu
			$popup = new PopupMenu("user_{$user['uid']}", $lang->options);
			$popup->add_item($lang->edit_profile_and_settings, "index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}");
			$popup->add_item($lang->ban_user, "index.php?module=user-banning&amp;uid={$user['uid']}#username");

			if($user['usergroup'] == 5)
			{
				if($user['coppauser'])
				{
					$popup->add_item($lang->approve_coppa_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
				}
				else
				{
					$popup->add_item($lang->approve_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
				}
			}

			$popup->add_item($lang->delete_user, "index.php?module=user-users&amp;action=delete&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->user_deletion_confirmation}')");
			$popup->add_item($lang->show_referred_users, "index.php?module=user-users&amp;action=referrers&amp;uid={$user['uid']}");
			$popup->add_item($lang->show_ip_addresses, "index.php?module=user-users&amp;action=ipaddresses&amp;uid={$user['uid']}");
			$popup->add_item($lang->show_attachments, "index.php?module=forum-attachments&amp;results=1&amp;username=".urlencode(htmlspecialchars_uni($user['username'])));
			$user['view']['controls'] = $popup->fetch();

			// Fetch the reputation for this user
			if($usergroups[$user['usergroup']]['usereputationsystem'] == 1 && $mybb->settings['enablereputation'] == 1)
			{
				$user['view']['reputation'] = get_reputation($user['reputation']);
			}
			else
			{
				$reputation = "-";
			}

			if($mybb->settings['enablewarningsystem'] != 0 && $usergroups[$user['usergroup']]['canreceivewarnings'] != 0)
			{
				$warning_level = round($user['warningpoints']/$mybb->settings['maxwarningpoints']*100);
				if($warning_level > 100)
				{
					$warning_level = 100;
				}
				$user['view']['warninglevel'] = get_colored_warning_level($warning_level);
			}

			if($user['avatar'] && !stristr($user['avatar'], 'http://'))
			{
				$user['avatar'] = "../{$user['avatar']}";
			}
			if($view['view_type'] == "card")
			{
				$scaled_avatar = fetch_scaled_avatar($user, 80, 80);
			}
			else
			{
				$scaled_avatar = fetch_scaled_avatar($user, 34, 34);
			}
			if(!$user['avatar'])
			{
				$user['avatar'] = "styles/{$page->style}/images/default_avatar.gif";
			}
			$user['view']['avatar'] = "<img src=\"".htmlspecialchars_uni($user['avatar'])."\" alt=\"\" width=\"{$scaled_avatar['width']}\" height=\"{$scaled_avatar['height']}\" />";

			if($view['view_type'] == "card")
			{
				$users .= build_user_view_card($user, $view, $i);
			}
			else
			{
				build_user_view_table($user, $view, $table);
			}
		}


and another <tr> here:

PHP Code:
	$table->construct_cell("<strong>{$lang->registration_ip}:</strong> {$user['regip']}");
	$table->construct_cell("<strong>{$lang->last_known_ip}:</strong> {$user['lastip']}");
	$table->construct_row();


Both codes are from modules/users.php and I can't see any hook which would let me do it.

Can I achieve that without core edits with Plugin Library? If yes, how?

(This post was last modified: 01-05-2014 05:48 AM by Destroy666.)
01-05-2014 05:47 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Hook into specific user in view/edit in ACP
You could always just use output buffering and do string replaces...
But if you don't want to do that:

(01-05-2014 05:47 AM)Destroy666 Wrote:  I'd like to add another $user item here:
Assuming you want to add another row, you could use the my_date hook.  You'd want to subclass the $db object beforehand though, firstly so that you can access the $user variable (since the code is within a function) and secondly so that you can ensure you're executing in the right place.

(01-05-2014 05:47 AM)Destroy666 Wrote:  and another <tr> here:
Subclassing $table or appending stuff to the $lang strings.

My Blog
01-08-2014 09:59 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: