MDL-48012 tool_recyclebin: converted to an admin tool
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
# - 5.6
|
||||
# - 7.0
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_27_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_28_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_29_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
|
||||
- DB=mysqli MOODLE_BRANCH=MOODLE_27_STABLE
|
||||
- DB=mysqli MOODLE_BRANCH=MOODLE_28_STABLE
|
||||
- DB=mysqli MOODLE_BRANCH=MOODLE_29_STABLE
|
||||
- DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
|
||||
|
||||
before_install:
|
||||
- cd ../..
|
||||
- composer selfupdate
|
||||
- composer create-project -n --no-dev moodlerooms/moodle-plugin-ci ci ^1
|
||||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
|
||||
|
||||
install:
|
||||
- moodle-plugin-ci install
|
||||
- sed -i.bak "s/\/\/ Get the module context./\\\\local_recyclebin\\\\observer::pre_cm_delete(\$cm);/g" /home/travis/build/moodle/course/lib.php
|
||||
- sed -i.bak "s/\/\/ Make the course completely empty./\\\\local_recyclebin\\\\observer::pre_course_delete(\$course);/g" /home/travis/build/moodle/lib/moodlelib.php
|
||||
|
||||
script:
|
||||
- moodle-plugin-ci phplint
|
||||
- moodle-plugin-ci phpcpd
|
||||
# - moodle-plugin-ci phpmd
|
||||
- moodle-plugin-ci codechecker
|
||||
# - moodle-plugin-ci csslint
|
||||
# - moodle-plugin-ci shifter
|
||||
# - moodle-plugin-ci jshint
|
||||
- moodle-plugin-ci phpunit
|
||||
# - moodle-plugin-ci behat
|
||||
@@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# Moodle Recycle Bin [](https://travis-ci.org/unikent/moodle-local_recyclebin)
|
||||
This plugin adds a "recycle bin" for course modules to Moodle.
|
||||
It requires a core hack.
|
||||
|
||||
See plugin pages here: https://moodle.org/plugins/view/local_recyclebin
|
||||
|
||||
See documentation here: https://docs.moodle.org/29/en/local/Recycle_bin
|
||||
|
||||
## Installation - course recyclebin
|
||||
As there is no "pre-cm-deleted" event, you will need to add a line to '/course/lib.php' (function course_delete_module), right after the first "if()".
|
||||
```
|
||||
diff --git a/course/lib.php b/course/lib.php
|
||||
index e49bdf1..5f8d6e6 100644
|
||||
--- a/course/lib.php
|
||||
+++ b/course/lib.php
|
||||
@@ -1654,6 +1654,9 @@ function course_delete_module($cmid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Notify the recycle bin plugin.
|
||||
+ \local_recyclebin\observer::pre_cm_delete($cm);
|
||||
+
|
||||
// Get the module context.
|
||||
$modcontext = context_module::instance($cm->id);
|
||||
|
||||
```
|
||||
|
||||
## Installation - category recyclebin
|
||||
As there is no "pre-course-deleted" event, you will need to add a line to '/lib/moodlelib.php' (function delete_course), right after the second "if()".
|
||||
```
|
||||
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
|
||||
index 456d0f1..aeb0853 100644
|
||||
--- a/lib/moodlelib.php
|
||||
+++ b/lib/moodlelib.php
|
||||
@@ -4683,6 +4683,9 @@ function delete_course($courseorid, $showfeedback = true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Notify the recycle bin plugin.
|
||||
+ \local_recyclebin\observer::pre_course_delete($course);
|
||||
+
|
||||
// Make the course completely empty.
|
||||
remove_course_contents($courseid, $showfeedback);
|
||||
|
||||
```
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* The main interface for recycle bin methods.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin;
|
||||
namespace tool_recyclebin;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Represents a category's recyclebin.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ class category extends recyclebin
|
||||
* Is this recyclebin enabled?
|
||||
*/
|
||||
public static function is_enabled() {
|
||||
return get_config('local_recyclebin', 'enablecategory');
|
||||
return get_config('tool_recyclebin', 'enablecategory');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ class category extends recyclebin
|
||||
public function get_item($itemid) {
|
||||
global $DB;
|
||||
|
||||
$item = $DB->get_record('local_recyclebin_category', array(
|
||||
$item = $DB->get_record('tool_recyclebin_category', array(
|
||||
'id' => $itemid
|
||||
), '*', MUST_EXIST);
|
||||
|
||||
@@ -76,7 +76,7 @@ class category extends recyclebin
|
||||
public function get_items() {
|
||||
global $DB;
|
||||
|
||||
$items = $DB->get_records('local_recyclebin_category', array(
|
||||
$items = $DB->get_records('tool_recyclebin_category', array(
|
||||
'category' => $this->_categoryid
|
||||
));
|
||||
|
||||
@@ -131,7 +131,7 @@ class category extends recyclebin
|
||||
}
|
||||
|
||||
// Record the activity, get an ID.
|
||||
$binid = $DB->insert_record('local_recyclebin_category', array(
|
||||
$binid = $DB->insert_record('tool_recyclebin_category', array(
|
||||
'category' => $course->category,
|
||||
'shortname' => $course->shortname,
|
||||
'fullname' => $course->fullname,
|
||||
@@ -141,7 +141,7 @@ class category extends recyclebin
|
||||
// Move the file to our own special little place.
|
||||
if (!$file->copy_content_to($bindir . '/course-' . $binid)) {
|
||||
// Failed, cleanup first.
|
||||
$DB->delete_records('local_recyclebin_category', array(
|
||||
$DB->delete_records('tool_recyclebin_category', array(
|
||||
'id' => $binid
|
||||
));
|
||||
|
||||
@@ -152,7 +152,7 @@ class category extends recyclebin
|
||||
$file->delete();
|
||||
|
||||
// Fire event.
|
||||
$event = \local_recyclebin\event\course_stored::create(array(
|
||||
$event = \tool_recyclebin\event\course_stored::create(array(
|
||||
'objectid' => $binid,
|
||||
'context' => \context_coursecat::instance($course->category)
|
||||
));
|
||||
@@ -235,11 +235,11 @@ class category extends recyclebin
|
||||
$controller->execute_plan();
|
||||
|
||||
// Fire event.
|
||||
$event = \local_recyclebin\event\course_restored::create(array(
|
||||
$event = \tool_recyclebin\event\course_restored::create(array(
|
||||
'objectid' => $item->id,
|
||||
'context' => $context
|
||||
));
|
||||
$event->add_record_snapshot('local_recyclebin_category', $item);
|
||||
$event->add_record_snapshot('tool_recyclebin_category', $item);
|
||||
$event->trigger();
|
||||
|
||||
// Cleanup.
|
||||
@@ -260,7 +260,7 @@ class category extends recyclebin
|
||||
unlink($CFG->dataroot . '/recyclebin/course-' . $item->id);
|
||||
|
||||
// Delete the record.
|
||||
$DB->delete_records('local_recyclebin_category', array(
|
||||
$DB->delete_records('tool_recyclebin_category', array(
|
||||
'id' => $item->id
|
||||
));
|
||||
|
||||
@@ -269,11 +269,11 @@ class category extends recyclebin
|
||||
}
|
||||
|
||||
// Fire event.
|
||||
$event = \local_recyclebin\event\course_purged::create(array(
|
||||
$event = \tool_recyclebin\event\course_purged::create(array(
|
||||
'objectid' => $item->id,
|
||||
'context' => \context_coursecat::instance($item->category)
|
||||
));
|
||||
$event->add_record_snapshot('local_recyclebin_category', $item);
|
||||
$event->add_record_snapshot('tool_recyclebin_category', $item);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ class category extends recyclebin
|
||||
*/
|
||||
public function can_view($item) {
|
||||
$context = \context_coursecat::instance($item->category);
|
||||
return has_capability('local/recyclebin:view_course', $context);
|
||||
return has_capability('tool/recyclebin:view_course', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +294,7 @@ class category extends recyclebin
|
||||
*/
|
||||
public function can_restore($item) {
|
||||
$context = \context_coursecat::instance($item->category);
|
||||
return has_capability('local/recyclebin:restore_course', $context);
|
||||
return has_capability('tool/recyclebin:restore_course', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,6 +304,6 @@ class category extends recyclebin
|
||||
*/
|
||||
public function can_delete($item) {
|
||||
$context = \context_coursecat::instance($item->category);
|
||||
return has_capability('local/recyclebin:delete_course', $context);
|
||||
return has_capability('tool/recyclebin:delete_course', $context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* The main interface for recycle bin methods.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin;
|
||||
namespace tool_recyclebin;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Represents a course's recyclebin.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ class course extends recyclebin
|
||||
* Is this recyclebin enabled?
|
||||
*/
|
||||
public static function is_enabled() {
|
||||
return get_config('local_recyclebin', 'enablecourse');
|
||||
return get_config('tool_recyclebin', 'enablecourse');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ class course extends recyclebin
|
||||
public function get_item($itemid) {
|
||||
global $DB;
|
||||
|
||||
return $DB->get_record('local_recyclebin_course', array(
|
||||
return $DB->get_record('tool_recyclebin_course', array(
|
||||
'id' => $itemid
|
||||
), '*', MUST_EXIST);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class course extends recyclebin
|
||||
public function get_items() {
|
||||
global $DB;
|
||||
|
||||
return $DB->get_records('local_recyclebin_course', array(
|
||||
return $DB->get_records('tool_recyclebin_course', array(
|
||||
'course' => $this->_courseid
|
||||
));
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class course extends recyclebin
|
||||
}
|
||||
|
||||
// Record the activity, get an ID.
|
||||
$binid = $DB->insert_record('local_recyclebin_course', array(
|
||||
$binid = $DB->insert_record('tool_recyclebin_course', array(
|
||||
'course' => $cm->course,
|
||||
'section' => $cm->section,
|
||||
'module' => $cm->module,
|
||||
@@ -141,7 +141,7 @@ class course extends recyclebin
|
||||
// Move the file to our own special little place.
|
||||
if (!$file->copy_content_to($bindir . '/' . $binid)) {
|
||||
// Failed, cleanup first.
|
||||
$DB->delete_records('local_recyclebin_course', array(
|
||||
$DB->delete_records('tool_recyclebin_course', array(
|
||||
'id' => $binid
|
||||
));
|
||||
|
||||
@@ -152,7 +152,7 @@ class course extends recyclebin
|
||||
$file->delete();
|
||||
|
||||
// Fire event.
|
||||
$event = \local_recyclebin\event\item_stored::create(array(
|
||||
$event = \tool_recyclebin\event\item_stored::create(array(
|
||||
'objectid' => $binid,
|
||||
'context' => \context_course::instance($cm->course)
|
||||
));
|
||||
@@ -219,11 +219,11 @@ class course extends recyclebin
|
||||
$controller->execute_plan();
|
||||
|
||||
// Fire event.
|
||||
$event = \local_recyclebin\event\item_restored::create(array(
|
||||
$event = \tool_recyclebin\event\item_restored::create(array(
|
||||
'objectid' => $item->id,
|
||||
'context' => $context
|
||||
));
|
||||
$event->add_record_snapshot('local_recyclebin_course', $item);
|
||||
$event->add_record_snapshot('tool_recyclebin_course', $item);
|
||||
$event->trigger();
|
||||
|
||||
// Cleanup.
|
||||
@@ -244,7 +244,7 @@ class course extends recyclebin
|
||||
unlink($CFG->dataroot . '/recyclebin/' . $item->id);
|
||||
|
||||
// Delete the record.
|
||||
$DB->delete_records('local_recyclebin_course', array(
|
||||
$DB->delete_records('tool_recyclebin_course', array(
|
||||
'id' => $item->id
|
||||
));
|
||||
|
||||
@@ -260,11 +260,11 @@ class course extends recyclebin
|
||||
}
|
||||
|
||||
// Fire event.
|
||||
$event = \local_recyclebin\event\item_purged::create(array(
|
||||
$event = \tool_recyclebin\event\item_purged::create(array(
|
||||
'objectid' => $item->id,
|
||||
'context' => $context
|
||||
));
|
||||
$event->add_record_snapshot('local_recyclebin_course', $item);
|
||||
$event->add_record_snapshot('tool_recyclebin_course', $item);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ class course extends recyclebin
|
||||
*/
|
||||
public function can_view($item) {
|
||||
$context = \context_course::instance($item->course);
|
||||
return has_capability('local/recyclebin:view_item', $context);
|
||||
return has_capability('tool/recyclebin:view_item', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,7 +285,7 @@ class course extends recyclebin
|
||||
*/
|
||||
public function can_restore($item) {
|
||||
$context = \context_course::instance($item->course);
|
||||
return has_capability('local/recyclebin:restore_item', $context);
|
||||
return has_capability('tool/recyclebin:restore_item', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,18 +297,18 @@ class course extends recyclebin
|
||||
$context = \context_course::instance($item->course);
|
||||
|
||||
// Basic check - do we have the first require capability?
|
||||
if (!has_capability('local/recyclebin:delete_item', $context)) {
|
||||
if (!has_capability('tool/recyclebin:delete_item', $context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Are we a protected item?
|
||||
$protected = get_config('local_recyclebin', 'protectedmods');
|
||||
$protected = get_config('tool_recyclebin', 'protectedmods');
|
||||
$protected = explode(',', $protected);
|
||||
if (!in_array($item->module, $protected)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Yes! Can we delete protected items?
|
||||
return has_capability('local/recyclebin:delete_protected_item', $context);
|
||||
return has_capability('tool/recyclebin:delete_protected_item', $context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin events.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\event;
|
||||
namespace tool_recyclebin\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event Class
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class course_purged extends \core\event\base
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'local_recyclebin_category';
|
||||
$this->data['objecttable'] = 'tool_recyclebin_category';
|
||||
$this->data['crud'] = 'd';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class course_purged extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('event_purged_name', 'local_recyclebin');
|
||||
return get_string('event_purged_name', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class course_purged extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return get_string('event_purged_description', 'local_recyclebin', array(
|
||||
return get_string('event_purged_description', 'tool_recyclebin', array(
|
||||
'objectid' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin events.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\event;
|
||||
namespace tool_recyclebin\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event Class
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class course_restored extends \core\event\base
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'local_recyclebin_category';
|
||||
$this->data['objecttable'] = 'tool_recyclebin_category';
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class course_restored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('event_restored_name', 'local_recyclebin');
|
||||
return get_string('event_restored_name', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class course_restored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return get_string('event_restored_description', 'local_recyclebin', array(
|
||||
return get_string('event_restored_description', 'tool_recyclebin', array(
|
||||
'objectid' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin events.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\event;
|
||||
namespace tool_recyclebin\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event Class
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class course_stored extends \core\event\base
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'local_recyclebin_category';
|
||||
$this->data['objecttable'] = 'tool_recyclebin_category';
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class course_stored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('event_stored_name', 'local_recyclebin');
|
||||
return get_string('event_stored_name', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class course_stored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return get_string('event_stored_description', 'local_recyclebin', array(
|
||||
return get_string('event_stored_description', 'tool_recyclebin', array(
|
||||
'objectid' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin events.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\event;
|
||||
namespace tool_recyclebin\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event Class
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class item_purged extends \core\event\base
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'local_recyclebin_course';
|
||||
$this->data['objecttable'] = 'tool_recyclebin_course';
|
||||
$this->data['crud'] = 'd';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class item_purged extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('event_purged_name', 'local_recyclebin');
|
||||
return get_string('event_purged_name', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class item_purged extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return get_string('event_purged_description', 'local_recyclebin', array(
|
||||
return get_string('event_purged_description', 'tool_recyclebin', array(
|
||||
'objectid' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin events.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\event;
|
||||
namespace tool_recyclebin\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event Class
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class item_restored extends \core\event\base
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'local_recyclebin_course';
|
||||
$this->data['objecttable'] = 'tool_recyclebin_course';
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class item_restored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('event_restored_name', 'local_recyclebin');
|
||||
return get_string('event_restored_name', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class item_restored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return get_string('event_restored_description', 'local_recyclebin', array(
|
||||
return get_string('event_restored_description', 'tool_recyclebin', array(
|
||||
'objectid' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin events.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\event;
|
||||
namespace tool_recyclebin\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event Class
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class item_stored extends \core\event\base
|
||||
* Init method.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'local_recyclebin_course';
|
||||
$this->data['objecttable'] = 'tool_recyclebin_course';
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class item_stored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('event_stored_name', 'local_recyclebin');
|
||||
return get_string('event_stored_name', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class item_stored extends \core\event\base
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return get_string('event_stored_description', 'local_recyclebin', array(
|
||||
return get_string('event_stored_description', 'tool_recyclebin', array(
|
||||
'objectid' => $this->objectid
|
||||
));
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* Recycle bin observers.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin;
|
||||
namespace tool_recyclebin;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Main class for the recycle bin.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -43,8 +43,8 @@ class observer
|
||||
* @param \stdClass $course The course record.
|
||||
*/
|
||||
public static function pre_course_delete($course) {
|
||||
if (\local_recyclebin\category::is_enabled()) {
|
||||
$recyclebin = new \local_recyclebin\category($course->category);
|
||||
if (\tool_recyclebin\category::is_enabled()) {
|
||||
$recyclebin = new \tool_recyclebin\category($course->category);
|
||||
$recyclebin->store_item($course);
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,8 @@ class observer
|
||||
* @param \stdClass $cm The course module record.
|
||||
*/
|
||||
public static function pre_cm_delete($cm) {
|
||||
if (\local_recyclebin\course::is_enabled()) {
|
||||
$recyclebin = new \local_recyclebin\course($cm->course);
|
||||
if (\tool_recyclebin\course::is_enabled()) {
|
||||
$recyclebin = new \tool_recyclebin\course($cm->course);
|
||||
$recyclebin->store_item($cm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
/**
|
||||
* The main interface for recycle bin methods.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin;
|
||||
namespace tool_recyclebin;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Represents a recyclebin.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
/**
|
||||
* Recycle bin cron task.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\task;
|
||||
namespace tool_recyclebin\task;
|
||||
|
||||
/**
|
||||
* This task deletes expired course recyclebin items.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ class cleanup_activities extends \core\task\scheduled_task {
|
||||
* Task name.
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('cleancourserecyclebin', 'local_recyclebin');
|
||||
return get_string('cleancourserecyclebin', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,8 +46,8 @@ class cleanup_activities extends \core\task\scheduled_task {
|
||||
global $DB;
|
||||
|
||||
// Delete mods.
|
||||
$lifetime = get_config('local_recyclebin', 'expiry');
|
||||
if (!\local_recyclebin\course::is_enabled() || $lifetime <= 0) {
|
||||
$lifetime = get_config('tool_recyclebin', 'expiry');
|
||||
if (!\tool_recyclebin\course::is_enabled() || $lifetime <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class cleanup_activities extends \core\task\scheduled_task {
|
||||
$params = array();
|
||||
|
||||
// Protected mods are exempt.
|
||||
$protected = get_config('local_recyclebin', 'protectedmods');
|
||||
$protected = get_config('tool_recyclebin', 'protectedmods');
|
||||
if (!empty($protected)) {
|
||||
$protected = explode(',', $protected);
|
||||
list($sql, $params) = $DB->get_in_or_equal($protected, SQL_PARAMS_NAMED, 'm', false);
|
||||
@@ -68,11 +68,11 @@ class cleanup_activities extends \core\task\scheduled_task {
|
||||
$params['deleted'] = time() - (86400 * $lifetime);
|
||||
|
||||
// Delete items.
|
||||
$items = $DB->get_recordset_select('local_recyclebin_course', 'deleted < :deleted' . $sql, $params);
|
||||
$items = $DB->get_recordset_select('tool_recyclebin_course', 'deleted < :deleted' . $sql, $params);
|
||||
foreach ($items as $item) {
|
||||
mtrace("[RecycleBin] Deleting item {$item->id}...");
|
||||
|
||||
$bin = new \local_recyclebin\course($item->course);
|
||||
$bin = new \tool_recyclebin\course($item->course);
|
||||
$bin->delete_item($item);
|
||||
}
|
||||
$items->close();
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
/**
|
||||
* Recycle bin cron task.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace local_recyclebin\task;
|
||||
namespace tool_recyclebin\task;
|
||||
|
||||
/**
|
||||
* This task deletes expired category recyclebin items.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ class cleanup_courses extends \core\task\scheduled_task {
|
||||
* Task name.
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('cleancategoryrecyclebin', 'local_recyclebin');
|
||||
return get_string('cleancategoryrecyclebin', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,16 +46,16 @@ class cleanup_courses extends \core\task\scheduled_task {
|
||||
global $DB;
|
||||
|
||||
// Delete courses.
|
||||
$lifetime = get_config('local_recyclebin', 'course_expiry');
|
||||
if (!\local_recyclebin\category::is_enabled() || $lifetime <= 0) {
|
||||
$lifetime = get_config('tool_recyclebin', 'course_expiry');
|
||||
if (!\tool_recyclebin\category::is_enabled() || $lifetime <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$items = $DB->get_recordset_select('local_recyclebin_category', 'deleted < ?', array(time() - (86400 * $lifetime)));
|
||||
$items = $DB->get_recordset_select('tool_recyclebin_category', 'deleted < ?', array(time() - (86400 * $lifetime)));
|
||||
foreach ($items as $item) {
|
||||
mtrace("[RecycleBin] Deleting course {$item->id}...");
|
||||
|
||||
$bin = new \local_recyclebin\category($item->category);
|
||||
$bin = new \tool_recyclebin\category($item->category);
|
||||
$bin->delete_item($item);
|
||||
}
|
||||
$items->close();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Plugin capabilities.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -25,7 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
'local/recyclebin:view_item' => array(
|
||||
'tool/recyclebin:view_item' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
@@ -35,7 +35,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'local/recyclebin:restore_item' => array(
|
||||
'tool/recyclebin:restore_item' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
@@ -44,7 +44,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'local/recyclebin:delete_item' => array(
|
||||
'tool/recyclebin:delete_item' => array(
|
||||
'captype' => 'write',
|
||||
'riskbitmask' => RISK_DATALOSS,
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -54,7 +54,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'local/recyclebin:view_course' => array(
|
||||
'tool/recyclebin:view_course' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSECAT,
|
||||
'archetypes' => array(
|
||||
@@ -62,7 +62,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'local/recyclebin:restore_course' => array(
|
||||
'tool/recyclebin:restore_course' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSECAT,
|
||||
'archetypes' => array(
|
||||
@@ -70,7 +70,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'local/recyclebin:delete_course' => array(
|
||||
'tool/recyclebin:delete_course' => array(
|
||||
'captype' => 'write',
|
||||
'riskbitmask' => RISK_DATALOSS,
|
||||
'contextlevel' => CONTEXT_COURSECAT,
|
||||
@@ -79,7 +79,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'local/recyclebin:delete_protected_item' => array(
|
||||
'tool/recyclebin:delete_protected_item' => array(
|
||||
'captype' => 'write',
|
||||
'riskbitmask' => RISK_DATALOSS,
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="local/recyclebin/db" VERSION="20150826" COMMENT="XMLDB file for Moodle local/recyclebin"
|
||||
<XMLDB PATH="tool/recyclebin/db" VERSION="20150826" COMMENT="XMLDB file for Moodle tool/recyclebin"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="local_recyclebin_course" COMMENT="A list of recycled course modules">
|
||||
<TABLE NAME="tool_recyclebin_course" COMMENT="A list of recycled course modules">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
@@ -21,7 +21,7 @@
|
||||
<INDEX NAME="i_deleted" UNIQUE="false" FIELDS="deleted"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="local_recyclebin_category" COMMENT="A list of deleted courses we have stored up">
|
||||
<TABLE NAME="tool_recyclebin_category" COMMENT="A list of deleted courses we have stored up">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="category" TYPE="int" LENGTH="11" NOTNULL="true" SEQUENCE="false"/>
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
/**
|
||||
* Recycle bin tasks.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => 'local_recyclebin\task\cleanup_activities',
|
||||
'classname' => 'tool_recyclebin\task\cleanup_activities',
|
||||
'blocking' => 0,
|
||||
'minute' => '*/30',
|
||||
'hour' => '*',
|
||||
@@ -33,7 +33,7 @@ $tasks = array(
|
||||
'month' => '*'
|
||||
),
|
||||
array(
|
||||
'classname' => 'local_recyclebin\task\cleanup_courses',
|
||||
'classname' => 'tool_recyclebin\task\cleanup_courses',
|
||||
'blocking' => 0,
|
||||
'minute' => '*/30',
|
||||
'hour' => '*',
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Upgrade code.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @copyright 2015 Skylar Kelty <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* Recycle bin upgrade task
|
||||
*
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool always true
|
||||
*/
|
||||
function xmldb_local_recyclebin_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2015060400) {
|
||||
// Define field deleted to be added to local_recyclebin.
|
||||
$table = new xmldb_table('local_recyclebin');
|
||||
if ($dbman->table_exists($table)) {
|
||||
$field = new xmldb_field('deleted', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'name');
|
||||
// Conditionally launch add field deleted.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define index i_deleted (not unique) to be added to local_recyclebin.
|
||||
$index = new xmldb_index('i_deleted', XMLDB_INDEX_NOTUNIQUE, array('deleted'));
|
||||
// Conditionally launch add index i_deleted.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2015060400, 'local', 'recyclebin');
|
||||
}
|
||||
|
||||
if ($oldversion < 2015082700) {
|
||||
// Define table local_recyclebin to be renamed to local_recyclebin_course.
|
||||
$table = new xmldb_table('local_recyclebin');
|
||||
|
||||
// Launch rename table for local_recyclebin.
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->rename_table($table, 'local_recyclebin_course');
|
||||
}
|
||||
|
||||
// Recyclebin savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2015082700, 'local', 'recyclebin');
|
||||
}
|
||||
|
||||
if ($oldversion < 2015082701) {
|
||||
// Define table local_recyclebin_category to be created.
|
||||
$table = new xmldb_table('local_recyclebin_category');
|
||||
|
||||
// Adding fields to table local_recyclebin_category.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('category', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('fullname', XMLDB_TYPE_CHAR, '254', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('deleted', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
|
||||
// Adding keys to table local_recyclebin_category.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
// Adding indexes to table local_recyclebin_category.
|
||||
$table->add_index('i_category', XMLDB_INDEX_NOTUNIQUE, array('category'));
|
||||
|
||||
// Conditionally launch create table for local_recyclebin_category.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Recyclebin savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2015082701, 'local', 'recyclebin');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -17,12 +17,12 @@
|
||||
/**
|
||||
* This page shows the contents of a recyclebin for a given course.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
@@ -37,33 +37,33 @@ $description = '';
|
||||
switch ($context->contextlevel) {
|
||||
case \CONTEXT_COURSE:
|
||||
require_login($context->instanceid);
|
||||
require_capability('local/recyclebin:view_item', $context);
|
||||
require_capability('tool/recyclebin:view_item', $context);
|
||||
|
||||
$recyclebin = new \local_recyclebin\course($context->instanceid);
|
||||
$description = get_string('description_course', 'local_recyclebin');
|
||||
$recyclebin = new \tool_recyclebin\course($context->instanceid);
|
||||
$description = get_string('description_course', 'tool_recyclebin');
|
||||
break;
|
||||
|
||||
case \CONTEXT_COURSECAT:
|
||||
require_login();
|
||||
require_capability('local/recyclebin:view_course', $context);
|
||||
require_capability('tool/recyclebin:view_course', $context);
|
||||
|
||||
$recyclebin = new \local_recyclebin\category($context->instanceid);
|
||||
$description = get_string('description_coursecat', 'local_recyclebin');
|
||||
$recyclebin = new \tool_recyclebin\category($context->instanceid);
|
||||
$description = get_string('description_coursecat', 'tool_recyclebin');
|
||||
break;
|
||||
|
||||
default:
|
||||
print_error('invalidcontext', 'local_recyclebin');
|
||||
print_error('invalidcontext', 'tool_recyclebin');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$recyclebin::is_enabled()) {
|
||||
print_error('notenabled', 'local_recyclebin');
|
||||
print_error('notenabled', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
$PAGE->set_url('/local/recyclebin/index.php', array(
|
||||
$PAGE->set_url('/admin/tool/recyclebin/index.php', array(
|
||||
'contextid' => $contextid
|
||||
));
|
||||
$PAGE->set_title(get_string('pluginname', 'local_recyclebin'));
|
||||
$PAGE->set_title(get_string('pluginname', 'tool_recyclebin'));
|
||||
|
||||
// If we are doing anything, we need a sesskey!
|
||||
if (!empty($action)) {
|
||||
@@ -81,7 +81,7 @@ if (!empty($action)) {
|
||||
case 'restore':
|
||||
if ($recyclebin->can_restore($item)) {
|
||||
$recyclebin->restore_item($item);
|
||||
redirect($PAGE->url, get_string('alertrestored', 'local_recyclebin', $item), 2);
|
||||
redirect($PAGE->url, get_string('alertrestored', 'tool_recyclebin', $item), 2);
|
||||
} else {
|
||||
print_error('nopermissions', 'error');
|
||||
}
|
||||
@@ -91,7 +91,7 @@ if (!empty($action)) {
|
||||
case 'delete':
|
||||
if ($recyclebin->can_delete($item)) {
|
||||
$recyclebin->delete_item($item);
|
||||
redirect($PAGE->url, get_string('alertdeleted', 'local_recyclebin', $item), 2);
|
||||
redirect($PAGE->url, get_string('alertdeleted', 'tool_recyclebin', $item), 2);
|
||||
} else {
|
||||
print_error('nopermissions', 'error');
|
||||
}
|
||||
@@ -100,7 +100,7 @@ if (!empty($action)) {
|
||||
// Empty it.
|
||||
case 'empty':
|
||||
$recyclebin->delete_all_items();
|
||||
redirect($PAGE->url, get_string('alertemptied', 'local_recyclebin'), 2);
|
||||
redirect($PAGE->url, get_string('alertemptied', 'tool_recyclebin'), 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -119,16 +119,16 @@ $items = $recyclebin->get_items();
|
||||
|
||||
// Nothing to show? Bail out early.
|
||||
if (empty($items)) {
|
||||
echo $OUTPUT->box(get_string('emptybin', 'local_recyclebin'));
|
||||
echo $OUTPUT->box(get_string('emptybin', 'tool_recyclebin'));
|
||||
echo $goback;
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// Start with a description.
|
||||
$expiry = get_config('local_recyclebin', 'expiry');
|
||||
$expiry = get_config('tool_recyclebin', 'expiry');
|
||||
if ($expiry > 0) {
|
||||
$description .= ' ' . get_string('descriptionexpiry', 'local_recyclebin', $expiry);
|
||||
$description .= ' ' . get_string('descriptionexpiry', 'tool_recyclebin', $expiry);
|
||||
}
|
||||
echo $OUTPUT->box($description, 'generalbox descriptionbox');
|
||||
|
||||
@@ -137,7 +137,7 @@ $firstcolstr = $context->contextlevel == \CONTEXT_COURSE ? 'activity' : 'course'
|
||||
$columns = array($firstcolstr, 'date', 'restore', 'delete');
|
||||
$headers = array(
|
||||
get_string($firstcolstr),
|
||||
get_string('deleted', 'local_recyclebin'),
|
||||
get_string('deleted', 'tool_recyclebin'),
|
||||
get_string('restore'),
|
||||
get_string('delete')
|
||||
);
|
||||
@@ -223,7 +223,7 @@ if ($showempty) {
|
||||
'sesskey' => sesskey()
|
||||
));
|
||||
|
||||
echo $OUTPUT->single_button($empty, get_string('empty', 'local_recyclebin'), 'post', array(
|
||||
echo $OUTPUT->single_button($empty, get_string('empty', 'tool_recyclebin'), 'post', array(
|
||||
'class' => 'singlebutton recycle-bin-delete-all'
|
||||
));
|
||||
}
|
||||
@@ -231,8 +231,8 @@ if ($showempty) {
|
||||
echo $goback;
|
||||
|
||||
// Confirmation JS.
|
||||
$PAGE->requires->strings_for_js(array('emptyconfirm', 'deleteconfirm'), 'local_recyclebin');
|
||||
$PAGE->requires->js_init_call('M.local_recyclebin.init');
|
||||
$PAGE->requires->strings_for_js(array('emptyconfirm', 'deleteconfirm'), 'tool_recyclebin');
|
||||
$PAGE->requires->js_init_call('M.tool_recyclebin.init');
|
||||
|
||||
// Output footer.
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* English strings for local_recyclebin.
|
||||
* English strings for tool_recyclebin.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 Skylar Kelty <S.Kelty@kent.ac.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Local lib code
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 Skylar Kelty <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -27,59 +27,34 @@ defined('MOODLE_INTERNAL') || die;
|
||||
/**
|
||||
* Adds a recycle bin link to the course admin menu.
|
||||
*
|
||||
* @param settings_navigation $nav Nav menu
|
||||
* @param context $context Context of the menu
|
||||
* @return navigation_node A new navigation mode to insert.
|
||||
* @param navigation_node $navigation The navigation node to extend
|
||||
* @param stdClass $course The course to object for the tool
|
||||
* @param context $context The context of the course
|
||||
*/
|
||||
function local_recyclebin_extend_settings_navigation(settings_navigation $nav, context $context) {
|
||||
function tool_recyclebin_extend_navigation_course($navigation, $course, $context) {
|
||||
global $PAGE;
|
||||
|
||||
$url = null;
|
||||
$bin = null;
|
||||
$settingnode = null;
|
||||
|
||||
// What context are we in?
|
||||
if ($context->contextlevel == \CONTEXT_COURSECAT) {
|
||||
// Check we can view the recycle bin.
|
||||
if (!has_capability('local/recyclebin:view_course', $context) || !\local_recyclebin\category::is_enabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Add a link to the category recyclebin.
|
||||
$bin = new \local_recyclebin\category($context->instanceid);
|
||||
$url = new moodle_url('/local/recyclebin/index.php', array(
|
||||
'contextid' => $context->id
|
||||
));
|
||||
|
||||
$settingnode = $nav->find('categorysettings', null);
|
||||
} else {
|
||||
// Only add this settings item on non-site course pages.
|
||||
if (!$PAGE->course || $PAGE->course->id == SITEID || !\local_recyclebin\course::is_enabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We might be in a mod page, etc.
|
||||
$coursectx = \context_course::instance($PAGE->course->id);
|
||||
|
||||
// Check we can view the recycle bin.
|
||||
if (!has_capability('local/recyclebin:view_item', $coursectx)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$bin = new \local_recyclebin\course($coursectx->instanceid);
|
||||
$url = new moodle_url('/local/recyclebin/index.php', array(
|
||||
'contextid' => $coursectx->id
|
||||
));
|
||||
|
||||
$settingnode = $nav->find('courseadmin', navigation_node::TYPE_COURSE);
|
||||
// Only add this settings item on non-site course pages.
|
||||
if (!$PAGE->course || $PAGE->course->id == SITEID || !\tool_recyclebin\course::is_enabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($settingnode == null) {
|
||||
return;
|
||||
// Check we can view the recycle bin.
|
||||
if (!has_capability('tool/recyclebin:view_item', $context)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$bin = new \tool_recyclebin\course($context->instanceid);
|
||||
$url = new moodle_url('/admin/tool/recyclebin/index.php', array(
|
||||
'contextid' => $context->id
|
||||
));
|
||||
|
||||
// If we are set to auto-hide, check the number of items.
|
||||
$autohide = get_config('local_recyclebin', 'autohide');
|
||||
$autohide = get_config('tool_recyclebin', 'autohide');
|
||||
if ($autohide) {
|
||||
$items = $bin->get_items();
|
||||
if (empty($items)) {
|
||||
@@ -88,14 +63,14 @@ function local_recyclebin_extend_settings_navigation(settings_navigation $nav, c
|
||||
}
|
||||
|
||||
// Add the recyclebin link.
|
||||
$pluginname = get_string('pluginname', 'local_recyclebin');
|
||||
$pluginname = get_string('pluginname', 'tool_recyclebin');
|
||||
|
||||
$node = navigation_node::create(
|
||||
$pluginname,
|
||||
$url,
|
||||
navigation_node::NODETYPE_LEAF,
|
||||
'local_recyclebin',
|
||||
'local_recyclebin',
|
||||
'tool_recyclebin',
|
||||
'tool_recyclebin',
|
||||
new pix_icon('e/cleanup_messy_code', $pluginname)
|
||||
);
|
||||
|
||||
@@ -103,17 +78,57 @@ function local_recyclebin_extend_settings_navigation(settings_navigation $nav, c
|
||||
$node->make_active();
|
||||
}
|
||||
|
||||
$settingnode->add_node($node);
|
||||
|
||||
return $node;
|
||||
$navigation->add_node($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* For pre-2.9 installations.
|
||||
* Adds a recycle bin link to the course admin menu.
|
||||
*
|
||||
* @param settings_navigation $nav
|
||||
* @param context $context
|
||||
* @param navigation_node $navigation The navigation node to extend
|
||||
* @param context $context The context of the course
|
||||
*/
|
||||
function local_recyclebin_extends_settings_navigation(settings_navigation $nav, context $context) {
|
||||
local_recyclebin_extend_settings_navigation($nav, $context);
|
||||
}
|
||||
function tool_recyclebin_extend_navigation_category_settings($navigation, $context) {
|
||||
global $PAGE;
|
||||
|
||||
$url = null;
|
||||
$bin = null;
|
||||
$settingnode = null;
|
||||
|
||||
// Check we can view the recycle bin.
|
||||
if (!has_capability('tool/recyclebin:view_course', $context) || !\tool_recyclebin\category::is_enabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Add a link to the category recyclebin.
|
||||
$bin = new \tool_recyclebin\category($context->instanceid);
|
||||
$url = new moodle_url('/admin/tool/recyclebin/index.php', array(
|
||||
'contextid' => $context->id
|
||||
));
|
||||
|
||||
// If we are set to auto-hide, check the number of items.
|
||||
$autohide = get_config('tool_recyclebin', 'autohide');
|
||||
if ($autohide) {
|
||||
$items = $bin->get_items();
|
||||
if (empty($items)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the recyclebin link.
|
||||
$pluginname = get_string('pluginname', 'tool_recyclebin');
|
||||
|
||||
$node = navigation_node::create(
|
||||
$pluginname,
|
||||
$url,
|
||||
navigation_node::NODETYPE_LEAF,
|
||||
'tool_recyclebin',
|
||||
'tool_recyclebin',
|
||||
new pix_icon('e/cleanup_messy_code', $pluginname)
|
||||
);
|
||||
|
||||
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
|
||||
$node->make_active();
|
||||
}
|
||||
|
||||
$navigation->add_node($node);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Added a confirmation dialogue when the empty recycle bin
|
||||
// button has been selected.
|
||||
M.local_recyclebin = {
|
||||
M.tool_recyclebin = {
|
||||
init: function (Y) {
|
||||
// Confirmation dialogue function.
|
||||
function confirmDialogue(e, str, callback) {
|
||||
@@ -27,7 +27,7 @@ M.local_recyclebin = {
|
||||
Y.all('.recycle-bin-delete').each(function(node) {
|
||||
node.on('click', function(e) {
|
||||
// Get some strings from the Recycle bin lang file.
|
||||
var str = M.util.get_string('deleteconfirm', 'local_recyclebin');
|
||||
var str = M.util.get_string('deleteconfirm', 'tool_recyclebin');
|
||||
|
||||
// Get the URL that leads to emptying the recycle bin.
|
||||
var urldelete = this.get('href');
|
||||
@@ -42,7 +42,7 @@ M.local_recyclebin = {
|
||||
// Find the "Delete All" button and perform an action when it is clicked.
|
||||
Y.one('.recycle-bin-delete-all input').on('click', function(e) {
|
||||
// Get some strings from the Recycle bin lang file.
|
||||
var str = M.util.get_string('emptyconfirm', 'local_recyclebin');
|
||||
var str = M.util.get_string('emptyconfirm', 'tool_recyclebin');
|
||||
|
||||
// Show the dialogue.
|
||||
confirmDialogue(e, str, function() {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Recycle bin settings.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -27,11 +27,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
global $PAGE;
|
||||
|
||||
if ($hassiteconfig) {
|
||||
$settings = new admin_settingpage('local_recyclebin', get_string('pluginname', 'local_recyclebin'));
|
||||
$ADMIN->add('localplugins', $settings);
|
||||
$settings = new admin_settingpage('tool_recyclebin', get_string('pluginname', 'tool_recyclebin'));
|
||||
$ADMIN->add('tools', $settings);
|
||||
|
||||
$lifetimes = array(
|
||||
0 => new lang_string('neverdelete', 'local_recyclebin'),
|
||||
0 => new lang_string('neverdelete', 'tool_recyclebin'),
|
||||
1000 => new lang_string('numdays', '', 1000),
|
||||
365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
@@ -48,32 +48,32 @@ if ($hassiteconfig) {
|
||||
);
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
'local_recyclebin/enablecourse',
|
||||
new lang_string('enablecourse', 'local_recyclebin'),
|
||||
new lang_string('enablecourse_desc', 'local_recyclebin'),
|
||||
'tool_recyclebin/enablecourse',
|
||||
new lang_string('enablecourse', 'tool_recyclebin'),
|
||||
new lang_string('enablecourse_desc', 'tool_recyclebin'),
|
||||
1
|
||||
));
|
||||
|
||||
$settings->add(new admin_setting_configselect(
|
||||
'local_recyclebin/expiry',
|
||||
new lang_string('expiry', 'local_recyclebin'),
|
||||
new lang_string('expiry_desc', 'local_recyclebin'),
|
||||
'tool_recyclebin/expiry',
|
||||
new lang_string('expiry', 'tool_recyclebin'),
|
||||
new lang_string('expiry_desc', 'tool_recyclebin'),
|
||||
0,
|
||||
$lifetimes
|
||||
));
|
||||
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
'local_recyclebin/enablecategory',
|
||||
new lang_string('enablecategory', 'local_recyclebin'),
|
||||
new lang_string('enablecategory_desc', 'local_recyclebin'),
|
||||
'tool_recyclebin/enablecategory',
|
||||
new lang_string('enablecategory', 'tool_recyclebin'),
|
||||
new lang_string('enablecategory_desc', 'tool_recyclebin'),
|
||||
1
|
||||
));
|
||||
|
||||
$settings->add(new admin_setting_configselect(
|
||||
'local_recyclebin/course_expiry',
|
||||
new lang_string('course_expiry', 'local_recyclebin'),
|
||||
new lang_string('course_expiry_desc', 'local_recyclebin'),
|
||||
'tool_recyclebin/course_expiry',
|
||||
new lang_string('course_expiry', 'tool_recyclebin'),
|
||||
new lang_string('course_expiry_desc', 'tool_recyclebin'),
|
||||
0,
|
||||
$lifetimes
|
||||
));
|
||||
@@ -81,16 +81,16 @@ if ($hassiteconfig) {
|
||||
unset($lifetimes);
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
'local_recyclebin/autohide',
|
||||
new lang_string('autohide', 'local_recyclebin'),
|
||||
new lang_string('autohide_desc', 'local_recyclebin'),
|
||||
'tool_recyclebin/autohide',
|
||||
new lang_string('autohide', 'tool_recyclebin'),
|
||||
new lang_string('autohide_desc', 'tool_recyclebin'),
|
||||
0
|
||||
));
|
||||
|
||||
$settings->add(new admin_setting_configmultiselect(
|
||||
'local_recyclebin/protectedmods',
|
||||
new lang_string('protectedmods', 'local_recyclebin'),
|
||||
new lang_string('protectedmods_desc', 'local_recyclebin'),
|
||||
'tool_recyclebin/protectedmods',
|
||||
new lang_string('protectedmods', 'tool_recyclebin'),
|
||||
new lang_string('protectedmods_desc', 'tool_recyclebin'),
|
||||
array(),
|
||||
$DB->get_records_menu('modules', array('visible' => 1), 'name ASC', 'id, name')
|
||||
));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@local_recyclebin
|
||||
@tool @tool_recyclebin
|
||||
Feature: Backup user data
|
||||
As a teacher
|
||||
I want user data to be backed up when I delete a course module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@local_recyclebin
|
||||
@tool @tool_recyclebin
|
||||
Feature: Basic recycle bin functionality
|
||||
As a teacher
|
||||
I want be able to recover deleted content
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@local_recyclebin @javascript
|
||||
@tool @tool_recyclebin
|
||||
Feature: Delete confirmation
|
||||
As a teacher
|
||||
I want to be prompted before I permanently delete something
|
||||
@@ -24,6 +24,7 @@ Background:
|
||||
And I delete "Test page" activity
|
||||
And I follow "Recycle bin"
|
||||
|
||||
@javascript
|
||||
Scenario: Confirm single delete
|
||||
When I click on "Delete" "link"
|
||||
Then I should see "Are you sure you want to delete the selected item in the recycle bin?"
|
||||
@@ -34,6 +35,7 @@ Scenario: Confirm single delete
|
||||
And I wait to be redirected
|
||||
Then I should see "There are no items in the recycle bin."
|
||||
|
||||
@javascript
|
||||
Scenario: Confirm empty bin
|
||||
When I press "Empty recycle bin"
|
||||
Then I should see "Are you sure you want to delete all items in the recycle bin?"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@local_recyclebin
|
||||
@tool @tool_recyclebin
|
||||
Feature: Description of recycle bin and expiry
|
||||
As a teacher
|
||||
I want to know what the recycle bin will do and how long contents last in the bin
|
||||
@@ -27,7 +27,7 @@ Scenario: Description should show when the recycle bin will clean up files.
|
||||
Then I should not see "Contents will be permanently deleted"
|
||||
# Test changing expiry to something else.
|
||||
When the following config values are set as admin:
|
||||
| expiry | 10 | local_recyclebin |
|
||||
| expiry | 10 | tool_recyclebin |
|
||||
# Step "I reload the page" doesn't work outside of javascript.
|
||||
And I follow "Recycle bin"
|
||||
Then I should see "Contents will be permanently deleted after 10 days"
|
||||
@@ -1,4 +1,4 @@
|
||||
@local_recyclebin
|
||||
@tool @tool_recyclebin
|
||||
Feature: Recycle bin refinements
|
||||
As a teacher
|
||||
I want the log to reflect the recycle bin's actions
|
||||
@@ -30,7 +30,7 @@ Feature: Recycle bin refinements
|
||||
And I wait to be redirected
|
||||
And I follow "C1"
|
||||
And I expand "Reports" node
|
||||
And I follow "Logs"
|
||||
And I follow "Logs"
|
||||
And I click on "Get these logs" "link_or_button"
|
||||
Then I should see "Item stored"
|
||||
Then I should see "Item stored"
|
||||
And I should see "Item purged"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Recycle bin tests.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -27,11 +27,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
/**
|
||||
* Recycle bin category tests.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class local_recyclebin_category_tests extends \advanced_testcase
|
||||
class tool_recyclebin_category_tests extends \advanced_testcase
|
||||
{
|
||||
/**
|
||||
* Setup for each test.
|
||||
@@ -57,7 +57,7 @@ class local_recyclebin_category_tests extends \advanced_testcase
|
||||
$this->assertEquals($this->before, $DB->count_records('course'));
|
||||
|
||||
// Try with the API.
|
||||
$recyclebin = new \local_recyclebin\category($this->course->category);
|
||||
$recyclebin = new \tool_recyclebin\category($this->course->category);
|
||||
$this->assertEquals(1, count($recyclebin->get_items()));
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class local_recyclebin_category_tests extends \advanced_testcase
|
||||
delete_course($this->course, false);
|
||||
$this->assertEquals($this->before, $DB->count_records('course'));
|
||||
|
||||
$recyclebin = new \local_recyclebin\category($this->course->category);
|
||||
$recyclebin = new \tool_recyclebin\category($this->course->category);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
$recyclebin->restore_item($item);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class local_recyclebin_category_tests extends \advanced_testcase
|
||||
delete_course($this->course, false);
|
||||
$this->assertEquals($this->before, $DB->count_records('course'));
|
||||
|
||||
$recyclebin = new \local_recyclebin\category($this->course->category);
|
||||
$recyclebin = new \tool_recyclebin\category($this->course->category);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
$recyclebin->delete_item($item);
|
||||
}
|
||||
@@ -103,19 +103,19 @@ class local_recyclebin_category_tests extends \advanced_testcase
|
||||
public function test_purge_task() {
|
||||
global $DB;
|
||||
|
||||
set_config('course_expiry', 1, 'local_recyclebin');
|
||||
set_config('course_expiry', 1, 'tool_recyclebin');
|
||||
|
||||
delete_course($this->course, false);
|
||||
$this->assertEquals($this->before, $DB->count_records('course'));
|
||||
|
||||
// Set deleted date to the distant past.
|
||||
$recyclebin = new \local_recyclebin\category($this->course->category);
|
||||
$recyclebin = new \tool_recyclebin\category($this->course->category);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
$item->deleted = 1;
|
||||
$DB->update_record('local_recyclebin_category', $item);
|
||||
$DB->update_record('tool_recyclebin_category', $item);
|
||||
}
|
||||
// Execute cleanup task.
|
||||
$task = new local_recyclebin\task\cleanup_courses();
|
||||
$task = new tool_recyclebin\task\cleanup_courses();
|
||||
$task->execute();
|
||||
|
||||
$this->assertEquals($this->before, $DB->count_records('course'));
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Recycle bin tests.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -27,11 +27,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
/**
|
||||
* Recycle bin course tests.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2015 University of Kent
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class local_recyclebin_course_tests extends \advanced_testcase
|
||||
class tool_recyclebin_course_tests extends \advanced_testcase
|
||||
{
|
||||
/**
|
||||
* Setup for each test.
|
||||
@@ -57,16 +57,16 @@ class local_recyclebin_course_tests extends \advanced_testcase
|
||||
global $DB;
|
||||
|
||||
$this->assertEquals($this->before + 1, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(0, $DB->count_records('local_recyclebin_course'));
|
||||
$this->assertEquals(0, $DB->count_records('tool_recyclebin_course'));
|
||||
|
||||
// Delete the CM.
|
||||
course_delete_module($this->instance->cmid);
|
||||
|
||||
$this->assertEquals($this->before, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(1, $DB->count_records('local_recyclebin_course'));
|
||||
$this->assertEquals(1, $DB->count_records('tool_recyclebin_course'));
|
||||
|
||||
// Try with the API.
|
||||
$recyclebin = new \local_recyclebin\course($this->course->id);
|
||||
$recyclebin = new \tool_recyclebin\course($this->course->id);
|
||||
$this->assertEquals(1, count($recyclebin->get_items()));
|
||||
}
|
||||
|
||||
@@ -80,13 +80,13 @@ class local_recyclebin_course_tests extends \advanced_testcase
|
||||
course_delete_module($this->instance->cmid);
|
||||
|
||||
// Try restoring.
|
||||
$recyclebin = new \local_recyclebin\course($this->course->id);
|
||||
$recyclebin = new \tool_recyclebin\course($this->course->id);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
$recyclebin->restore_item($item);
|
||||
}
|
||||
|
||||
$this->assertEquals($this->before + 1, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(0, $DB->count_records('local_recyclebin_course'));
|
||||
$this->assertEquals(0, $DB->count_records('tool_recyclebin_course'));
|
||||
$this->assertEquals(0, count($recyclebin->get_items()));
|
||||
}
|
||||
|
||||
@@ -100,13 +100,13 @@ class local_recyclebin_course_tests extends \advanced_testcase
|
||||
course_delete_module($this->instance->cmid);
|
||||
|
||||
// Try purging.
|
||||
$recyclebin = new \local_recyclebin\course($this->course->id);
|
||||
$recyclebin = new \tool_recyclebin\course($this->course->id);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
$recyclebin->delete_item($item);
|
||||
}
|
||||
|
||||
$this->assertEquals($this->before, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(0, $DB->count_records('local_recyclebin_course'));
|
||||
$this->assertEquals(0, $DB->count_records('tool_recyclebin_course'));
|
||||
$this->assertEquals(0, count($recyclebin->get_items()));
|
||||
}
|
||||
|
||||
@@ -116,23 +116,23 @@ class local_recyclebin_course_tests extends \advanced_testcase
|
||||
public function test_purge_task() {
|
||||
global $DB;
|
||||
|
||||
set_config('expiry', 1, 'local_recyclebin');
|
||||
set_config('expiry', 1, 'tool_recyclebin');
|
||||
|
||||
// Delete the CM.
|
||||
course_delete_module($this->instance->cmid);
|
||||
|
||||
// Set deleted date to the distant past.
|
||||
$recyclebin = new \local_recyclebin\course($this->course->id);
|
||||
$recyclebin = new \tool_recyclebin\course($this->course->id);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
$item->deleted = 1;
|
||||
$DB->update_record('local_recyclebin_course', $item);
|
||||
$DB->update_record('tool_recyclebin_course', $item);
|
||||
}
|
||||
// Execute cleanup task.
|
||||
$task = new local_recyclebin\task\cleanup_activities();
|
||||
$task = new tool_recyclebin\task\cleanup_activities();
|
||||
$task->execute();
|
||||
|
||||
$this->assertEquals($this->before, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(0, $DB->count_records('local_recyclebin_course'));
|
||||
$this->assertEquals(0, $DB->count_records('tool_recyclebin_course'));
|
||||
$this->assertEquals(0, count($recyclebin->get_items()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
3.0
|
||||
===
|
||||
|
||||
* local_recyclebin\Observer has been changed to local_recyclebin\observer (lower case). Please update the core hack.
|
||||
@@ -17,15 +17,13 @@
|
||||
/**
|
||||
* Defines the version.
|
||||
*
|
||||
* @package local_recyclebin
|
||||
* @package tool_recyclebin
|
||||
* @copyright 2016 Skylar Kelty <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016022200;
|
||||
$plugin->component = 'local_recyclebin';
|
||||
$plugin->requires = 2014051200;
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
$plugin->release = '3.3 (Build: 2016022200)';
|
||||
$plugin->version = 2016022300; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015111000; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_recyclebin'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
Reference in New Issue
Block a user