-
Notifications
You must be signed in to change notification settings - Fork 42
Add permissions to access transactions and transaction batches #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| for ($i=$week_count; $i>=0; $i--) | ||
| $weeks[] = date('YW', strtotime("now -$i weeks")); | ||
|
|
||
| // Migration to APIv4 would require YEARWEEK as \Civi\Api4\Query\SqlFunction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can EXTRACT() be used to replace YEARWEEK()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracting year and week using EXTRACT() doesn't always lead to the same results, e.g.:
SELECT CONCAT(EXTRACT(YEAR FROM '2000-01-01'), EXTRACT(WEEK FROM '2000-01-01'));results in 20000.
SELECT YEARWEEK('2000-01-01', 3);resutls in 202001.
The year can differ in some cases, too:
The year in the result may be different from the year in the date argument for the first and the last week of the year.
| ['value_date', '>=', date('Y-01-01 00:00:00')], | ||
| ['value_date', '<', date('Y-01-0100:00:00', strtotime('+1 year'))], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is strtotime('+1 year') (or -1 year below) guaranteed to always work correctly regardless of leap years, leap seconds, timezones, DST and date/time of script execution?
Considering the old code did the same, this might be irrelevant here, but got me wondering …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like PHP doesn't handle leap seconds....
php > echo date('Y-m-d H:i:s', strtotime('2016-12-31 23:59:60'));
2017-01-01 00:00:00
php > echo date('Y-m-d H:i:s', strtotime('2016-12-31 23:59:60 +1 year'));
2018-01-01 00:00:00
php > echo date('Y-m-d H:i:s', strtotime('2016-12-31 23:59:60 -1 year'));
2016-01-01 00:00:00Otherwise I couldn't imagine any issues here.
| if (is_array($value)) { | ||
| $where[] = [$fieldName, 'IN', $value]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIv3 encodes all other operators as arrays, e.g. 'id' => ['BETWEEN' => [1, 100]] or even 'id' => ['IS NULL' => 1] so this will change operators and values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we could make use of hook_civicrm_selectWhereClause and then wouldn't need this code at all.
|
@dontub Could you resolve the conflicts with the current master? |
e92de14 to
02b85ac
Compare
Restrictions are applied by the field
domainwhich is added toBankTransactionandBankTransactionGroups. Possible domains are specified by an option group. For each domain a CiviCRM permission is created which gives access to transactions and transaction groups with that domain. On import the domain can be specified. (Specifying a domain can be enforced optionally.) The previous behavior should not be changed, i.e. users that currently can access all transactions will still have access to all transactions.WHEREclose is adapted.systopia-reference: 25700