Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
a55eaf03
Commit
a55eaf03
authored
Dec 16, 2013
by
Rajesh Taneja
Browse files
MDL-43293 Events: Added comments event in modules supporting comments
parent
edd9bb45
Changes
18
Hide whitespace changes
Inline
Side-by-side
blocks/comments/classes/event/comment_created.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* block_comments comment created event.
*
* @package block_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
block_comments\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* block_comments comment created event.
*
* @package block_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_created
extends
\
core\event\comment_created
{
// No need to override any method.
}
blocks/comments/classes/event/comment_deleted.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* block_comments comment deleted event.
*
* @package block_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
block_comments\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* block_comments comment deleted event.
*
* @package block_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_deleted
extends
\
core\event\comment_deleted
{
// No need to override any method.
}
comment/lib.php
View file @
a55eaf03
...
...
@@ -652,7 +652,11 @@ class comment {
$newcmt
->
time
=
userdate
(
$newcmt
->
timecreated
,
$newcmt
->
strftimeformat
);
// Trigger comment created event.
$eventclassname
=
'\\'
.
$this
->
component
.
'\\event\comment_created'
;
if
(
core_component
::
is_core_subsystem
(
$this
->
component
))
{
$eventclassname
=
'\\core\\event\\'
.
$this
->
component
.
'_comment_created'
;
}
else
{
$eventclassname
=
'\\'
.
$this
->
component
.
'\\event\comment_created'
;
}
if
(
class_exists
(
$eventclassname
))
{
$event
=
$eventclassname
::
create
(
array
(
...
...
@@ -724,7 +728,11 @@ class comment {
}
$DB
->
delete_records
(
'comments'
,
array
(
'id'
=>
$commentid
));
// Trigger comment delete event.
$eventclassname
=
'\\'
.
$this
->
component
.
'\\event\comment_deleted'
;
if
(
core_component
::
is_core_subsystem
(
$this
->
component
))
{
$eventclassname
=
'\\core\\event\\'
.
$this
->
component
.
'_comment_deleted'
;
}
else
{
$eventclassname
=
'\\'
.
$this
->
component
.
'\\event\comment_deleted'
;
}
if
(
class_exists
(
$eventclassname
))
{
$event
=
$eventclassname
::
create
(
array
(
...
...
lib/classes/component.php
View file @
a55eaf03
...
...
@@ -1013,4 +1013,14 @@ $cache = '.var_export($cache, true).';
opcache_invalidate
(
$file
,
true
);
}
}
/**
* Return true if subsystemname is core subsystem.
*
* @param string $subsystemname name of the subsystem.
* @return bool true if core subsystem.
*/
public
static
function
is_core_subsystem
(
$subsystemname
)
{
return
isset
(
self
::
$subsystems
[
$subsystemname
]);
}
}
lib/classes/event/blog_comment_created.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* blog comment created event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
core\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* blog comment created event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
blog_comment_created
extends
\
core\event\comment_created
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/blog/index.php'
,
array
(
'entryid'
=>
$this
->
other
[
'itemid'
]));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' added comment for blog with id '
.
$this
->
other
[
'itemid'
];
}
}
lib/classes/event/blog_comment_deleted.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* blog comment deleted event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
core\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* blog comment deleted event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
blog_comment_deleted
extends
\
core\event\comment_deleted
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/blog/index.php'
,
array
(
'entryid'
=>
$this
->
other
[
'itemid'
]));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' deleted comment for blog with id '
.
$this
->
other
[
'itemid'
];
}
}
lib/classes/event/comment_created.php
View file @
a55eaf03
...
...
@@ -63,10 +63,19 @@ abstract class comment_created extends \core\event\base {
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' added comment for '
.
$this
->
component
.
' with instance id '
.
return
'User with id '
.
$this
->
userid
.
' added comment for '
.
$this
->
component
.
' with instance id '
.
$this
->
contextinstanceid
;
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
$this
->
context
->
get_url
();
}
/**
* Custom validation.
*
...
...
lib/classes/event/comment_deleted.php
View file @
a55eaf03
...
...
@@ -63,10 +63,19 @@ abstract class comment_deleted extends \core\event\base {
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' deleted comment for '
.
$this
->
component
.
' with instance id '
.
return
'User with id '
.
$this
->
userid
.
' deleted comment for '
.
$this
->
component
.
' with instance id '
.
$this
->
contextinstanceid
;
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
$this
->
context
->
get_url
();
}
/**
* Custom validation.
*
...
...
lib/classes/event/comments_viewed.php
View file @
a55eaf03
...
...
@@ -65,4 +65,13 @@ abstract class comments_viewed extends \core\event\base {
return
'User with id '
.
$this
->
userid
.
' viewed comments for '
.
$this
->
component
.
' with instance id '
.
$this
->
objectid
;
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
$this
->
context
->
get_url
();
}
}
mod/assign/submission/comments/classes/event/comment_created.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* assignsubmission_comments comment created event.
*
* @package assignsubmission_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
assignsubmission_comments\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* assignsubmission_comments comment created event.
*
* @package assignsubmission_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_created
extends
\
core\event\comment_created
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/assign/view.php'
,
array
(
'id'
=>
$this
->
contextinstanceid
));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' added comment for assignment submission with id '
.
$this
->
other
[
'itemid'
];
}
}
mod/assign/submission/comments/classes/event/comment_deleted.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* assignsubmission_comments comment deleted event.
*
* @package assignsubmission_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
assignsubmission_comments\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* assignsubmission_comments comment deleted event.
*
* @package assignsubmission_comments
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_deleted
extends
\
core\event\comment_deleted
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/assign/view.php'
,
array
(
'id'
=>
$this
->
contextinstanceid
));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' deleted comment for assignment submission with id '
.
$this
->
other
[
'itemid'
];
}
}
mod/data/classes/event/comment_created.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_data comment created event.
*
* @package mod_data
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
mod_data\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* mod_data comment created event.
*
* @package mod_data
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_created
extends
\
core\event\comment_created
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/data/view.php'
,
array
(
'id'
=>
$this
->
other
[
'itemid'
]));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' added comment for database activity with id '
.
$this
->
other
[
'itemid'
];
}
}
mod/data/classes/event/comment_deleted.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_data comment deleted event.
*
* @package mod_data
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
mod_data\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* mod_data comment deleted event.
*
* @package mod_data
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_deleted
extends
\
core\event\comment_deleted
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/data/view.php'
,
array
(
'id'
=>
$this
->
other
[
'itemid'
]));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' deleted comment for database activity with id '
.
$this
->
other
[
'itemid'
];
}
}
mod/glossary/classes/event/comment_created.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_glossary comment created event.
*
* @package mod_glossary
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
mod_glossary\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* mod_glossary comment created event.
*
* @package mod_glossary
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_created
extends
\
core\event\comment_created
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/glossary/view.php'
,
array
(
'id'
=>
$this
->
other
[
'itemid'
]));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' added comment for glossary activity with id '
.
$this
->
other
[
'itemid'
];
}
}
mod/glossary/classes/event/comment_deleted.php
0 → 100644
View file @
a55eaf03
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_glossary comment deleted event.
*
* @package mod_glossary
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
mod_glossary\event
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* mod_glossary comment deleted event.
*
* @package mod_glossary
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
comment_deleted
extends
\
core\event\comment_deleted
{
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public
function
get_url
()
{
return
new
\
moodle_url
(
'/mod/glossary/view.php'
,
array
(
'id'
=>
$this
->
other
[
'itemid'
]));
}
/**
* Returns description of what happened.
*
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' deleted comment for glossary activity with id '
.
$this
->
other
[
'itemid'
];
}
}
mod/wiki/classes/event/comment_created.php
View file @
a55eaf03
...
...
@@ -49,7 +49,6 @@ class comment_created extends \core\event\comment_created {
* @return string
*/
public
function
get_description
()
{
return
'User with id '
.
$this
->
userid
.
' added comment for '
.
$this
->
component
.
' with page id '
.
$this
->
other
[
'itemid'