Hello, Guest.

Reporting API

Reporting allows 3rd party application / module provider to generate a link that will allow guests / members to report against an item. The item here could refer to any object within the page. There is 3 main steps that needs to be done to achieve this,

Generate HTML codes

Generate the 'HTML' codes and display it within your application / module.

// Load libraries
CFactory::load('libraries', 'reporting');
$report	 = new CReportingLibrary();
$html	 = $report->getReportingHTML( JText::_('CC REPORT BAD USER') , 'profile,reportProfile' , array( $user->id ) );
  • JText::_('CC REPORT BAD USER') - The first parameter here informs the library to display this text in the html codes.
  • profile,reportProfile - Second parameter informs the library to call the method to register your tasks. To register a call for plugins, you can use plugins,pluginname,method.
  • array( $user->id ) - Third parameter is the unique id that you are reporting against.


Registering the report action

/**
 * Method is called from the reporting library. Function calls should be
 * registered here.
 *
 * return	String	Message that will be displayed to user upon submission.
 **/
function reportProfile( $link, $message , $id )
{
	CFactory::load( 'libraries' , 'reporting' );
	$report = new CReportingLibrary();
 
	$report->createReport( JText::_('Bad user') , $link , $message );
	$action					= new stdClass();
	$action->label			= 'Block User';
	$action->method			= 'profile,blockProfile';
	$action->parameters		= $id;
	$action->defaultAction	= false;
 
	$report->addActions( array( $action ) );
 
	return JText::_('CC REPORT SUBMITTED');
}
  • For plugins, simply create the function in your plugin and the system will automatically call this method.
  • $action->method - To register a call for plugins, you can use plugins,pluginname,method .

Creating method that will be executed by the administrator

When the report item is added to the system, the administrator will then be able to perform the actions based on what you have parsed to the system. For an example, the 'block profile' method below, will block the user when the administrator clicks on the link.

/**
 * Function that is called from the back end
 **/	 	
function blockProfile( $userId )
{
	$user		=& CFactory::getUser( $userId );
	$user->set( 'block' , 1 );
	$user->save();
	return JText::_('CC USER ACCOUNT BLOCKED');
}

The return value will be a normal string output which will be displayed to the administrator.

  • For plugins, simply create the function in your plugin and the system will automatically call this method.

Docs Navigation

JomSocial Video Testimonial Contest. Top 5 best videos wins iPod Nano 4G.

Slashes & Dots Sdn. Bhd.
MALAYSIA OFFICE
No 1-7, Signature Office,
The Boulevard Mid Valley City,
Lingkaran Syed Putra,
59200 Kuala Lumpur, Malaysia.
U.S. OFFICE
251 West Central Avenue #146,
Springboro, Ohio 45066, U.S.A.

Tel: +60 (3) 2282-1997
Fax: +60 (3) 2283-1997
E-mail:
Copyright © 2007 - 2009 JomSocial.com. All rights reserved.
JomSocial is made for Joomla!
JomSocial Community Count

1827 users currently online | 84780 forum posts