Git Product home page Git Product logo

nz.co.fuzion.relatedpermissions's Introduction

nz.co.fuzion.relatedpermissions

This extension makes the permission flag on a contact's relationship work as a true ACL. In core CiviCRM that flag only allows the user to see the contact's dashboard. However, in many cases it is a useful mechanism to give people permission to view contact records and search for contacts.

Contacts also get 'transitive permissions' - if you give, for example, a secretary permission over an organisation they will have permission over anyone that organisation has permissions over. Transitive permissions go only one step & only where the first contact is a Household or Organisation

Features

  • Ability to set some relationship types to always be permissioned (this doesn't retrospectively change them but does cause save on any relationships to have the permission flag going forwards)

  • Second degree permissions. (If the second degree permissions is checked then on admin/misc screen). For example if you have a organisation called 'Chapter' and it has a permissioned relationship over an organisation called 'branch' then anyone with a permissioned relationship over the chapter will have permissions to access anyone the branch has a permissioned relationship over. There is no theoretical limit to the number of relationshipsbut only organisations and households pass on their permissions. This is because you cannot login as an organisation / household so there is no other purpose served by a household having permission over someone. However, individuals may throw up some more nuances - so for now they are excluded.

Outcomes

When extension is enabled, on any Relationship Type you should now see a new field saying Always Permission A to B (and vv). And at civicrm/admin/setting/misc?reset=1 you should see an option for 'Allow second-degree relationship permissions'

nz.co.fuzion.relatedpermissions's People

Contributors

agileware-dev avatar aydun avatar eileenmcnaughton avatar jackrabbithanna avatar lcdservices avatar mattwire avatar megaphonejon avatar mlutfy avatar seamuslee001 avatar torrance avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nz.co.fuzion.relatedpermissions's Issues

error when trying to install in CiviCRM 5.13

I am trying to get the extension to work in CiviCRM 5.13, but its the same error during install in two different installations:'Integer' is not a valid option for field data_type, which should be a valid option, i guess.
It is located in the upgrader.php on Line 50. I have tried a couple of different expressions like integer or INTEGER with no other results.
Any ideas or hints?

thanks!

Error "relatedpermissions is not a valid option for field custom_group_id" after saving a relationship

Seeing this error in my log.

There seems to be an additional issue with how the error is being handled, but I think this is the key piece.

The error is triggered when saving a new or existing employer for a contact. The relationship does appear to be getting saved, this is getting triggered afterwards.

Apr 30 10:02:00  [error] 
$Fatal Error Details = array:3 [
  "message" => "'relatedpermissions' is not a valid option for field custom_group_id"
  "code" => null
  "exception" => CiviCRM_API3_Exception {#2246
    -extraParams: array:6 [
      "error_field" => "custom_group_id"
      "error_code" => 2001
      "entity" => "CustomField"
      "action" => "get"
      "is_error" => 1
      "error_message" => "'relatedpermissions' is not a valid option for field custom_group_id"
    ]
    #message: "'relatedpermissions' is not a valid option for field custom_group_id"
    #code: 0
    #file: "/var/www/html/sites/all/modules/civicrm/api/api.php"
    #line: 133
    trace: {
      /var/www/html/sites/all/modules/civicrm/api/api.php:133 {
        › if (is_array($result) && !empty($result['is_error'])) {
        ›   throw new CiviCRM_API3_Exception($result['error_message'], CRM_Utils_Array::value('error_code', $result, 'undefined'), $result);
        › }
      }
      /var/www/html/sites/default/civicrm_ext/nz.co.fuzion.relatedpermissions/CRM/Relatedpermissions/Utils/Relatedpermissions.php:34 { …}
      /var/www/html/sites/default/civicrm_ext/nz.co.fuzion.relatedpermissions/CRM/Relatedpermissions/Utils/Relatedpermissions.php:8 { …}
      /var/www/html/sites/default/civicrm_ext/nz.co.fuzion.relatedpermissions/relatedpermissions.php:325 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Utils/Hook.php:283 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Utils/Hook/DrupalBase.php:73 { …}
      /var/www/html/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php:180 { …}
      /var/www/html/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php:214 { …}
      /var/www/html/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php:44 { …}
      /var/www/html/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php:129 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Utils/Hook.php:344 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Contact/BAO/Relationship.php:175 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact/Utils.php:281 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php:210 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php:297 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Contact/Form/Inline/ContactInfo.php:57 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/Form.php:513 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php:152 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php:119 { …}
      /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php:203 { …}
      /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php:103 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/Controller.php:347 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Utils/Wrapper.php:98 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/Page/AJAX.php:63 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:279 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:68 { …}
      /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:36 { …}
      /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module:458 { …}
      /var/www/html/includes/menu.inc:527 { …}
      /var/www/html/index.php:21 { …}
    }
  }
]

incorrectly sets default values on existing relationships

We ran into the following issue:

  • contact exists and has an employer relationship where view/update is selected in both directions
  • related permission extension installed an "none" is set as the default for both directions, for the employer rel type
  • event registration form is created and the profile includes the current employer field is included
  • user completes the registration form. the view/update permissions are lost

The problem is that the related permission extension triggers on the pre hook, and assumes all existing values are included in the parameters. That's not a safe assumption. When the relationship is created via the event registration profile, the existing permission values are not included, and so the default values are getting set -- overriding the existing values.

E Notice Squashing

I'm seeing
Notice: Undefined index: is_permission_a_b in relatedpermissions_civicrm_pre() (line 335 of extensiondir/nz.co.fuzion.relatedpermissions/relatedpermissions.php).

Version 1.8 ->

if (isset($permissionSettings['permission_' . $direction]) && $entityArray['is_permission_' . $direction] == '') {

I'm wondering if this test should be
empty($entityArray['is_permission_' . $direction] == '')
instead of
$entityArray['is_permission_' . $direction] == ''

Currently I've done an isset then check if it's the empty string to replicate current behaviour and prevent the E Notice.

I'm unclear however if this should be setting a default if the entityArray['is_permission_a_b'] or entityArray['is_permission_b_a'] is not set?

Occasional errors creating myrelationship temporary table

We've been using this extension for a while on one client site, and it has worked well. This client has organizations which can relate to primary members who can edit the org, and these orgs also get related to other "facility" organizations, which the primary member should be able to edit. This extension made it possible for the primary members to edit the "facility" org data that is related to the main org record....

When we upgraded their site to 4.7.30, we doing our testing, and we get an error:

DB Error: already exists

Database Error Code: Table 'myrelationships85500' already exists, 1050

So looking at the code line 97 of relatedpermissions.php
$tmpTableName = 'myrelationships' . rand(10000, 100000);

I can see that here occasionally an existing table with a number could exist, and the new table trying to be created could have the same number.

My question is this: how long should these tables exist for?
Does it hurt to flush them out occasionally?
If we do drop them, will new ones be created, and does this really harm the user experience in any way?

Also I'm thinking about just adding some code that checks if the table exists before it tries to create it, and come up with a better way to get a random number/hash...

But I want to do if dropping all the existing tables will "hurt".

Any plans....

... to upgrade this for 4.6.x? Is there any way to influence this by way of donations?

Error when trying to install this extension in CiviCRM 4.6

Good morning,

I'm trying to install this extension in CiviCRM 4.6.31 and I get this error:

Fatal error: Call to undefined method CRM_Core_SelectValues::getPermissionedRelationshipOptions() in C:\Apache24\htdocs\drupal\sites\default\files\civicrm\custom_ext\nz.co.fuzion.relatedpermissions-1.5\CRM\Relatedpermissions\Upgrader.php on line 52

In the github repository I can only see 1.5 and 1.6 releases which are compatible with CiviCRM 5.5 and 5.6 respectively.

Could you please give me a hand with this?
It would be really appreciated!

Warning: Trying to access array offset on value of type null

I'm getting the following error:

Warning: Trying to access array offset on value of type null in relatedpermissions_civicrm_pre() (line 230 of /.../nz.co.fuzion.relatedpermissions/relatedpermissions.php)

I tried adding is_null and is_array on line 230 but neither of these made any difference

Related permissions settings defaults not applying

When we try and add a relationship (manually), once we select a relationship type none of the defaults / overrides apply. They just stay at none. We are on WP 5.3, Civi 5.17.5 and have eliminated as many causes as possible.

We have disabled all Civi extensions except for this one (nz.co.fuzion.relatedpermissions) and disabled all WP plugins except for CiviCRM of course. We are running 2017 WP theme. We have no custom template directory. So we are left with a stripped down Civi.

We saw this behavior when we were testing on our staging. We then decided to try it out on production and the defaults / overrides did apply. Now it has stopped working again, which makes this very strange that it once worked. This is a multisite.

So it looks like this JS file is not getting applied https://github.com/eileenmcnaughton/nz.co.fuzion.relatedpermissions/blob/master/js/set_permissions.js.

Do you have suggestions on debugging further? Has this occurred before?

"Always permission" doesn't work on relations assigned by case [CiviCRM 4.6.8]

Goal: Case manager can edit clients' contact details (relationship: Case Coordinator)

The "always permission" option works when relationships are assigned manually, but not when it's done by CiviCRM itself as the Case Coordinator when a new CiviCase case is created. Simply saving the relationship without any change fixes this, but "resaving" for each new case is far from the ideal state.

Install fails on D9(?)

I was just able to successfully install this on a D7 w/ 5.46alpha. When I tried installing on D9 w/ 5.44, I got the following stacktrace.

When I traced it down, it seems like the issue is with creating the option values from within CustomField.create. The option group and values are created, but not saved to the database due to being in a transaction. When the custom field is created, it fails because the option_group_id references a non-existent record.

I'm reporting it just for other folks to find - I'm going to manually create the fields and move on.

#1 /home/jon/local/mysite/web/sites/all/civicrm-custom/extensions/nz.co.fuzion.relatedpermissions/CRM/Relatedpermissions/Upgrader.php(95): CRM_Relatedpermissions_Upgrader->create_custom_fields()
#2 /home/jon/local/mysite/web/sites/all/civicrm-custom/extensions/nz.co.fuzion.relatedpermissions/CRM/Relatedpermissions/Upgrader/Base.php(306): CRM_Relatedpermissions_Upgrader->install()
#3 /home/jon/local/mysite/web/sites/all/civicrm-custom/extensions/nz.co.fuzion.relatedpermissions/relatedpermissions.civix.php(131): CRM_Relatedpermissions_Upgrader_Base->onInstall()
#4 /home/jon/local/mysite/web/sites/all/civicrm-custom/extensions/nz.co.fuzion.relatedpermissions/relatedpermissions.php(30): _relatedpermissions_civix_civicrm_install()
#5 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Extension/Manager/Module.php(61): relatedpermissions_civicrm_install()
#6 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Extension/Manager/Module.php(33): CRM_Extension_Manager_Module->callHook(Object(CRM_Extension_Info), 'install')
#7 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Extension/Manager.php(293): CRM_Extension_Manager_Module->onPreInstall(Object(CRM_Extension_Info))
#8 /home/jon/local/mysite/vendor/civicrm/civicrm-core/api/v3/Extension.php(42): CRM_Extension_Manager->install(Array)
#9 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_install(Array)
#10 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(149): Civi\API\Provider\MagicFunctionProvider->invoke(Array)
#11 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest(Array)
#12 /home/jon/local/mysite/vendor/civicrm/civicrm-core/api/api.php(22): Civi\API\Kernel->runSafe('Extension', 'install', Array)
#13 phar:///usr/local/bin/cv/src/Command/BaseCommand.php(49): civicrm_api('Extension', 'install', Array)
#14 phar:///usr/local/bin/cv/src/Command/ExtensionEnableCommand.php(91): Civi\Cv\Command\BaseCommand->callApiSuccess(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'Extension', 'install', Array)
#15 phar:///usr/local/bin/cv/vendor/symfony/console/Command/Command.php(257): Civi\Cv\Command\ExtensionEnableCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 phar:///usr/local/bin/cv/vendor/symfony/console/Application.php(850): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 phar:///usr/local/bin/cv/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Civi\Cv\Command\ExtensionEnableCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 phar:///usr/local/bin/cv/src/Application.php(46): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 phar:///usr/local/bin/cv/vendor/symfony/console/Application.php(124): Civi\Cv\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 phar:///usr/local/bin/cv/src/Application.php(15): Symfony\Component\Console\Application->run()
#21 phar:///usr/local/bin/cv/bin/cv(27): Civi\Cv\Application::main('phar:///usr/loc...')
#22 /usr/local/bin/cv(14): require('phar:///usr/loc...')
#23 {main}

Related Permissions conflict with CiviMail

We are running CiviCRM 4.7.10, Drupal 7.50 with CiviHosting on servers tailored to Civi.

With the Related Permissions module enabled we get errors when trying to send mailings with CiviMail. With the extension disabled the mailings work fine. There are several corresponding errors in the logs, two attached.

backtrace.txt
FatalErrorDetails.txt

Why are individuals excluded from second degree relationships

The extension does not want to allow second degree relationships where all 3 contacts A => B => C are individuals

Just wondering if @eileenmcnaughton has any recollection on why this would have been implemented this way? Or was there just a presumption that an Org would be in the mix?

Scenario
Staff > Child > Parent
currently this is not permitted so Staff with a permissioned relationship to the Child cannot then access the Parent's record eg for contact information

Install resulted in missing labels on Relationship Types

Hey there,

Thanks for building this extension. After installing in CiviCRM 5.45.0. The labels seem to be missing on the Relationship permission dialog after installing though.

Selection_002

For what it's worth this is a multilingual install with English (Canada) and French (Canada).

A couple of questions

Hi Eileen, I've got a couple of questions about the extension.

  1. Why the need to create temporary tables?
  2. Are there reasons why this isn't core behaviour? The current permission is nearly useless. Webform loading and updating don't respect it, for example.

Every request creates 4 tables

I installed the extension and I am still struggling to make it work.
Whilst investigating, I noticed that 4 new tables with random names get created with every request (Always a certain contact X trying to view/edit contact Y).

Is this how the extension is supposed to work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.