26 Commits

Author SHA1 Message Date
Sara Arjona
edbee4c4b6 MDL-62266 core_availability: Implement privacy API 2018-04-30 11:20:16 +02:00
Mark Nelson
b75ff47441 MDL-55548 backup: changes after review
1) There is no need to store the 'timemodified' value of
the section when backing up a course module, they do
not refer to the same time.
2) When creating a new course section during restore use
the current time.
3) Added timemodified value to more places when updating
the 'course_sections' table.
2017-06-12 15:52:54 +08:00
Jakob
6a36b8526e MDL-37765 course: Add capability to ignore availability restrictions.
Allow a role to view activities without addressing the restriction rules.
2017-03-27 08:37:27 -07:00
David Mudrák
93f4f3494a MDL-53481 availability: Fix uniqueness of SQL named param placeholders
Static variables do not behave the way you might expect when accessing
them through the classes inheritance. When accessing a method via self::
or static:: operators, even though the method is inherited, its variable
scope is not. So the method unique_sql_parameter() was using the scope
of the child class and each child class had its own sequence of usp1,
usp2, usp3, ... placeholders. This led to "Incorrect number of query
parameters" error when multiuple condition classes were contributing to
a single SQL query.

All credit should go to Adam Olley who debugged and described the
essence of the problem in the tracker.
2016-11-08 13:36:07 +01:00
sam marshall
07bb79b451 MDL-51652 Availability: OR conditions fail when filtering user lists
When filtering a user list, if there is an OR tree where one of the
conditions does not restrict user lists such as a date condition,
then the overall result should include all users (not be filtered).
This was not working correctly.
2015-10-12 10:23:54 +01:00
Dan Poltawski
6a51993e9f MDL-49434 availability: more bad whitespace 2015-07-22 23:58:12 +01:00
Dan Poltawski
e870b10343 MDL-49434 availability: fix trailing whitespace 2015-07-22 23:49:52 +01:00
sam marshall
c7b738546c MDL-49434 availability: Use renderables for multiple messages
Co-Authored-By: Andrew Nicols <andrew@nicols.co.uk>
2015-07-15 11:43:01 +01:00
Matt Sammarco
5ef6f97f47 MDL-18177 availability: Excluding group members availability info
If setting was not enabled when backing up, exclude the availability
information of group members.
2015-02-20 11:45:22 +11:00
sam marshall
6b40e5b2ec MDL-48660 Availability: filter_user_list() should respect 'view hidden'
Updated filter_user_list and get_user_list_sql to account for
the viewhiddenactivities and viewhiddensections capabilities.
2015-01-27 10:59:05 +00:00
PJ King
c8c746c440 MDL-46671 availability: DEBUG when course_module does not exist.
There was a fatal error when calendar event linked to non-extant activities.

Now, instead of throwing an exception when a course_module does not exist, is_user_visible() will print a debug statement.
2015-01-02 10:34:16 -05:00
sam marshall
c0d92241f1 MDL-47564 Availability: incorrect use of defined('PHP_UNIT') 2014-10-07 14:47:29 +01:00
sam marshall
06c0603825 MDL-47322 Availability: empty availability should be saved as null
As part of the unit test modifications for this change, I added the get_json
function to the availability conditions that didn't have it. (This is a function
for use in unit tests.)
2014-09-26 15:42:37 +01:00
sam marshall
5176504d3f MDL-46991 Availability: Conditional dates not updated on restore 2014-09-18 16:37:53 +01:00
Adam Olley
0151ca2b91 MDL-47208 core_availability: Return false when cm isnt in modinfo list
If a cm isn't in modinfo's cm list, then the user shouldn't be able to see that cm.
This fixes an issue where hidden activities would cause users to be unable to use moodle.
2014-09-12 09:14:56 +09:30
Marina Glancy
3b4db5bdf5 MDL-44725 dml: added sql_intersect() 2014-09-03 13:33:58 +08:00
sam marshall
1a7049af22 MDL-44725 Availability: Add SQL feature for user lists (11)
The previous API included a facility to filter a list of users
to include only those who are allowed to access an activity, i.e.
only people who belong to the required groups etc.

This change adds a new API function to return SQL that obtains
this list of users, so that it can be combined with other
queries.
2014-09-02 13:03:29 +01:00
sam marshall
f9103882dc MDL-44725 Availability: Add utility API to make unit testing easier (7)
Previously there was no way in PHP to create the JSON values used for
availability, except by manually hard-coding them (the main code to
do this normally is in JavaScript).

This makes unit tests hard to read, so I have implemented static
functions tree::get_root_json and tree::get_nested_json which allow
for easier-to-read unit tests.
2014-09-02 13:03:19 +01:00
sam marshall
3d962d49cb MDL-44725 Availability: Replace groupmembersonly - core_availability (2)
Remove groupmembersonly usage in the core_availability API, and change
the update code (used in backup) so that it considers groupmembersonly
when restoring old backups.
2014-09-02 13:03:09 +01:00
Nadav Kavalerchik
51f2398ce7 MDL-46450 availability/info: Add links to module names inside restrict access availabilityinfo box 2014-08-24 23:39:20 +03:00
Ankit Agarwal
5cad8d353d MDL-45543 availability: Use correct namespace for global classes 2014-05-14 15:31:08 +08:00
Dan Poltawski
af80f7b4a5 Merge branch 'MDL-45027-master' of https://github.com/sammarshallou/moodle
Conflicts:
	availability/yui/build/moodle-core_availability-form/moodle-core_availability-form-min.js
2014-04-18 10:23:45 +08:00
sam marshall
2a848ab9e2 MDL-45027 Availability API: Better handling of invalid data in GUI
If there is invalid data in the availability condition (note: this
should not happen, but can do in unusual situations, such as
specifying a date after 2038 in 32-bit PHP), this should not
leave the course so broken that users cannot edit the activity and
update it.
2014-04-11 10:57:15 +01:00
Marina Glancy
58d113934d MDL-45038 modinfo: added property section_info::modinfo 2014-04-10 20:26:25 +08:00
sam marshall
e01efa2cfd MDL-44070 Conditional availability enhancements (3): conditions
Includes all the conditions that were in previous Moodle versions:

* Date
* Grade
* Completion (of another activity)
* User profile field

Also includes conditions that are used to reimplement
groupmembersonly:

* Grouping
* Group

For each condition, the component plus unit tests are included.

PLEASE NOTE: The code to actually check each condition is reused
from previous Moodle versions and has not been modified except to
pass codechecker. This is intentional, to reduce the risk of the
change and maximise the chance that behaviour is preserved. Some
of this code might not be very good and might need updating but
that can happen separately.

AMOS BEGIN
 CPY [contains,core_condition],[op_contains,availability_profile]
 CPY [doesnotcontain,core_condition],[op_doesnotcontain,availability_profile]
 CPY [endswith,core_condition],[op_endswith,availability_profile]
 CPY [isempty,core_condition],[op_isempty,availability_profile]
 CPY [isequalto,core_condition],[op_isequalto,availability_profile]
 CPY [isnotempty,core_condition],[op_isnotempty,availability_profile]
 CPY [startswith,core_condition],[op_startswith,availability_profile]
 CPY [completion_fail,core_condition],[option_fail,availability_completion]
 CPY [completion_pass,core_condition],[option_pass,availability_completion]
 CPY [completion_complete,core_condition],[option_complete,availability_completion]
 CPY [completion_incomplete,core_condition],[option_incomplete,availability_completion]
AMOS END
2014-04-07 20:11:37 +01:00
sam marshall
d3db4b037c MDL-44070 Conditional availability enhancements (2): subsystem, API
This commit defines the new /availability root folder, with
/availability/classes, /availability/tests, and
/availability/condition where the condition plugins will live.
Condition plugin prefix is availability_, e.g. availability_date.

Rationale for this organisation:

1. I was originally going to put this in /lib/availability but
   it has been pointed out that putting even more junk in lib
   is probably bad.
2. 'availability' and 'condition' are the two names used in code
   to refer to this system ($CFG->enableavailability).
3. The prefix has to be short enough to allow database tables
   (although in practice I assume that condition plugins will not
   normally contain database tables).

The new API includes a Boolean tree structure that controls the
availability of an item.

AMOS BEGIN
 CPY [availabilityconditions,core_condition],[restrictaccess,core_availability]
 CPY [enableavailability,core_condition],[enableavailability,core_availability]
 CPY [configenableavailability,core_condition],[enableavailability_desc,core_availability]
AMOS END
2014-04-07 20:11:33 +01:00