CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Limiting Relationship Report to Current User
Pages: [1]

Author Topic: Limiting Relationship Report to Current User  (Read 925 times)

darkchild

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 2
  • “…more than kisses, letters mingle souls…”- John D
  • CiviCRM version: 4.0.1
  • CMS version: joomla & drupal
  • MySQL version: 5.0.91
  • PHP version: 5.2.14
Limiting Relationship Report to Current User
January 25, 2012, 05:59:22 am
I wish to have a custom report exactly like the Relationship Report. The only difference is the report would be limited to the current user ie, only the current user's relationships would show.

Has anyone done any work around this?

darkchild

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 2
  • “…more than kisses, letters mingle souls…”- John D
  • CiviCRM version: 4.0.1
  • CMS version: joomla & drupal
  • MySQL version: 5.0.91
  • PHP version: 5.2.14
Re: Limiting Relationship Report to Current User
January 25, 2012, 10:30:13 am
I am not a coder so please be gentle....

I copied Relationship.php and renamed MyRelationship.php

I found some code via LCD here in the forrum and the activity.php file in reports. I added the following code to line 173 after the   relationship type array

Code: [Select]
'current_user' => add option to limit to current user
  array( 'name'      => 'current_user' ,
                                                     'title'     => ts( 'Limit to Current User' ),
'type'         => CRM_Utils_Type::T_INT,
                                      'operatorType' => CRM_Report_Form::OP_SELECT,
                                                     'options'   => array('0'=>'No', '1'=>'Yes')
                                                      ),

I also added the code around line 354
Code: [Select]

if ( $field['name'] == 'current_user' ) {
$currentuseronly = CRM_Utils_Array::value( "{$fieldName}_value", $this->_params );
if ( $currentuseronly == 1 ) {
// get current user
$session =& CRM_Core_Session::singleton( );
if ( $contactID = $session->get( 'contactID' ) ) {
                                $clause = "( contact_b_civireport.id = "   . $contactID .
                                              " OR civicrm_contact_target.id = "   . $contactID . " )";

} else { //if not flagged, ignore filter value
$clause = NULL;
}
}
The 'Limit to current user' filed shows up on the form but getting when trying to put put. the errors seems related to the second patch of code (contact_b_civireport.id )...

I would appreciate any ideas or nudges in the right direction :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Limiting Relationship Report to Current User

This forum was archived on 2017-11-26.