mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'w13_MDL-44107_m27_canview' of git://github.com/skodak/moodle
This commit is contained in:
commit
daf7b64ef7
5 changed files with 24 additions and 1 deletions
|
@ -304,12 +304,18 @@ abstract class base implements \IteratorAggregate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define whether a user can view the event or not.
|
* This method was originally intended for granular
|
||||||
|
* access control on the event level, unfortunately
|
||||||
|
* the proper implementation would be too expensive
|
||||||
|
* in many cases.
|
||||||
|
*
|
||||||
|
* @deprecated since 2.7
|
||||||
*
|
*
|
||||||
* @param int|\stdClass $user_or_id ID of the user.
|
* @param int|\stdClass $user_or_id ID of the user.
|
||||||
* @return bool True if the user can view the event, false otherwise.
|
* @return bool True if the user can view the event, false otherwise.
|
||||||
*/
|
*/
|
||||||
public function can_view($user_or_id = null) {
|
public function can_view($user_or_id = null) {
|
||||||
|
debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER);
|
||||||
return is_siteadmin($user_or_id);
|
return is_siteadmin($user_or_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,14 @@ class course_module_viewed extends \core\event\course_module_viewed {
|
||||||
/**
|
/**
|
||||||
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
|
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
|
||||||
*
|
*
|
||||||
|
* @deprecated since 2.7
|
||||||
|
*
|
||||||
* @param int|\stdClass $userorid ID of the user.
|
* @param int|\stdClass $userorid ID of the user.
|
||||||
* @return bool True if the user can view the event, false otherwise.
|
* @return bool True if the user can view the event, false otherwise.
|
||||||
*/
|
*/
|
||||||
public function can_view($userorid = null) {
|
public function can_view($userorid = null) {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
if (empty($userorid)) {
|
if (empty($userorid)) {
|
||||||
$userorid = $USER;
|
$userorid = $USER;
|
||||||
|
|
|
@ -84,11 +84,14 @@ class response_deleted extends \core\event\base {
|
||||||
/**
|
/**
|
||||||
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
|
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
|
||||||
*
|
*
|
||||||
|
* @deprecated since 2.7
|
||||||
|
*
|
||||||
* @param int|\stdClass $userorid ID of the user.
|
* @param int|\stdClass $userorid ID of the user.
|
||||||
* @return bool True if the user can view the event, false otherwise.
|
* @return bool True if the user can view the event, false otherwise.
|
||||||
*/
|
*/
|
||||||
public function can_view($userorid = null) {
|
public function can_view($userorid = null) {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
if (empty($userorid)) {
|
if (empty($userorid)) {
|
||||||
$userorid = $USER;
|
$userorid = $USER;
|
||||||
|
|
|
@ -106,11 +106,14 @@ class response_submitted extends \core\event\base {
|
||||||
/**
|
/**
|
||||||
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
|
* Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response.
|
||||||
*
|
*
|
||||||
|
* @deprecated since 2.7
|
||||||
|
*
|
||||||
* @param int|\stdClass $userorid ID of the user.
|
* @param int|\stdClass $userorid ID of the user.
|
||||||
* @return bool True if the user can view the event, false otherwise.
|
* @return bool True if the user can view the event, false otherwise.
|
||||||
*/
|
*/
|
||||||
public function can_view($userorid = null) {
|
public function can_view($userorid = null) {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
if (empty($userorid)) {
|
if (empty($userorid)) {
|
||||||
$userorid = $USER;
|
$userorid = $USER;
|
||||||
|
|
|
@ -135,8 +135,10 @@ class mod_feedback_events_testcase extends advanced_testcase {
|
||||||
// Test can_view() .
|
// Test can_view() .
|
||||||
$this->setUser($this->eventuser);
|
$this->setUser($this->eventuser);
|
||||||
$this->assertFalse($event->can_view());
|
$this->assertFalse($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
$this->setAdminUser();
|
$this->setAdminUser();
|
||||||
$this->assertTrue($event->can_view());
|
$this->assertTrue($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
|
|
||||||
// Create a response, with anonymous set to no and test can_view().
|
// Create a response, with anonymous set to no and test can_view().
|
||||||
$response = new stdClass();
|
$response = new stdClass();
|
||||||
|
@ -162,8 +164,10 @@ class mod_feedback_events_testcase extends advanced_testcase {
|
||||||
// Test can_view() .
|
// Test can_view() .
|
||||||
$this->setUser($this->eventuser);
|
$this->setUser($this->eventuser);
|
||||||
$this->assertTrue($event->can_view());
|
$this->assertTrue($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
$this->setAdminUser();
|
$this->setAdminUser();
|
||||||
$this->assertTrue($event->can_view());
|
$this->assertTrue($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
$this->assertEventContextNotUsed($event);
|
$this->assertEventContextNotUsed($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,8 +232,10 @@ class mod_feedback_events_testcase extends advanced_testcase {
|
||||||
$this->assertEquals(FEEDBACK_ANONYMOUS_YES, $event->other['anonymous']);
|
$this->assertEquals(FEEDBACK_ANONYMOUS_YES, $event->other['anonymous']);
|
||||||
$this->setUser($this->eventuser);
|
$this->setUser($this->eventuser);
|
||||||
$this->assertFalse($event->can_view());
|
$this->assertFalse($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
$this->setAdminUser();
|
$this->setAdminUser();
|
||||||
$this->assertTrue($event->can_view());
|
$this->assertTrue($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
|
|
||||||
// Test legacy data.
|
// Test legacy data.
|
||||||
$this->assertEventLegacyLogData(null, $event);
|
$this->assertEventLegacyLogData(null, $event);
|
||||||
|
@ -262,8 +268,10 @@ class mod_feedback_events_testcase extends advanced_testcase {
|
||||||
|
|
||||||
// Test can_view().
|
// Test can_view().
|
||||||
$this->assertTrue($event->can_view());
|
$this->assertTrue($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
$this->setAdminUser();
|
$this->setAdminUser();
|
||||||
$this->assertTrue($event->can_view());
|
$this->assertTrue($event->can_view());
|
||||||
|
$this->assertDebuggingCalled();
|
||||||
$this->assertEventContextNotUsed($event);
|
$this->assertEventContextNotUsed($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue