FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Logging Group Manager actions
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Logging Group Manager actions [message #164072] Sun, 02 January 2011 14:54 Go to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Just a first step since I felt like it Razz

In admlog.php

After

			case "ADDFORUM":
				echo '<td>Created Forum</td><td>forum: '.return_forum_name($obj->a_res_id).'</td>';
				break;


insert

case "ADDGRP":
				echo '<td>Added groupmember</td><td>'.$obj->logaction.'</td>';
				break;	
			case "DELGRP":
				echo '<td>Deleted groupmember</td><td>'.$obj->logaction.'</td>';
				break;	
			case "EDITGRP":
				echo '<td>Edited groupmember</td><td>'.$obj->logaction.'</td>';
				break;	


In groupmgr.php.t
After
	if (isset($_POST['btn_submit'])) {

insert
		fud_use('logaction.inc');







After
q('INSERT INTO {SQL_TABLE_PREFIX}group_members (group_members_opt, user_id, group_id) VALUES ('.$perm.', '.$usr_id.', '.$group_id.')');

insert
$user_alias = q_singleval("SELECT alias FROM {SQL_TABLE_PREFIX}users WHERE id=".$usr_id);
				$group_name = q_singleval("SELECT name FROM {SQL_TABLE_PREFIX}groups WHERE id=".$group_id);
				$log_add_grp = 'Added member '.$user_alias.' ('.$usr_id.') to group '.$group_name.' ('.$group_id.')';
				logaction(_uid, 'ADDGRP', 0, $log_add_grp);


after
q('UPDATE {SQL_TABLE_PREFIX}group_members SET group_members_opt='.$perm.' WHERE id='.(int)$_POST['edit']);


insert
$user_alias = q_singleval("SELECT alias FROM {SQL_TABLE_PREFIX}users WHERE id=".$usr_id);
				$group_name = q_singleval("SELECT name FROM {SQL_TABLE_PREFIX}groups WHERE id=".$group_id);
				$log_edit_grp = 'Edit member '.$user_alias.' ('.$usr_id.') in group '.$group_name.' ('.$group_id.')';
				logaction(_uid, 'EDITGRP', 0, $log_edit_grp);



After
	if (isset($_GET['del']) && ($del = (int)$_GET['del']) && $group_id && sq_check(0, $usr->sq)) {

insert
		fud_use('logaction.inc');

After
$is_gl = q_singleval("SELECT user_id FROM {SQL_TABLE_PREFIX}group_members WHERE group_id=".$group_id." AND user_id=".$del." AND group_members_opt>=131072 AND (group_members_opt & 131072) > 0");

insert
				$user_alias = q_singleval("SELECT alias FROM {SQL_TABLE_PREFIX}users WHERE id=".$del);
				$group_name = q_singleval("SELECT name FROM {SQL_TABLE_PREFIX}groups WHERE id=".$group_id);
				$log_del_grp = 'Deleted member '.$user_alias.' ('.$del.') from group '.$group_name.' ('.$group_id.')';
				logaction(_uid, 'DELGRP', 0, $log_del_grp);









This should add entries to the action log whenever someone adds, edits or deletes a groupmember


Re: Logging Group Manager actions [message #164073 is a reply to message #164072] Sun, 02 January 2011 14:55 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Pardon the tabs, its late, going to bed, just wanted to share. Trying to share stuff from now on, sorta Razz

Re: Logging Group Manager actions [message #164076 is a reply to message #164073] Sun, 02 January 2011 22:02 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3632
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Beautiful! I'll commit it later.

PS: It would be easier if you can post your changes in unidiff (diff -u) format.
For more info, see http://en.wikipedia.org/wiki/Diff#Unified_format
Re: Logging Group Manager actions [message #164077 is a reply to message #164076] Mon, 03 January 2011 00:58 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
I guess I will have to get a tool for that Razz

Re: Logging Group Manager actions [message #164089 is a reply to message #164077] Mon, 03 January 2011 09:36 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3632
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
If you use Windows, you can try http://winmerge.org/

"Creates patch files (Normal-, Context- and Unified formats)"
Re: Logging Group Manager actions [message #164093 is a reply to message #164089] Mon, 03 January 2011 10:54 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
I use ultraedit, so i picked up uestudio, that should be able to do the job. Was annoyed that uedit couldnt do it from the start.

Re: Logging Group Manager actions [message #164167 is a reply to message #164072] Fri, 07 January 2011 06:53 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 662
Registered: May 2009
Location: USA
Karma: 2
Senior Member
add to buddy list
ignore all messages by this user
You said :Ernesto wrote on Sun, 02 January 2011 13:54
Just a first step since I felt like it Razz
<- Snip -->
This should add entries to the action log whenever someone adds, edits or deletes a groupmember


Is there more to come? Or needed?

Which brings me to ask just how comprehensive is the admin log function, and are there any other recommended additions to be made?



"I'm a Witcher, I solve human problems; not always using a sword!"
Re: Logging Group Manager actions [message #164256 is a reply to message #164167] Sun, 16 January 2011 03:38 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3632
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Yes, we will log a lot more than this in FUDforum 3.0.3, for example, SQL statements that look suspect (insert, update, delete, drop, etc.). I'm not sure how far we are going to take this. Only time will tell. We should also be cautious not to over do it.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Database host:port support
Next Topic: Fudforum on Foswiki appliance
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Dec 18 02:12:43 EST 2017

Total time taken to generate the page: 0.00858 seconds