Compare commits

..

473 Commits

Author SHA1 Message Date
moodler c51ffe5107 Drawing a line in the sand at this point. 2004-11-05 03:22:11 +00:00
moodler b60003a832 Updated release notes a little 2004-11-05 03:20:40 +00:00
moodler 7fc51d17c3 New file 2004-11-05 03:02:06 +00:00
moodler 9bd37fa711 New files 2004-11-05 03:01:44 +00:00
moodler 9e74ddd633 Copied over language files from HEAD 2004-11-05 02:52:14 +00:00
moodler 0551474e63 Fixed up some XHTML and also sesskey links on link dialog 2004-11-04 16:56:29 +00:00
moodler c562717acb Added sesskey etc to HTML editor file browser 2004-11-04 16:23:13 +00:00
skodak d52e13002e initialized $image and moved filemtime after file_exists 2004-11-04 09:31:33 +00:00
skodak d8d356d4c7 initialized variables - the same as algebra/pix.php 2004-11-04 07:58:41 +00:00
moodler 57af827e39 Trim search string of spaces 2004-11-04 07:14:16 +00:00
moodler 8ba0912440 Patch for postgresql happiness 2004-11-04 07:05:10 +00:00
moodler 54b5310062 Addslashes to pathinfo to prevent SQL injections 2004-11-04 06:28:17 +00:00
stronk7 f4f27c0675 Ready BUMP! 2004-11-04 00:11:34 +00:00
stronk7 796d3c880a Now courses are deleted from backup_courses when they have been
deleted from Moodle. See:
http://moodle.org/mod/forum/discuss.php?d=13633
2004-11-04 00:08:28 +00:00
moodler d6f6091a4b Initialise some variables $cmd and $status - thanks Petr 2004-11-03 16:01:32 +00:00
moodler fa1c36fb99 Hidden teachers should not be shown in separate groups mode 2004-11-03 14:11:52 +00:00
moodler 5ff5caa58d Bump 2004-11-03 12:53:05 +00:00
moodler 34990da46d Merged changes from HEAD to STABLE 2004-11-03 08:49:44 +00:00
moodler e41871f1fb Whoops, missing uploadfile.php! 2004-11-03 08:41:39 +00:00
moodler af0145e39d Removed use of PHP_SELF 2004-11-03 02:01:22 +00:00
moodler 40dcb53fc6 Nullified courseimages.php, and made some of the security improvements
to lib/editor.php ... not quite completed yet with that though.
2004-11-02 16:57:10 +00:00
moodler fbc914dafe files/index.php now allows choosing and it makes the coursefiles.php
scripts unnecessary.

Wiki, Resource and Scorm now use the new method, so their versions
have been bumped.
2004-11-02 12:02:00 +00:00
stronk7 412e0bb881 Bug 2140 solved partially. Now categories are
deleted properly.

Delete of orphan categories will be done later...
2004-11-01 20:47:48 +00:00
moodler c5505d8071 Initialise $parent variable to avoid Norton bug 2004-11-01 12:47:38 +00:00
moodler 153bd6ec63 Fixed the bug introduced in 1.4 (part of the site-level module changes)
that caused assignment notifications to not be mailed out
2004-10-31 04:09:05 +00:00
gustav_delius ebd32e3e38 Fixed a bug that allowed teachers to upload images of arbitrary size 2004-10-30 22:40:22 +00:00
defacer d907cdad93 Importing fix for bug #2004 (Bug of the Year! :D) from HEAD:
Events in each day are now displayed ordered by starting time, and not by
eventid as before. Thanks to Gustav for pointing this out!
2004-10-29 17:29:29 +00:00
moodler 7747441767 I have removed the <style> tag from the list of allowed tags in forum
posts and other places students can write.

It allows too many possibilities like this:

<style>
div {
   position:absolute;
   width:100%;
   height:100%;
   background:black;
   top:0;
   left:0;
}
</style>
<div>test</div>

styles within tags don't allow this for some reason.

Thanks to Andrea Giardina for the alert.

Note that the HTML editor strips this tag anyway so it's not a big deal.
2004-10-29 07:28:32 +00:00
skodak f349337d7e removed incorrect global $USER 2004-10-28 14:17:19 +00:00
moodler 00980197b8 FIxed bug with displaying user access time on site level 2004-10-27 05:57:34 +00:00
skodak da11cdfbe4 updated htmleditor invocation (from files/index.php) 2004-10-26 19:53:26 +00:00
skodak 5dcda7b86f changes:
* sesskey;
* only editing teachers can use it;
* time modified - used filemtime (consistency with files/index.php, better for Win32);
* directory sizes shown;
* removed unused "torte" action;
* updated breadcrums (active folder not linked and &raquo;);
* updated comments;
* some other fixes from files/index.php.

Please test, test, test.
2004-10-26 18:55:47 +00:00
moodler 1a8b9564c4 Add slashes to wiki names when creating new entries. 2004-10-26 07:40:48 +00:00
gustav_delius e8715b0d9b added missing print_footer() 2004-10-25 20:33:27 +00:00
stronk7 7092220f99 Added sesskey to more actions + bug fix when detecting directory traversals.
From skodak!
2004-10-24 23:51:51 +00:00
skodak aeb0e7ee1e fixed warning in Activity report/Outline - oops, wrong line 2004-10-24 21:00:48 +00:00
stronk7 e674aa8ba8 Now everything in files/index.php is using sesskey.
Patch submmited by skodak.
2004-10-24 00:04:56 +00:00
skodak 20f961f1e2 fixed warning in Activity report/Outline 2004-10-23 19:07:31 +00:00
moodler ed95139596 Fix for bug 2114 that was losing track of the Real user when loginas
was used by a logged-in user
2004-10-21 15:49:59 +00:00
stronk7 4cc9465bc7 Solved one annoying bug where label texts in sections != first
was being always cleared, preventing some tags to be there!
2004-10-20 23:22:16 +00:00
moodler 91bbe51649 Moved the new additions from the display() function into the constructor 2004-10-19 09:41:01 +00:00
moodler 4fe3740b36 Centralised some of the display stuff in the display function in the base class
Added better checking for students accessing hidden resources
2004-10-19 09:28:18 +00:00
moodler 64f689e0d0 No need for DISTINCT when getting courses any more (only one table) 2004-10-18 05:58:12 +00:00
moodler b0cbbc56c2 More efficient querying of courses (from Martin Langhoff) 2004-10-18 05:57:09 +00:00
stronk7 4a69819405 Strip control chars when unzipping. 2004-10-17 23:42:48 +00:00
stronk7 dcf2a27a32 Now Wiki's FileManager is using central zip & unzip functions. 2004-10-17 23:14:40 +00:00
stronk7 83b640f957 Now Editor's FileManager is using central zip and unzip functions.
NOTE: What is the courseimages.php file, I haven't tested it because
I didn't find how to do it!!
2004-10-17 23:08:59 +00:00
stronk7 07d0fff0f3 Now Scorm's FileManager is using central zip and unzip functions. 2004-10-17 22:46:31 +00:00
stronk7 e5e3f219dd Small change in condition... 2004-10-17 22:34:49 +00:00
stronk7 6ee3b260cb Included some filename transformations to work like info-zip.
Directory traversal protection added.

Working under Win32, MacOS X and BSD (and rest of Unix, I hope).

Patch file from Petr. Thanks!
2004-10-17 22:26:45 +00:00
stronk7 35a510d8b6 Now resource's FileManager is using central zip & unzip functions. 2004-10-17 19:33:46 +00:00
stronk7 1a9911452e Now pclzip generated files are compatible with info-zip
(linux, macos x, win32, bsd...) based extractors. This
include command-line flavours, stuffit and so on...

Thanks to Petr!!

We have to remember to apply this patch when we update the
pclzip in th future (if their authors don't include it).
2004-10-17 13:34:26 +00:00
stronk7 736db01dc4 ZIP_METHOD included in backup for future tests at restore time. 2004-10-16 17:47:26 +00:00
stronk7 1e55f8cfce Not mandatory but I prefer to initialise it. 2004-10-16 17:36:37 +00:00
stronk7 3eb92f112c Now backup and restore are using central zip & unzip functions. 2004-10-16 17:09:49 +00:00
stronk7 20b53a7ba2 Added the optional showstatus parameter to unzip_file() to avoid
sending any output if desired.
2004-10-16 16:29:57 +00:00
stronk7 4bc418dc6d Bump to 1.4.2 2004-10-16 16:10:04 +00:00
stronk7 27974c8587 Latest patches from skodak included in param functions.
Simple and double quotes are out now.
Full paths in unzip are now hidden too.

Please test it. It could have some pending changes yet!
2004-10-16 11:30:14 +00:00
moodler 882a125790 Added some robustness 2004-10-16 10:15:26 +00:00
moodler ee4fe14631 Implemented Eloy's suggestion from Bug 2073 2004-10-15 09:52:16 +00:00
moodler c56d16bb4e Prettier error message when Moodle can't connect to database,
but also the database info is no longer printed (bug 2074)
2004-10-15 08:46:13 +00:00
moodler f7375fe1c3 Bumping for ID purposes 2004-10-15 06:41:40 +00:00
paca70 a67dd90008 Prevent auth_iscreator from overriding users course creation status 2004-10-13 07:27:34 +00:00
skodak 00c6364cbb added sesskey to update_module_button(), error reported in moodle forum d=13835
I made a quick fix - it seemed critical to me
2004-10-12 18:37:56 +00:00
stronk7 176d456ed9 Under Win32, we need backslashes in paths. Now it works!! 2004-10-10 23:24:15 +00:00
stronk7 4f64ed9405 Added some nedded strings 2004-10-10 22:45:00 +00:00
stronk7 27ed82e82f Deleted some unused strings 2004-10-10 22:44:37 +00:00
stronk7 54ce5e46c8 Delete some debug output... 2004-10-10 21:57:58 +00:00
stronk7 a748a0f84d Now we are using the new, central, unzip_file() function here...
Please TEST, TEST, TEST!!
2004-10-10 21:54:11 +00:00
stronk7 ed124087d7 vim is in again... :-) 2004-10-10 21:47:29 +00:00
stronk7 0954d514b8 Central unzip_file() function included:
- Supports both internal and external zip execution.
    - Displays the results of the execution.
    - All Petr's patched added.
    - External zip execution in Win32 supported.
Please TEST, TEST, TEST.
2004-10-10 21:33:46 +00:00
skodak 2d9a666670 one more cleaned 2004-10-10 20:21:40 +00:00
stronk7 291fd04602 Order logs by creation order (id) 2004-10-10 18:46:25 +00:00
skodak 2c9f5a3a00 cleaned text from forms 2004-10-10 17:26:34 +00:00
stronk7 f54d5ea5fb Now FileManager is using the new, central zip_files() function.
Only tested under MacOS X. It should support all the new
features of that function (Win32 external zip, imporved security...).

TODO: Create the unzip_file() function and use it here too!!
      Apply this changes to the rest of filemanagers (coursefiles.php...)
      TEST, TEST, TEST...!!
2004-10-10 01:17:20 +00:00
stronk7 2b26825cb2 Now the zip_files() function is working better:
- More checks are done
- Non existing files are out
- Both internal an external are supported and protected
- All Petr's patchs applied
- Included support to Win32 external zip.

TODO: Create a paralel unzip_file() function
      Use this functions in all the FileManager scripts

THOUGHT: External zip seems to work always adding files to
      zip file if it exists, where PclZip resets the file.
      Perhaps a rm (or delete) should be included in the
      command chain. Analyse it!!
2004-10-10 01:01:02 +00:00
stronk7 d5640b844b Use of cleardoubleslashes() added to the backup and restore functions.
They will be changed to calls to new, central zip and unzip functions.
(coming soon)
2004-10-09 23:00:51 +00:00
stronk7 3099dc3e6f course/view.php is using sesskey
(changes in blocks done, please check them)
2004-10-09 20:04:45 +00:00
stronk7 1824077052 course/unenrol.php is using sesskey. 2004-10-09 19:06:51 +00:00
stronk7 672610e605 course/teacher.php is using sesskey.
(in POST form too)
2004-10-09 19:01:02 +00:00
stronk7 473d3495a5 course/student.php is using sesskey. 2004-10-09 18:43:32 +00:00
stronk7 dfcbccbbef course/scales.php is using sesskey. 2004-10-09 18:30:11 +00:00
stronk7 55b55d08f9 course/mod.php is using sesskey. 2004-10-09 17:02:28 +00:00
stronk7 952d9baf58 course/index.php is using sesskey. 2004-10-09 13:11:49 +00:00
stronk7 bccdea508c course/groups.php is using sesskey. 2004-10-09 12:01:34 +00:00
stronk7 ecea1540da course/group.php is using sesskey. 2004-10-09 11:45:48 +00:00
stronk7 2e989420c9 course/grades.php is using sesskey. 2004-10-09 11:36:10 +00:00
moodler 08bae16463 Removed a notice 2004-10-09 04:38:01 +00:00
stronk7 ac63a3f445 course/editsection.php is using sesskey. 2004-10-08 18:29:02 +00:00
stronk7 58b9565184 edit.php is using sesskey 2004-10-08 18:10:37 +00:00
stronk7 4a25390975 course/delete.php is now using sesskey 2004-10-08 17:55:16 +00:00
stronk7 d177dd7713 course/category.php is using sesskey 2004-10-08 16:41:04 +00:00
moodler c30dd54457 Slightly changed the shortcut method of disabling email so that it's
less potentially confusing for students.  The status is now written
in full (not just an icon) and only for re-enabling an email.
2004-10-08 07:01:52 +00:00
moodler 229ee13480 Merged into stable 2004-10-08 04:02:58 +00:00
defacer 4d54248710 Smallish refinement. 2004-10-08 00:19:20 +00:00
defacer 9dc9d6b0a8 Updated the translation in a place it was so badly behind that it actually
caused the admins to turn to the programmers for help... sad.
2004-10-08 00:15:05 +00:00
moodler fdce874a70 Send welcome email even when there is no course password 2004-10-07 15:21:49 +00:00
stronk7 3db6b58aa4 PclZip library upgraded to 2.1 2004-10-07 14:05:33 +00:00
stronk7 913f744325 Changes to the zip, unzip, listzip and restore sections of the file:
- Added a new function in lib/moodlelib.php
- Uses the new version of pclzip.php library.
- Petr patches applied.
- Some minor changes to hide full paths under Win32.
- Tested in MacOS X and Win32 (not linux).
- New function zip_files() in moodlelib.php. Not used, but a good start.

Please test it!!
2004-10-07 14:04:37 +00:00
stronk7 c5544714a8 Changed some conditions against the $USER variable
to work fine under PHP5.

Bug 2053
(http://moodle.org/bugs/bug.php?op=show&bugid=2053)
2004-10-06 16:47:27 +00:00
moodler dcbe5864f6 Damn, typo 2004-10-06 14:19:06 +00:00
moodler 028f222c2a Changed the error logging format in error_log to make it
- more standard
   - better for multi-site servers
2004-10-06 13:53:55 +00:00
moodler 8b559dc502 Slight fix for logic of USER 2004-10-06 13:42:57 +00:00
stronk7 2c13dbe497 Now sesskey is working fine at installation time.
Bug 2049
(http://moodle.org/bugs/bug.php?op=show&bugid=2049)
2004-10-06 00:03:32 +00:00
stronk7 92ff33eee8 Small typo closing tr... 2004-10-05 23:12:25 +00:00
stronk7 7c957e6052 Now RSS links ae showed properly in SITE course when
user isn't logged.

Solve a problem with if($USER) under PHP5.
2004-10-05 22:51:48 +00:00
stronk7 2a8d898ae0 Now RSS links are displayed ok in SITEID course.
Bug 2048.
(http://moodle.org/bugs/bug.php?op=show&bugid=2048)
2004-10-04 22:05:36 +00:00
moodler d7fef4ea06 Just to help avoid confusion ... it messes up the nice round number
but oh well.  :-)
2004-10-04 17:28:06 +00:00
moodler d7b9ae5984 Send first "change password" mail even if mail was stopped. 2004-10-04 15:47:28 +00:00
moodler 853fdc2076 Added sesskey checking for confirmuser variable 2004-10-04 13:40:32 +00:00
moodler eb1f864d0a Added sesskey checking 2004-10-04 13:38:53 +00:00
moodler 9935789477 Added session key checking to timezone.php 2004-10-04 13:14:50 +00:00
moodler 3d3b104b1b Added sesskey checking to site settings page 2004-10-04 13:08:16 +00:00
moodler ddc2560146 Added sesskey checks to variables page 2004-10-04 12:54:22 +00:00
moodler 87e1fb0e31 Fixes to check arguments better for file manager 2004-10-04 12:04:22 +00:00
moodler 95bd142e85 One more divide-by-zero 2004-10-04 11:49:08 +00:00
moodler c7d5bd00b8 Prevented two divide-by-zero errors (bug 2043) 2004-10-04 11:47:26 +00:00
stronk7 b0fbbd20f6 admin/user.php is now using sesskey. 2004-10-03 17:04:56 +00:00
stronk7 c6ad74fad4 admin/uploaduser.php is now using sesskey. 2004-10-03 16:03:44 +00:00
stronk7 37a192beca admin/register.php is now using sesskey.
Solved a minor bug with the use of one incorrect string.
2004-10-03 15:24:51 +00:00
stronk7 13a2015285 admin/modules.php is now using sesskey. 2004-10-03 15:05:11 +00:00
stronk7 215241b0f0 admin/module.php is now using sesskey. 2004-10-03 09:44:59 +00:00
stronk7 e85705799e admin/lang.php is now using sesskey. 2004-10-03 09:11:11 +00:00
moodler e1f2e71b60 Use a permanent "siteidentifier" code for Moodle.org registrations 2004-10-03 03:45:21 +00:00
stronk7 5657bcafcd admin/filters.php is now using sesskey. 2004-10-03 00:28:22 +00:00
stronk7 0f8c7865b1 admin/enrol.php is now using sesskey. 2004-10-03 00:17:55 +00:00
stronk7 a959544c5b admin/editor.php is now using sesskey. 2004-10-03 00:01:58 +00:00
stronk7 09b1a30d72 admin/creators.php is now using sesskey. 2004-10-02 23:49:22 +00:00
stronk7 9b464d9fb2 admin/blocks.php is now using sesskey. 2004-10-02 23:29:44 +00:00
stronk7 a8b50ee01e admin/block.php is now using sesskey. 2004-10-02 23:09:36 +00:00
stronk7 36b1e811e4 admin/block.php is now using sesskey.
And solved bug when trying to unset config['block']. It isn't
an array but an object.
2004-10-02 23:07:22 +00:00
stronk7 719593e839 admin/backup.php is now using sesskey. 2004-10-02 22:44:25 +00:00
stronk7 249c36eaa0 admin/auth.php is now using sesskey. 2004-10-02 19:43:17 +00:00
stronk7 05c2036b1f admin/admin.php is now using sesskey. 2004-10-02 19:16:16 +00:00
skodak 833b9fd8d5 missing htmlSpecialChars() in INPUT's value 2004-10-02 18:50:25 +00:00
moodler 1721518730 More options for parameter handling ... 2004-10-02 16:11:46 +00:00
moodler bb89f07c23 Don't show hidden activities in activity reports 2004-10-02 15:29:02 +00:00
moodler 27b93cf8e5 Set the sesskey for new admins 2004-10-02 15:21:17 +00:00
ikawhero 10604909ea Changes for language strings 2004-10-02 13:03:59 +00:00
gustav_delius 42cc44d560 provisional fix for bug reported by Timothy Allen in http://moodle.org/mod/forum/discuss.php?d=13388. Provisional because I am not sure I am using the new parameter functions correctly. 2004-10-02 11:09:17 +00:00
ikawhero 7b94708be9 Fixing some bugs in the class 2004-10-01 23:40:34 +00:00
moodler b93635e369 Not ready yet 2004-10-01 15:23:21 +00:00
moodler 22bb7196b0 Don't allow any dots in the subdirectory string for directory resources Thanks Petr! 2004-10-01 15:18:24 +00:00
moodler 98cda81fcf Better check for integer when cleaning parameter 2004-10-01 15:04:21 +00:00
moodler edfa37ae27 Added a new sesskey variable to perform better checks of identity
for some scripts.

Thanks to Petr for finding the exploit!
2004-10-01 14:09:30 +00:00
stronk7 9d90abb900 Included one more translation of links from
assignments to resources. Required in bug 2027.
Easy and not risky.
2004-10-01 11:31:12 +00:00
stronk7 2a135a5f64 More format_text() calls... 2004-10-01 10:26:11 +00:00
stronk7 f85e2d3767 Clean text for category->name 2004-10-01 09:49:06 +00:00
stronk7 b430433c2e clean_text() from entry->concept and aliases!! 2004-10-01 09:46:08 +00:00
stronk7 8259642b1b Changed to new 'point release' schema in STABLE. 2004-10-01 09:23:29 +00:00
moodler ed6804bf75 New functions to check parameters:
required_param()
   optional_param()

Putting them in stable to aid backward compatibility later
2004-10-01 08:40:41 +00:00
stronk7 af796dc774 New version syntax. 2004-10-01 08:36:36 +00:00
ikawhero e39d41ec6b Bug in path for language strings fixed 2004-10-01 04:31:25 +00:00
papita 62b9331113 Latest updates 2004-10-01 04:12:09 +00:00
moodler 9cc29c562c Parameters to common error and notice functions are now always cleaned 2004-10-01 02:38:39 +00:00
moodler 21ba61c3cf Clean error messages just in case scripts have been injected 2004-10-01 02:23:44 +00:00
moodler 9022e87436 Clean action so it isn't shown raw in error messages 2004-10-01 02:18:33 +00:00
moodler 36e62734ec Clean pathname before showing an error 2004-10-01 02:15:03 +00:00
stronk7 d683df8086 Up to 1.4.2 !! 2004-10-01 01:32:10 +00:00
moodler 30a5ea69f5 Latest release notes 2004-09-30 18:15:36 +00:00
moodler 0ed0f0298d Ready for tomorrow 2004-09-30 18:13:58 +00:00
moodler a410c12d23 Fixed bug 2020 in stable 2004-09-30 08:38:20 +00:00
julmis f4df4e9a26 Bug fix for Bug #1999 2004-09-29 22:09:11 +00:00
moodler 73197ea200 Full tags 2004-09-29 16:01:28 +00:00
stronk7 8d3b392d7d More use of SITEID 2004-09-29 15:18:32 +00:00
moodler 1b1779d677 Fixed SQL for PostgreSQL (always use AS). Thanks to Miles Metcalfe from the UK! 2004-09-29 07:54:09 +00:00
moodler ec9111371f Fixed SQL for PostgreSQL (need to always use AS) 2004-09-29 07:52:34 +00:00
moodler e30102faed Checkig pathnames for security 2004-09-29 07:01:33 +00:00
moodler e40bd2e541 Safer processing of pathnames 2004-09-29 06:56:55 +00:00
moodler 2dcadca9a6 Check filenames before including files 2004-09-29 06:51:35 +00:00
moodler b77f5e7a06 Fixes to check path names properly 2004-09-29 05:33:00 +00:00
moodler c99c3dac32 Check resource->type more carefully 2004-09-29 03:11:28 +00:00
stronk7 685a07e8ab Quoted some parameters as they must be. Thanks skodak! 2004-09-28 23:14:31 +00:00
moodler 357df17cb8 Clean modulename before calling include. Thanks again Petr! 2004-09-28 15:54:05 +00:00
moodler 1129e06081 Use the new parameter() function to check parameters better 2004-09-28 15:48:16 +00:00
moodler be35eacfb3 Added new function parameter(). Eventually this will replace all the
optional_variable and require_variable calls anyway, but it's needed
in STABLE to fix some security issues.

See bug 1865.
2004-09-28 15:27:08 +00:00
moodler 74845319b5 Added rtsp to protocols, and moved protocols out to top of the file 2004-09-28 08:25:26 +00:00
moodler ff377eb66b Copy of the change from files/index.php to clean $oldname during rename 2004-09-28 08:02:19 +00:00
moodler 018d7c657a Clean old name as well - thanks, Petr! 2004-09-28 07:59:17 +00:00
moodler c24313bc8c Little typo 2004-09-27 13:51:33 +00:00
moodler 802766d303 Looking at releasing a 1.4.2 within days to include all the recent fixes.
Also, I'm going to change the numbering convention slightly for stable
releases and start using both characters after the date
2004-09-27 13:47:25 +00:00
moodler db5bf3f55a 1) If user or course aren't specified, then assume current user and site course.
2) Closed possible security hole when using userid from form-sunmitted data

   (Thanks again Chief Security Officer Petr!)
2004-09-27 13:24:58 +00:00
moodler 69a791b831 Do safety check on $auth pathname before doing include. Thanks, Petr Skoda! 2004-09-27 12:50:23 +00:00
moodler 2003a0d463 Closed potential security problem (thanks, Petr!) 2004-09-27 01:46:42 +00:00
moodler 62592b861c Moving redirect back again - my fault! bug 2000 2004-09-26 02:41:45 +00:00
stronk7 5fd78134a4 Updated xmilze to official new 1.0.1 version
(it's 'our' version with some comments).
2004-09-25 16:20:35 +00:00
moodler b986e3b007 Upgraded to phpmailer 1.72 - none of the old hacks necessary any more! 2004-09-25 16:01:32 +00:00
moodler 8fcccd5ba8 Restore $CFG->prefix just in case 2004-09-25 15:31:37 +00:00
moodler e335cc7193 EVeryone can login to the site all the time 2004-09-25 15:21:31 +00:00
moodler dc9999208b Daryl Hawes found this fix for bug 1991 2004-09-25 15:17:58 +00:00
moodler 823940bcb3 Only break up subject lines for recent activity bug 1995 2004-09-25 13:10:23 +00:00
stronk7 303eaa286e Added backup & restore to SITE page.
Some changes from hardcoded '1' to SITEID.

See Bug 1928
(http://moodle.org/bugs/bug.php?op=show&bugid=1928)
2004-09-25 11:33:12 +00:00
stronk7 f258f45e31 Scheduled backup improvements:
- Old (>4 hour) directories are deleted at the beginning of the
  execution, so the disk full problem should be out!
- There are 2 types of errors:
    - Controlled errors: The backup process finish although something
        has been wrong.
    - Uncontrolled errors: The backup process dies (memory fault, apache
        problem, electric problem...:-)).
- Now scheduled backup is able to detect previous uncontrolled errors to
  avoid repeating the same course always. It'll be deferred to the next
  execution.
- Every time that a backup cycle has finished, admins will receive an email
  with the summary of the execution.
- The 'ERROR' text will be present in email subjects if something was wrong.

With this, all should be ok (I hope).
2004-09-24 19:01:11 +00:00
stronk7 6d5f3867e9 3 new strings for scheduled backups. 2004-09-24 18:37:03 +00:00
stronk7 e62064ad43 The get_directory_list() function was being executed with
directories excluded so backup_delete_old_dirs() was no
working fine! This should delete REALLY old dirs in sites
with problems in their scheduled backup.
2004-09-24 11:47:03 +00:00
paca70 78a0c06ae6 DB-authentication fix for postgres7.
Fix bud id 1740
2004-09-24 08:41:03 +00:00
paca70 8c589739b6 Fixes for new postgresql database creation 2004-09-24 08:20:42 +00:00
moodler 8a9d7a93af Added two strings for PAM authentication 2004-09-24 04:46:38 +00:00
moodler dd26a66841 Added PAM module for authentication 2004-09-24 04:42:46 +00:00
moodler 8a91a43fae Completely improved database enrolment that actually works this time ;-) 2004-09-23 17:00:20 +00:00
moodler 7b8ebd2771 Redirect to site page earlier if we know it's a site 2004-09-23 16:59:29 +00:00
moodler 146296b733 Allow course creators to restore to new or existing courses too 2004-09-23 11:25:44 +00:00
moodler 95c129edfb Fixed bug in forum ratings with PHP 5 2004-09-23 07:36:20 +00:00
moodler f5650a9675 Highlight was stripping backslashes but I can't see why! 2004-09-23 07:19:57 +00:00
paca70 6b9d8ab22b Added utf8_decode when reading info from ldap.
Thanks to stronk7 pointing this out.
2004-09-22 18:45:05 +00:00
moodler c4b8c0c709 New versions of get_courses and get_courses_page that don't require
a big JOIN between 'course' and 'user_teachers'.

Normally it works fine, but on one server with big tables I saw
a terrible delay that could not be fixed with indexes or by
upgrading MySQL ...

These new versions just avoid the issue.
2004-09-22 15:44:41 +00:00
bobopinna f6c70cf3bf Fixed a problem with onbeforeunload 2004-09-20 14:33:44 +00:00
bobopinna ebd62fdd86 Fixed a typo 2004-09-20 14:32:08 +00:00
moodler 6cce9458a5 Should always use p() function when printing variables 2004-09-20 12:47:56 +00:00
defacer 2c241d2a9d Fix for bug 1957:
Now the calendar behaves correctly even if you "log as" someone else.
2004-09-19 22:18:33 +00:00
moodler 8a70716abf Strip tags from heading before calling print_heading_with_help 2004-09-19 14:00:00 +00:00
moodler 1defa4e7be Pass formatoptions when formatting text so that it's not cleaned 2004-09-19 04:30:58 +00:00
skodak 7b3019e3e6 short php tags - Bug #1956 2004-09-18 22:31:11 +00:00
moodler 1cca75d257 On the front page, if the user is logged in then the calendar blocks
now only show events from their own courses.   bug 1957.
2004-09-18 13:16:01 +00:00
moodler f8ab1daa7c Merged forum post headers feature from HEAD into 1.4.x so that we
can use this on moodle.org posts (among other sites ;-)).
2004-09-18 08:18:02 +00:00
rkingdon 5e56f16030 One more workshop help file... 2004-09-17 17:58:22 +00:00
rkingdon 9b30b693ad Adding the five help files needed by the 1.4 STABLE 2004-09-17 17:39:38 +00:00
moodler 50e752d018 Moved spellcheck button a little :-) 2004-09-17 03:53:37 +00:00
moodler a187eda73f Fix for PHP5 new object referencing ... :-/
http://moodle.org/mod/forum/discuss.php?d=12541
2004-09-17 02:58:16 +00:00
defacer 0afc847f80 Small fixes: change site-detection code to use SITEID and some XHTML stuff
(I 'm going to merge this over to HEAD).
2004-09-16 10:52:00 +00:00
defacer 198f0fb09b Changed all references to hard-coded "1"s to SITEID. Made the logical expressions
in those lines a bit more clear. Removed one obsolete function. Thanks Eloy! :-)
2004-09-16 10:25:08 +00:00
moodler 203469c660 Implemented fix to use draw_rand_array instead of shuffle
(From Bernard Boucher, see bug 1889)

This could use some better testing!
2004-09-16 05:42:18 +00:00
mchurch 5ec9237d2b Fixed remove_teacher, so that a removed teacher is also removed from any
groups they belong to.
2004-09-14 23:41:27 +00:00
mchurch 908b8b9a4f Fixed strip_pages bug. 2004-09-13 23:09:33 +00:00
stronk7 855faed103 Release 1.4.1 info merged from HEAD.
(perhaps anybody forgot to do this before 1.4.1 release?) :-D
2004-09-13 19:31:09 +00:00
moodler 69f1e0a3cf This should make the charset detection automatic ... 2004-09-13 08:20:30 +00:00
moodler b8a6ed644b Checking in fixes to xml_parser_create to specify an encoding (UTF-8)
See Eloy's bug 1927 for details.

After this checkin I'll be immediately testing some backup/restores on PHP 4.
2004-09-13 07:42:13 +00:00
moodler 41e783c3cc Moving on ... 2004-09-12 16:24:11 +00:00
moodler ed6913a320 Merged more stuff from HEAD 2004-09-12 08:21:57 +00:00
moodler 854e0622c3 Merged changes from Trunk 2004-09-11 15:51:37 +00:00
moodler 7d5e12061e Seems very stable, I'll add the email protection filter to stable 2004-09-11 13:29:29 +00:00
moodler 0e468cfc54 FIxed some HTML 2004-09-11 08:35:37 +00:00
mchurch 7dc26ba47b Fixed a bug to export caused by removal of the email filters. 2004-09-10 18:34:52 +00:00
moodler a03a098f63 Looking at a point-release soon to get some of the issues fixed recently out there. 2004-09-10 07:00:04 +00:00
moodler 24fac39fce Default field value for get_course_users should be '', not * 2004-09-10 04:46:26 +00:00
moodler ce31ac9abd Added some instructions for translators on some important strings 2004-09-10 02:21:23 +00:00
stronk7 d7d8758184 Important changes about how view.php (and print.php) retrieve records
from BD to be displayed. Some SQL statements have been modified to
get target records, avoiding a lot of post-processing causing some
bugs like Bug 1912
(http://moodle.org/bugs/bug.php?op=show&bugid=1912)
2004-09-09 18:25:06 +00:00
moodler bef692c32e Undoing the commenting-out I did earlier, since the problem was something else. 2004-09-09 15:57:17 +00:00
mchurch 8d0a452321 Fixed potential undefined variable warning. 2004-09-09 12:47:44 +00:00
fiedorow f80964c99b Do not redeclare auth_user_login upon failed login 2004-09-09 12:26:59 +00:00
defacer 969da74d8b Fix for bug 1921:
I had forgotten to globalize $USER...
2004-09-09 11:53:42 +00:00
defacer a10b3ade4d addslashes() on messages from users before inserting into db. 2004-09-09 10:56:57 +00:00
moodler 06dc71e4e5 Use timestart and timeend when enrolling (or re-enrolling) 2004-09-09 09:28:21 +00:00
moodler 7d8e444763 Improved enrol_student so it can update older records 2004-09-09 09:26:29 +00:00
moodler 33cfeeb2a5 Better check of upcoming enrolment 2004-09-09 09:25:49 +00:00
stronk7 34f5efca4b Solved an small issue when "not clasified" was selected and
we tried to edit categories.
2004-09-09 08:39:16 +00:00
stronk7 c16e25ca1d Simply reformated before solving some bugs to have
ideas clearer.
2004-09-09 08:35:22 +00:00
moodler 14b03b3507 SITEID is more flexible 2004-09-09 06:59:12 +00:00
moodler 5efca069cc Prevent changes in future. :-) 2004-09-09 06:51:31 +00:00
moodler 1b0feaf88a Undoing botched version number - We can't update these like the HEAD version 2004-09-09 06:34:41 +00:00
moodler 010e8ea172 For some reason this include_once doesn't work ... I can't see why though!?
It's only included once and mentioned once throughout the all the wiki code,
but I have a site which errors-out with a redeclaration error ...

This plugin doesn't seem to be needed for highlighting of search  anyway
so I'll uncomment it for now.
2004-09-09 04:49:45 +00:00
fiedorow 1ec72ac59b Updating version date on MOODLE_14_STABLE 2004-09-09 01:55:36 +00:00
stronk7 fe20798cb6 Increase memory_limit to 128 in backups & restore. 2004-09-08 22:44:42 +00:00
stronk7 ba9b14e1e8 Changed to plural (directorypath-->directorypaths) 2004-09-08 18:03:15 +00:00
julmis cf0b27037b Few minor bug fixes, so en_us can be indentified. 2004-09-08 16:50:37 +00:00
stronk7 8915662a32 Added a help button about directory paths... 2004-09-08 16:47:57 +00:00
moodler 2b9011efdc Smilies are now rendered for Markdown format texts 2004-09-08 16:15:19 +00:00
moodler 00067b0836 Made some fixes to get_course_users to make it use particular fields passed
to it as before the recent changes.  This was causing blowout in memory
in the logs for large sites.

http://moodle.org/mod/forum/discuss.php?d=12236

I've done light testing of this only on a small site, I'm about to test it on
some bigger sites.
2004-09-08 15:38:00 +00:00
moodler 527ef6b490 Increase memory limit to cover some sites with too many modules etc ...
We should never hit this limit ...
2004-09-08 07:10:34 +00:00
moodler a2b8c47446 Moved these functions from locallib.php to lib.php so that Workshops
work under recent activity

   workshop_get_recent_mod_activity()
   workshop_print_recent_mod_activity()

Also fixed a problem with mimeinfo being called from locallib.php
without having included the mimetypes.php library
2004-09-08 06:40:28 +00:00
moodler 91e81b7fa4 crikey I really should have checked that last checkin before checking it in 2004-09-07 14:14:30 +00:00
moodler b988c62844 CourseID is now mandatory on file.php 2004-09-07 14:11:59 +00:00
moodler b2e0d6b6a2 Full paths on includes, to help some machines
http://moodle.org/mod/forum/discuss.php?d=11792&parent=58802
2004-09-07 13:38:52 +00:00
defacer 75c45044bb Improving the behavior of the two calendar blocks when they are displayed
at the site front page. See http://moodle.org/mod/forum/discuss.php?d=12149
2004-09-07 10:16:33 +00:00
ikawhero 472b9e478e Updated flash 2004-09-07 06:24:43 +00:00
ikawhero fdcec8bb0c Missing image 2004-09-07 06:24:27 +00:00
moodler e51980345c No round corners needed 2004-09-07 03:05:12 +00:00
moodler a50ded84ea Adding this (optional) feature to 1.4 stable because it seems quite
a few people really need it.
2004-09-07 02:50:03 +00:00
moodler 7c2e85f1bd dbhost may have quotes in it (needs slashes) 2004-09-06 15:50:00 +00:00
defacer ae18de992f Avoid debug mode notice. 2004-09-06 07:54:04 +00:00
stronk7 cda01a6052 Now entries are showed correctly in categories view if they belong
to multiple categories.

Bug 1903
(http://moodle.org/bugs/bug.php?op=show&bugid=1903)
2004-09-06 07:43:07 +00:00
defacer c1d0f7d584 Removed leftovers I got with my last update. 2004-09-06 07:20:38 +00:00
stronk7 b495ed2b48 Changed the way to determine the site course... 2004-09-05 09:20:27 +00:00
moodler 78cb48c712 Updated name of language from "English" to "Chinese" 2004-09-05 07:29:37 +00:00
moodler 6154173f51 Updated files, merged from HEAD 2004-09-05 06:43:57 +00:00
moodler 6472c54bea Merged new files from HEAD 2004-09-05 05:21:09 +00:00
moodler 671daf6e07 Merged new changes from HEAD 2004-09-05 05:19:40 +00:00
moodler d5238eaf23 New release docs merged from HEAD 2004-09-05 05:18:23 +00:00
moodler e56802dacd Removed duplicate fonts 2004-09-05 05:13:33 +00:00
moodler c62346d190 Fix display of "correct answers" during quiz review (for students and teachers) 2004-09-04 08:10:02 +00:00
mchurch 91202daa84 Added <tt> and <code> tags to valid tags. 2004-09-03 18:02:21 +00:00
stronk7 353a72e0a9 Simplify things a bit. I'm no really sure why I was using get_recods()
instead of get_record(). Perhaps it was in my PHP learning process...
2004-09-03 16:29:28 +00:00
moodler f2670b1325 Bump to post 1.4 2004-09-03 12:47:42 +00:00
moodler 9af5afa62c When formatting text, don't need to clean section summaries and
labels of all Javascript
2004-09-03 12:42:56 +00:00
moodler 91b0c4f3e1 FIxed a notice bug 1875 2004-09-03 07:23:21 +00:00
moodler 2f128ef194 Allow uncleaned text in the course (and site) summaries 2004-09-03 03:36:42 +00:00
moodler 4cde340d52 Fixed a bad function call! 2004-09-03 03:16:55 +00:00
mchurch 92b57640a4 Fixed some problems affecting wiki ** and ## formatting tags. 2004-09-02 19:20:29 +00:00
moodler aa3d9221e2 FIxed a bug that was affecting one customer site using Novell LDAP 2004-09-02 17:46:02 +00:00
moodler e0f27e8191 Whoops - forgot a few styles. Not too crucial though 2004-09-02 10:09:21 +00:00
moodler 93e6edcc16 Merged from HEAD 2004-09-02 04:14:53 +00:00
moodler 42e249983d When secure forms is on, allow forms to come from the home page
Primarily this is for the login block but could work for other
blocks too.
2004-09-01 11:23:33 +00:00
martignoni c788cafae7 Little tweak 2004-09-01 10:10:58 +00:00
bobopinna 507af9944b Created this new module intro 2004-08-31 16:08:00 +00:00
bobopinna a57089b02e Updated to new resource format 2004-08-31 15:59:15 +00:00
moodler 0644bc9e12 Merged files that have changed recently since the last merge 2004-08-31 15:40:12 +00:00
bobopinna 387496c8a6 Updated to Moodle 1.4 Stable 2004-08-31 15:08:04 +00:00
moodler b5cfd0e85f Like some horror movie, the second hand on the clock ticks over
in slow motion to the next mark
2004-08-31 13:43:44 +00:00
moodler fd772c442e More robust with bad themes 2004-08-31 13:36:47 +00:00
defacer 2ebaaa5e68 Mike noticed that PHP_SELF was being used here. Replaced all instances with $ME. 2004-08-31 13:31:00 +00:00
moodler e5bd075113 Fixing my recent typo 2004-08-31 12:56:11 +00:00
moodler 88289032b6 FIx install.php for PostgreSQL. I *think* ... this is untested 2004-08-31 12:48:36 +00:00
defacer 9c0458b046 One typo and a glitch
The developer fixes
Lo! Bug-free Moodle!
2004-08-31 12:45:05 +00:00
defacer 4ea496519e Fix for bug 1800:
Adding this harmless column makes the get_recent_enrolments() query legal
in Postgres. Patch submitted by Petri.
2004-08-31 12:26:04 +00:00
moodler 36d0082229 FIxed up recent problems with external authentication
http://moodle.org/mod/forum/discuss.php?d=11723#57001
2004-08-31 12:23:24 +00:00
moodler e0a456a3b3 SLightly reworded the enrollfirst string ... no difference to translators probably 2004-08-31 10:16:56 +00:00
moodler 88a70c8436 FIxed the link in the change I just made 2004-08-31 10:03:54 +00:00
moodler a5b9e4d94e Prevent restricted users from using "login as" 2004-08-31 09:59:59 +00:00
moodler 8913dce495 Fixed some english errors 2004-08-31 09:17:49 +00:00
moodler de3e4de88d Some extra safety when using variables - doesn't appear to be an exploit
in the general case but thanks, Fernando Quintero
2004-08-31 08:52:12 +00:00
moodler d0d1008498 Moved loginhttps into main config screen. Some security has been built
in to prevent accidental enabling on sites without https.
2004-08-31 08:39:22 +00:00
moodler 46808f4afc Added shortcut button to edit course settings (bug 1850) 2004-08-31 07:24:33 +00:00
defacer 7eda7f6cbd Another one bites the dust, this one wasn't needed and noone had any
objections about the array-based notation. RIP.
2004-08-31 06:56:44 +00:00
gustav_delius 21c500f755 my second attempt at getting this block right. 2004-08-30 23:24:03 +00:00
stronk7 dfb203cad6 Release info for 1.4. 2004-08-30 22:57:38 +00:00
gustav_delius 8ec882c22f Access to site participants list is now controlled through $CFG->showsiteparticipantslist 2004-08-30 20:57:26 +00:00
gustav_delius d31cdc0ee9 isteacher() with no arguments now does the expected 2004-08-30 20:54:42 +00:00
moodler f547ee52e7 Merged latest language files from HEAD to STABLE 2004-08-30 19:36:07 +00:00
gustav_delius 129af65665 fixed the isstudent function 2004-08-30 19:09:36 +00:00
moodler b2794b6554 removed junk 2004-08-30 18:48:48 +00:00
gustav_delius 04fd313892 Site participants list now shows correct list of site students 2004-08-30 18:43:13 +00:00
moodler be037b8039 Updated index 2004-08-30 18:19:57 +00:00
moodler f01c72ee73 Added help buttons to the new help file for window settings 2004-08-30 18:17:52 +00:00
moodler 2eebac9129 New help file, based on one from Marc Dastous - thanks Marc! 2004-08-30 18:16:36 +00:00
moodler a8db8bdc3e Fixed an unquoted string 2004-08-30 17:45:51 +00:00
gustav_delius bee864c912 Just tidying up. 2004-08-30 17:28:47 +00:00
moodler 4a51bb7cca No need to put MS up there :-) 2004-08-30 16:57:01 +00:00
moodler 4cbb5d6b4b Default editor fonts now match default Moodle themes 2004-08-30 16:53:21 +00:00
gustav_delius 30bc2fa671 This now implements the new rule on who is a site student, see http://moodle.org/mod/forum/discuss.php?d=8452#56743 2004-08-30 16:42:32 +00:00
moodler 4e65d23fd1 OK, this should finally fix the block upgrading problem.
The problem was that site_admin_menu had not been added to the
database yet when we tried to update the blockinfo for the site.
2004-08-30 15:57:09 +00:00
moodler 327f0cdf22 Er, this will work better ;-) 2004-08-30 14:58:13 +00:00
moodler 5e1eaab52f Checking in a fix for the blocks upgrade on the home page so I can test
it on upgrading a real site.
2004-08-30 14:53:43 +00:00
stronk7 431c81eefa Bug 1831
(http://moodle.org/bugs/bug.php?op=show&bugid=1831)
2004-08-30 14:40:23 +00:00
moodler 6908074777 New configuration variable allusersaresitestudents for Gustav to use
in modules ...
2004-08-30 13:21:16 +00:00
moodler 7f446f68b6 Colored text now works.
Allow CSS "color" styles (which look like a protocol to the security system)
to get through the net.  Luckily anything with a hyphen is let through by
default to everything else the editor produces is OK.
2004-08-30 12:09:14 +00:00
bobopinna 6de08a7a4d Updated to Moodle 1.4 stable 2004-08-30 12:06:43 +00:00
defacer 4172b51f81 Some improvements to the code that assigns sideblocks to new courses.
Moved all "magic strings" to nice and tidy constants.
2004-08-30 11:55:36 +00:00
defacer 52f42b41fc Bug 1848:
As per Gustav's recommendation, event names in Upcoming Events are now hyperlinked.
This required an internal API change, but as far as I can see only block_upcoming
used it the relevant functions so it's ok.
Also, substituded SITEID for the magic number 1 in calendar/lib.php as an aside.
2004-08-30 11:42:07 +00:00
bobopinna 63d9ac4893 Fixed a bug in mounth view 2004-08-30 11:38:09 +00:00
gustav_delius cc4a7edf6f course teachers are also site students. This implements the rule described in http://moodle.org/mod/forum/discuss.php?d=8452#56678.
This commit is probably pointless because the rules are likely to change again soon. I won't merge it onto HEAD.
2004-08-30 08:49:01 +00:00
moodler 1afe51e630 Disabled HTML editor when editing HTML files, for now. See bug 1815 2004-08-30 08:42:21 +00:00
gustav_delius eb4f1a380a course teachers are also site students. 2004-08-30 08:13:14 +00:00
moodler 3977f41672 MOved the Editor on/off to the editor settings page, and tidied up a bit 2004-08-30 07:45:03 +00:00
moodler bce227c2bd Fixed some notices ... bug 1846 .. Thanks Bruno! 2004-08-30 06:28:41 +00:00
moodler 862d076232 Fix from Bruno for 1843 2004-08-30 04:31:45 +00:00
moodler 7ac53b8334 Added chooseparamter ... bug 1824 2004-08-30 04:21:56 +00:00
moodler b42451d5c7 "Choose parameter" is now translatable. 2004-08-30 04:21:24 +00:00
stronk7 e706e6bf35 Check that glossary is correct before edit categories.
Bug 1838
(http://moodle.org/bugs/bug.php?op=show&bugid=1838)
2004-08-29 23:26:04 +00:00
stronk7 4e3cfbb4d8 strip_tags() to some parameters. Thanks skodak.
Bug 1836
(http://moodle.org/bugs/bug.php?op=show&bugid=1836)
2004-08-29 22:46:31 +00:00
stronk7 7f322bf4f0 Typo. Thanks to skodak.
Bug 1839
(http://moodle.org/bugs/bug.php?op=show&bugid=1839)
2004-08-29 22:03:01 +00:00
moodler be50231d4a Upgraded to Markdown 1.0 release 2004-08-29 15:45:22 +00:00
gustav_delius 19425053af added constant SITEID=1 2004-08-29 14:00:49 +00:00
moodler c0c2ae7637 Some small changes .. nothing new just re-phrasing 2004-08-29 13:11:43 +00:00
gustav_delius aef7d2ef0b replacing get_site() in add_to_log() for efficiency. Moodle 1.5 will have this done more thoroughly. 2004-08-29 12:54:39 +00:00
moodler f4fbd4d664 Fixed some uninitialised variables bug 1830 2004-08-29 11:59:19 +00:00
gustav_delius d5fe509f44 add_to_log now updates lastaccess if used on site. See bug 1821 2004-08-29 11:35:08 +00:00
stronk7 420b3d092c Backup is ready for 1.4! Bump. 2004-08-29 10:14:56 +00:00
moodler 19625783b5 By default turn off validation for Moodle 1.4 to make things a bit easier
for some packages.  It can be enabled manually in the SCORM module settings.
2004-08-29 09:03:22 +00:00
moodler c5e704f41b FIxed heading and helpbutton link 2004-08-29 07:37:52 +00:00
moodler fda51b8d69 Fixes to authentication logic to help upgraders (ie admin and guest accounts) 2004-08-29 05:42:11 +00:00
moodler 79424afeb2 Slight rewording, not enough to warrant a new file but translators may
want to make similar changes.
2004-08-29 04:46:02 +00:00
moodler bcabc1aac6 Merged change from HEAD (Display -> Window) 2004-08-29 04:34:46 +00:00
moodler ad13b33c01 Added some stripping of data when displaying logs to help prevent some
possible XSS.  Thanks for highlighting this, Petr Skoda!
2004-08-29 03:54:51 +00:00
stronk7 b50ab1c6ac Define a bit better the 'automatic link' feature at glossary and entry levels.
Bug 1745
(http://moodle.org/bugs/bug.php?op=show&bugid=1745)
2004-08-29 00:06:28 +00:00
stronk7 486e156924 translated to es 2004-08-28 23:44:25 +00:00
stronk7 62368bd2a2 Slighty change
Merged from HEAD
2004-08-28 23:41:26 +00:00
stronk7 bbbfb3193b If we are updating an entry, compare current session user with
existing entry user to avoid some potential problems if secureforms=off
Perhaps too much security? Anyway thanks to skodak

(Bug 1823)
(http://moodle.org/bugs/bug.php?op=show&bugid=1823)
2004-08-28 23:20:39 +00:00
stronk7 c2716331a4 Avoid one notice 2004-08-28 19:58:55 +00:00
stronk7 a2ce999684 HTML editor (format popup) display wrong in glossary comments
Bug 1826
(http://moodle.org/bugs/bug.php?op=show&bugid=1826)
2004-08-28 19:45:35 +00:00
gustav_delius 8c8be6622e added explanation about non-editing teachers to help file 2004-08-28 19:27:46 +00:00
stronk7 ac75511c40 Now students cannot add/edit/delete entries if glossary->studentcanpost = 0
using manual URLs.
2004-08-28 19:10:47 +00:00
stronk7 c14abb9990 - students cannot add/edit/delete comments if it isn't allowed
- students can view comments if they exist
- teachers bypass the commentsallowed field always (this can be useful to create glossaries with public comments from the teacher).
- buttons are showed correctly.

Bug 1814
(http://moodle.org/bugs/bug.php?op=show&bugid=1814)
2004-08-28 18:30:39 +00:00
gustav_delius d97903b9ca improvement of online_users block on front page, suggested by Bruno, see bug # 1821 2004-08-28 18:29:55 +00:00
stronk7 356f6d69d2 Added compatibility in user->auth from 1.3 backups...$CFG->auth is used 2004-08-28 17:28:18 +00:00
gustav_delius d0437b3eab fixed name order in headings on log.php 2004-08-28 17:17:25 +00:00
moodler 799ce03dff Fixed a rarely-occurring problem when deleting a module sometimes. 2004-08-28 16:30:01 +00:00
moodler b4ad8b3d24 Added two new site-wide settings for the resource module so that the
admin can deternine the default state of the collapsible panes on the
resource creation screen.
2004-08-28 16:29:20 +00:00
moodler e8ef939008 Aded user preferences to the collapsing resources. Panel settings are
now remembered per user from one edit to the next.
2004-08-28 15:56:29 +00:00
mchurch ebea2dd039 Fixed some SQL statements so they work with PostGreSQL as well as MySQL.
Fix provided by paca.
2004-08-28 15:10:16 +00:00
defacer be37cf962d Candidate fix for bug 1808:
When upgrading from versions < 1.4, put blocks in the site front page by
default. This was already taken care of when doing a fresh install.

Please check the validity of the fix, if possible. It needs to be extended
to Postgres, Oracle and also merged to HEAD if everything's OK.
2004-08-28 12:33:25 +00:00
stronk7 c75a34409f changed timemodified to timecreated 2004-08-28 11:23:25 +00:00
stronk7 eb4409277e Now action is checked and defaults to edit.
Thanks skodak!

Bug 1813
(http://moodle.org/bugs/bug.php?op=show&bugid=1813)
2004-08-28 11:11:27 +00:00
stronk7 f7311bbe14 Now maxeditingtime for entries work againt timecreated instead of timemodified.
Thanks skodak!

Bug 1822
(http://moodle.org/bugs/bug.php?op=show&bugid=1822)
2004-08-28 10:52:54 +00:00
stronk7 04f1308619 Now user->auth is in backup & restore
Bug 1789
(http://moodle.org/bugs/bug.php?op=show&bugid=1789)
2004-08-28 10:19:34 +00:00
moodler 48143e5a51 Fix from a while back 2004-08-28 08:04:10 +00:00
moodler 223b5ee619 Merged changes from trunk 2004-08-28 07:57:57 +00:00
moodler 56fdffcfeb Fixed bug 1787 - clean_text doesn't work as expected on text with added slashes 2004-08-28 07:55:22 +00:00
moodler eb363f4d99 Added ellipses to buttons "Show settings..." 2004-08-28 05:15:57 +00:00
stronk7 1a625fd590 Some important changes arrive:
- 'editalways' applied to comments.
   - some minor notices out.
   - security bug solved:
      + users cannot edit any comment now.
      + users cannot delete any comment now.
      + users cannot edit any entry now.
      + users cannot delete any antry now.

Thanks to skodak, discovering the bug!!!
2004-08-28 00:23:09 +00:00
stronk7 7e71e010a7 Init 2 arrays 2004-08-27 17:20:02 +00:00
stronk7 bc213d6e8a Now, terms being defined in URLs aren't broken by the <nolink> tag.
Bug 1790
(http://moodle.org/bugs/bug.php?op=show&bugid=1790)
2004-08-27 16:46:22 +00:00
moodler 19dd3171b1 Merged Howard's changes from HEAD 2004-08-27 15:50:18 +00:00
moodler aff55f17a2 It's quick but it will do for now. 2004-08-27 11:47:15 +00:00
moodler 42f291c945 Tidied up form sections with javascript 2004-08-27 09:44:13 +00:00
stronk7 64c548ef7a Error when sending a delete-entry action to logs... 2004-08-27 09:12:03 +00:00
moodler 1404a13a33 Merged from trunk. Changes to file resource. 2004-08-27 09:06:36 +00:00
bobopinna 3e93cbe128 Updated to Moodle 1.4 Stable 2004-08-27 08:06:45 +00:00
julmis dafecdb3d9 Fixing Bug #1792 in Student view :-) 2004-08-27 06:37:54 +00:00
moodler 56e55d22ec Merged from HEAD 2004-08-27 04:42:30 +00:00
moodler ae2b896821 Merged Penny's fix from HEAD 2004-08-27 03:39:47 +00:00
stronk7 68467fbf94 Another duplicated tag....now it's really well-formed :-) 2004-08-27 00:57:35 +00:00
stronk7 b9f5885b4d Found it!!!!
A missing </select> was the cause to the wrong display under Safari!!!
2004-08-27 00:50:22 +00:00
stronk7 9f46966132 Solved some inconsistencies when using the HTML editor and the
format menu!!

One Curiosity: I've discovered a bug in Safari Browser. Edit any
multi-line definition entry and you will see it without line
breaks (not using the HTML editor). I've tried moving that textarea
to other positions in the page and then it works.
2004-08-27 00:00:28 +00:00
julmis 6d388d8e29 Added string editorresettodefaults. 2004-08-26 23:06:36 +00:00
stronk7 b6162f17e2 Strange typo.
Bug 1804
(http://moodle.org/bugs/bug.php?op=show&bugid=1804)
2004-08-26 22:36:17 +00:00
gustav_delius 9b1f47c6bd fixed my own typo, bug 1798 2004-08-26 22:17:07 +00:00
stronk7 ba1b26a543 One notice 2004-08-26 21:37:44 +00:00
julmis 53542fb830 Fixing Bug #1791 for real this time ;-) 2004-08-26 19:58:48 +00:00
julmis d390acad28 Added reset to defaults 2004-08-26 18:30:56 +00:00
julmis c27e555d40 Fix for Bug #1793 2004-08-26 17:27:33 +00:00
julmis 1fed924a16 Spell-button added to images directory 2004-08-26 17:24:58 +00:00
julmis 8009ff257a Spell-button to second row 2004-08-26 17:18:41 +00:00
julmis b7eccbf37f Spell-button to second row
Bug #1791 fix
Better debug mode compatibility
2004-08-26 17:10:36 +00:00
moodler 8428897528 OK, I've been having bad luck with this one. NOW it's fixed properly! 2004-08-26 15:08:11 +00:00
moodler 3a5cc3936d Dammit, I accidentally deleted a line. 2004-08-26 14:46:53 +00:00
bobopinna c0ee89d2dc Updated to Moodle 1.4 stable 2004-08-26 14:41:35 +00:00
moodler 6365268b3b 1. Delete is no longer shown on posts after maxeditingtime has expired
2.  Prune strings are cached (my that's an odd sentence)
3.  Last post links from discussion listing now work when there are no replies
2004-08-26 14:19:50 +00:00
moodler 1e27382ed1 Added Password and Phone 2
Frame is now default again
2004-08-26 12:58:59 +00:00
moodler e75647df91 FIxed bug 1799 - thanks Eloy! 2004-08-26 12:24:20 +00:00
stronk7 19b1bd0bc8 Recode page->userid at restore time. 2004-08-26 10:56:02 +00:00
defacer 72d8255f7e Fix for WHERE clauses in Postgres, submitted by Petri Asikainen.
Apparently, Postgres doesn't like "SELECT * FROM table WHERE 0"
2004-08-26 10:48:51 +00:00
defacer ca27c7f734 Small fixes and improvements. 2004-08-26 09:57:59 +00:00
defacer ebc9be85c7 1. Code restructuring
2. Small logic fixes (e.g. only delete chat_user records WHERE type='sockets')
3. More informative messages when rejecting connections for some reason
4. Better handling of updating chat_user records (lastping updated correctly)
5. Custom error handling, so that PHP errors show up in the trace()s
2004-08-26 08:48:15 +00:00
gustav_delius d1dec2d112 fixed bug in online user list, see http://moodle.org/mod/forum/discuss.php?d=11554 2004-08-26 04:11:46 +00:00
stronk7 f54e807d59 Notice out 2004-08-26 00:10:51 +00:00
mchurch ab37ddd5d2 Updated diff functions to handle HTML formatting a little better. 2004-08-25 20:31:30 +00:00
moodler 6e2c52bad7 This hack doesn't work, and it doesn't matter, but I'm leaving it in
in case someone can fix it later
2004-08-25 16:03:39 +00:00
moodler 7b4bb520ba Course passed properly to messages
Old chat_users all deleted on startup
2004-08-25 14:20:54 +00:00
mchurch ab55cb4107 Reorganized the attachment details page a bit, and added author info. 2004-08-25 13:39:18 +00:00
moodler 785d24f0f6 FIx for recent activity when sockets being used 2004-08-25 13:37:38 +00:00
mchurch 5d2f527449 Changed attachment section on content page to only display if there are
attachments, and then only as a link to the attachments control page.
2004-08-25 13:18:46 +00:00
mchurch b36a469ffc Changed title for attachments on content page. 2004-08-25 13:17:45 +00:00
moodler 1820e4e3f2 Fixed a style, just for Przemyslaw 2004-08-25 12:37:37 +00:00
defacer e55474005b *** TRANSLATOR ALERT ***
This commit contains changes and additions to the chat language file.

Better display and explanations for the chat config screen. Final tweaks to
chatd now that we know which settings we 'll be using and how.
2004-08-25 12:13:06 +00:00
defacer 6e82cd4cd3 Second part of changes. Doing this slowly to keep integrity between this branch and HEAD. 2004-08-25 10:57:43 +00:00
defacer 0b0d2241e3 Lots and lots of improvements! Foremost changes are:
1. The users window is now provided with BOTH JavaScript and HTTP refresh mechanisms
2. The daemon now reliably detects disconnected users even in the absence of chat
   activity. Coupled with the fact that the "users in chats" lists are now manipulated
   only by chatd, they have reached 100% accuracy. Even better than the "normal"
   version, since you can leave your chat open (and idle) for as long as you want
   _without_ being disconnected.
3. Better OOP.
2004-08-25 10:45:13 +00:00
moodler 7d9137d05a Merged fixes from HEAD 2004-08-25 09:21:44 +00:00
moodler 97a8cdafd6 FIxed international display of timezones using string 'strftimedaytime'
http://moodle.org/mod/forum/discuss.php?d=11510
2004-08-25 08:27:53 +00:00
moodler cc876bc667 I was trying to make the glossary link open in the parent window, but
I could not get it to work all the time.
2004-08-25 08:15:15 +00:00
moodler 5b5302faa8 Fixed tabs links when glossary called without id 2004-08-25 07:39:26 +00:00
moodler afa051933d Fixed showentry for POstgreSQLo
Moved SQL to its own function in lib.php
Added links to glossary for each entry
2004-08-25 07:36:29 +00:00
moodler 1281b0a7df Redundant cleaning removed 2004-08-25 05:09:31 +00:00
moodler 092f22eb7f Removing some cleaning see bug 1787 2004-08-25 05:07:30 +00:00
moodler e0f0b7bc2d Added USERID field to restore/backup bug 1788 2004-08-25 04:48:19 +00:00
mchurch e8df6a8946 Restoring summary view to attachments view. 2004-08-25 04:19:48 +00:00
moodler d00f113675 Info page -> History 2004-08-25 03:22:15 +00:00
moodler efe91196f3 Hiding attachment listing altogether 2004-08-25 03:19:50 +00:00
moodler b4d9eecbd0 Fixed my bug with the missing Attachments tab 2004-08-25 03:00:36 +00:00
mchurch d2049a8b7b Cleaned up attachment section of view page. 2004-08-25 02:51:15 +00:00
stronk7 cbac49ac50 Don't clean posted text on input (will be cleaned on output). 2004-08-24 22:56:24 +00:00
stronk7 ea4dec3080 Bump to beta!
I suppose that I cannot update the version number because I'm in a branch,
isn't it?
2004-08-24 22:34:06 +00:00
stronk7 e73ae3f14e Deleted to use the English version until it can be updated. 2004-08-24 21:44:56 +00:00
stronk7 4ec1c2a0bd Release info updated to 1.3.4 2004-08-24 21:42:13 +00:00
stronk7 834fc9fd91 one more warning out 2004-08-24 20:55:40 +00:00
stronk7 f3d2d06518 Avoid some warnings
Bug 1729
(http://moodle.org/bugs/bug.php?op=show&bugid=1729)
2004-08-24 20:35:43 +00:00
gustav_delius 2e32990a63 reduced $module->requires to 052505 after Martin put my new functions into that version. 2004-08-24 15:14:32 +00:00
defacer 4b31fcf608 Still better handling of console output, and starting to experiment with the
new idea of "externally" refreshing the users window for reliability.
2004-08-24 14:29:00 +00:00
moodler dd23e499f3 A default I never checked in auth_pop3mailbox => 'INBOX' 2004-08-24 14:24:14 +00:00
moodler 72fe9309f3 Fixed an echo -> mtrace 2004-08-24 14:23:01 +00:00
defacer 3b905f1aab Adding ID attributes to the frames. Better than NAMEs, for one, and also I
have a devious idea to vanquish user window dropouts once and for all...
2004-08-24 14:02:40 +00:00
defacer f11d5ccb4f Improvements in the way that STDOUT output is handled (turns out the constant
exists in PHP >= 4.3 and it's not defined() at all).

Don't let delete_old_users() kill sockets-type clients, we can do that on
our own, thank you.

Comment some trace()s.
2004-08-24 13:58:01 +00:00
mchurch 75c180d2e3 Set Moodle filtering for wiki text only. 2004-08-24 13:39:03 +00:00
gustav_delius ae7fb33a55 disabled email_protect plugin, see Bug #1775 2004-08-24 12:50:57 +00:00
defacer 7a89b30fac I may not be as productive a translator as Koen, but the ? lines in my CVS
updates were approaching the third page boundary! ;-)
2004-08-24 12:27:20 +00:00
defacer d9bdf8cb96 Brand new spiffy shining bright!
1. REAL support for command-line parameters! Pretty good too!
   (actually don't tell Jon, it gets to his head)
2. Can you show the "users in chat" normally now? Please?
2004-08-24 12:22:13 +00:00
stronk7 1a2e6cfb12 Now some CFG->glossary_XXXX are checked in lib.php.
Bug 1764
(http://moodle.org/bugs/bug.php?op=show&bugid=1764)
2004-08-24 11:20:01 +00:00
gustav_delius df85e55750 All the modules in which I made changes require the latest version of datalib.php. 2004-08-24 10:13:41 +00:00
moodler dba8c2802e Merged some changes from HEAD 2004-08-24 06:48:42 +00:00
moodler 67f2fae171 FIxed Upgrade feedback from SQL 2004-08-24 04:57:00 +00:00
gustav_delius bc1ed83f43 fixed small typo 2004-08-23 21:27:52 +00:00
gustav_delius 2559db73e6 fixed bug 1748 2004-08-23 21:26:03 +00:00
gustav_delius 956ad3b8a8 removed ancient german release notes 2004-08-23 20:46:01 +00:00
gustav_delius 0420e8715d removed empty bullet point 2004-08-23 20:34:52 +00:00
17251 changed files with 602188 additions and 2107854 deletions
-27
View File
@@ -1,27 +0,0 @@
# This file specifies intentionally untracked files that all Moodle git
# repositories should ignore. It is recommended not to modify this file in your
# local clone. Instead, use .git/info/exclude and add new records there as
# needed.
#
# Example: if you deploy a contributed plugin mod/foobar into your site, put
# the following line into .git/info/exclude file in your Moodle clone:
# /mod/foobar/
#
# See gitignore(5) man page for more details
#
/config.php
/lib/editor/tinymce/extra/tools/temp/
*~
*.swp
/tags
/TAGS
/cscope.*
/.patches/
/.idea/
/nbproject/
CVS
.DS_Store
/.settings/
/.project
/.buildpath
/.cache
+12256
View File
File diff suppressed because it is too large Load Diff
-674
View File
@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 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, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU 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. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+51 -29
View File
@@ -1,29 +1,51 @@
QUICK INSTALL
=============
For the impatient, here is a basic outline of the
installation process, which normally takes me only
a few minutes:
1) Move the Moodle files into your web directory.
2) Create a single database for Moodle to store all
it's tables in (or choose an existing database).
3) Visit your Moodle site with a browser, you should
be taken to the install.php script, which will lead
you through creating a config.php file and then
setting up Moodle, creating an admin account etc.
4) Set up a cron task to call the file admin/cron.php
every five minutes or so.
For more information, see the INSTALL DOCUMENTATION:
http://docs.moodle.org/en/Installing_Moodle
Good luck and have fun!
Martin Dougiamas, Lead Developer
README $Id$
------
If you are installing the first time, then you
should read the installation guide which is
part of the Moodle documentation (along with
information about upgrading etc):
http://moodle.com/doc/
There is a copy of all this documentation as part of
this Moodle distribution. You can access your local
copy of the installation guide here:
lang/en/docs/install.html
Once Moodle is installed on your machine, then
you can also access a local copy of all this
documentation (localised to your language) at:
http://yourmoodlesite.com/doc/
For the impatient, here is a basic outline of the
installation process, which normally takes me only
a few minutes:
1) Move the Moodle files into your web directory.
2) Create an empty directory somewhere to store
uploaded files (NOT accessible via the web).
This directory must be writeable by the web server
process.
3) Create a single database for Moodle to store all
it's tables in (or choose an existing database).
4) Copy the file config-dist.php to config.php, and
edit it with all your own settings.
5) Visit your new home page with a web browser. Moodle
will lead you through the rest of the setup,
creating an admin account and so on.
6) Set up a cron task to call the file admin/cron.php
every five minutes or so.
Cheers!
Martin Dougiamas
-34
View File
@@ -1,34 +0,0 @@
------------------------
Moodle Trademark License
------------------------
The name Moodle™ is a registered trademark of the Moodle Trust.
A key part of the business model that allows us to produce and
distribute Moodle as completely Free open source software is that
we restrict the commercial use of the Moodle trademark to those
who have contracted to support Moodle development (Moodle Partners).
If you are intending to use the name (and/or logo) to advertise
generic Moodle™ services (eg Moodle Hosting, Moodle Support,
Moodle Certification, Moodle Training, Moodle Consulting,
Moodle Customisation, Moodle Courseware Development, Moodle
Theme design, Moodle Integrations, Moodle Installations, etc)
or as the name of a software package, then you must seek
direct permission in writing from the Moodle Trust via the
moodle.com helpdesk, in accordance with normal trademark
restrictions.
There are no restrictions on how you use the name in other
contexts (for example, if you use Moodle just to provide
courses then you can use the name freely to refer to it.)
If you aren't sure of a particular case, please ask us via
http://moodle.com/helpdesk: we'll be happy to either provide
you with official permission in writing or help you fix
your wording.
Martin Dougiamas
Executive Director
Moodle Trust
http://moodle.com
+89
View File
@@ -0,0 +1,89 @@
<form name="adminform" id="adminform" method="post" action="admin.php">
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table align="center" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">
<?php echo count($admins) . " ". $strexistingadmins ?>
</td>
<td></td>
<td valign="top">
<?php echo $usercount . " " . $strpotentialadmins ?>
</td>
</tr>
<tr>
<td valign="top">
<select name="removeselect[]" size="20" id="removeselect" multiple
onFocus="document.adminform.add.disabled=true;
document.adminform.remove.disabled=false;
document.adminform.addselect.selectedIndex=-1;">
<?php
if (count($admins) == 1) {
$disabled = 'disabled';
$removebuttontype = 'hidden';
} else {
$disabled = '';
$removebuttontype = 'submit';
}
foreach ($admins as $admin) {
$fullname = fullname($admin, true);
echo "<option value=\"$admin->id\" $disabled>".$fullname.", ".$admin->email."</option>\n";
}
?>
</select></td>
<td valign="top">
<br />
<input name="add" type="submit" id="add" value="&larr;" />
<br />
<input name="remove" type="<?php echo $removebuttontype ?>" id="remove" value="&rarr;" />
<br />
</td>
<td valign="top">
<select name="addselect[]" size="20" id="addselect" multiple
onFocus="document.adminform.add.disabled=false;
document.adminform.remove.disabled=true;
document.adminform.removeselect.selectedIndex=-1;">
<?php
if (!empty($searchusers)) {
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
foreach ($searchusers as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
echo "</optgroup>\n";
}
if (!empty($users)) {
foreach ($users as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
}
?>
</select>
<br />
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
onFocus ="document.adminform.add.disabled=true;
document.adminform.remove.disabled=true;
document.adminform.removeselect.selectedIndex=-1;
document.adminform.addselect.selectedIndex=-1;"
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
if (keyCode == 13) {
document.adminform.previoussearch.value=1;
document.adminform.submit();
} " />
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
<?php
if (!empty($searchusers)) {
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
}
?>
</td>
</tr>
</table>
</form>
+122
View File
@@ -0,0 +1,122 @@
<?PHP // $Id$
// Admin-only script to assign administrative rights to users
require_once("../config.php");
define("MAX_USERS_PER_PAGE", 50);
optional_variable($add, "");
optional_variable($remove, "");
optional_variable($search, "");
if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
require_login();
if (!isadmin()) {
error("You must be an administrator to use this page.");
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
$primaryadmin = get_admin();
/// If you want any administrator to have the ability to assign admin
/// rights, then comment out the following if statement
if ($primaryadmin->id != $USER->id) {
error("You must be the primary administrator to use this page.");
}
/// assign all of the configurable language strings
$stringstoload = array (
"assignadmins",
"administration",
"existingadmins",
"potentialadmins",
"search",
"users",
"searchresults",
"showall"
);
foreach ($stringstoload as $stringtoload){
$strstringtoload = "str" . $stringtoload;
$$strstringtoload = get_string($stringtoload);
}
print_header("$site->shortname: $strassignadmins",
"$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strassignadmins", "adminform.searchtext");
if (!$frm = data_submitted()) {
print_simple_box("<center>".get_string("adminhelpassignadmins")."</center>", "center", "50%");
/// A form was submitted so process the input
} else {
if (!empty($frm->add) and !empty($frm->addselect)) {
foreach ($frm->addselect as $addadmin) {
if (! add_admin($addadmin)) {
error("Could not add admin with user id $addadmin!");
}
}
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
$admins = get_admins();
if (count($admins) > count($frm->removeselect)) {
foreach ($frm->removeselect as $removeadmin) {
if (! remove_admin($removeadmin)) {
error("Could not remove admin with user id $removeadmin!");
}
}
}
} else if (!empty($frm->showall)) {
unset($frm->searchtext);
$frm->previoussearch = 0;
}
}
/// Is there a current search?
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
/// Get all existing admins
$admins = get_admins();
$adminarray = array();
foreach ($admins as $admin) {
$adminarray[] = $admin->id;
}
$adminlist = implode(',', $adminarray);
unset($adminarray);
/// Get search results excluding any current admins
if (!empty($frm->searchtext) and $previoussearch) {
$searchusers = get_users(true, $frm->searchtext, true, $adminlist, 'firstname ASC, lastname ASC',
'', '', 0, 99999, 'id, firstname, lastname, email');
$usercount = get_users(false, '', true, $adminlist);
}
/// If no search results then get potential users excluding current admins
if (empty($searchusers)) {
if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
0, 99999, 'id, firstname, lastname, email') ) {
$users = array();
}
$usercount = count($users);
}
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
$previoussearch = ($previoussearch) ? '1' : '0';
include('./admin.html');
print_footer();
?>
+170 -93
View File
@@ -1,103 +1,180 @@
<?php
<?PHP // $Id$
// config.php - allows admin to edit all configuration variables
/**
* Allows admin to edit all auth plugin settings.
*
* JH: copied and Hax0rd from admin/enrol.php and admin/filters.php
*
*/
include("../config.php");
require_login();
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
if (!$site = get_site()) {
redirect("index.php");
}
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
if (!isadmin()) {
error("Only the admin can use this page");
}
$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
$PAGE->set_url($returnurl);
/// If data submitted, then process and store.
$action = optional_param('action', '', PARAM_ACTION);
$auth = optional_param('auth', '', PARAM_PLUGIN);
if ($config = data_submitted()) {
get_enabled_auth_plugins(true); // fix the list of enabled auths
if (empty($CFG->auth)) {
$authsenabled = array();
} else {
$authsenabled = explode(',', $CFG->auth);
$config = (array)$config;
validate_form($config, $err);
if (count($err) == 0) {
print_header();
foreach ($config as $name => $value) {
if (! set_config($name, $value)) {
notify("Problem saving config $name as $value");
}
}
redirect("auth.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
exit;
} else {
foreach ($err as $key => $value) {
$focus = "form.$key";
}
}
}
/// Otherwise fill and print the form.
if (empty($config)) {
$config = $CFG;
}
$modules = get_list_of_plugins("auth");
foreach ($modules as $module) {
$options[$module] = get_string("auth_$module"."title", "auth");
}
asort($options);
if (isset($_GET['auth'])) {
$auth = $_GET['auth'];
} else {
$auth = $config->auth;
}
$auth = clean_filename($auth);
require_once("$CFG->dirroot/auth/$auth/lib.php"); //just to make sure that current authentication functions are loaded
if (! isset($config->guestloginbutton)) {
$config->guestloginbutton = 1;
}
if (! isset($config->auth_instructions)) {
$config->auth_instructions = "";
}
if (! isset($config->changepassword)) {
$config->changepassword = "";
}
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
foreach ($user_fields as $user_field) {
$user_field = "auth_user_$user_field";
if (! isset($config->$user_field)) {
$config->$user_field = "";
}
}
if (empty($focus)) {
$focus = "";
}
$guestoptions[0] = get_string("hide");
$guestoptions[1] = get_string("show");
$createoptions[0] = get_string("no");
$createoptions[1] = get_string("yes");
$stradministration = get_string("administration");
$strauthentication = get_string("authentication");
$strauthenticationoptions = get_string("authenticationoptions","auth");
$strsettings = get_string("settings");
$strusers = get_string("users");
print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
"<A HREF=\"index.php\">$stradministration</A> -> <a href=\"users.php\">$strusers</a> -> $strauthenticationoptions", "$focus");
echo "<CENTER><P><B>";
echo "<form TARGET=\"{$CFG->framename}\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
print_string("chooseauthmethod","auth");
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
echo "</B></P></CENTER>";
print_simple_box_start("center", "100%", "$THEME->cellheading");
print_heading($options[$auth]);
print_simple_box_start("center", "60%", "$THEME->cellcontent");
print_string("auth_$auth"."description", "auth");
print_simple_box_end();
echo "<hr>";
print_heading($strsettings);
echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
require_once("$CFG->dirroot/auth/$auth/config.html");
if ($auth != "email" and $auth != "none" and $auth != "manual") {
echo "<tr valign=\"top\">";
echo "<td align=right nowrap><p>";
print_string("changepassword", "auth");
echo ":</p></td>";
echo "<td>";
echo "<input type=\"text\" name=\"changepassword\" size=40 value=\"$config->changepassword\">";
echo "</td>";
echo "<td>";
print_string("changepasswordhelp","auth");
echo "</td></tr>";
}
echo "<tr valign=\"top\">";
echo "<td align=right nowrap><p>";
print_string("guestloginbutton", "auth");
echo ":</p></td>";
echo "<td>";
choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
echo "</td>";
echo "<td>";
print_string("showguestlogin","auth");
echo "</td></tr>";
if (function_exists('auth_user_create')){
echo "<tr valign=\"top\">";
echo "<td align=right nowrap><p>";
print_string("auth_user_create", "auth");
echo ":</p></td>";
echo "<td>";
choose_from_menu($createoptions, "auth_user_create", $config->auth_user_create, "");
echo "</td>";
echo "<td>";
print_string("auth_user_creation","auth");
echo "</td></tr>";
}
echo "</table><center><p><input type=\"submit\" value=\"";
print_string("savechanges");
echo "\"></p></center></form>";
print_simple_box_end();
print_footer();
exit;
/// Functions /////////////////////////////////////////////////////////////////
function validate_form(&$form, &$err) {
// if (empty($form->fullname))
// $err["fullname"] = get_string("missingsitename");
return;
}
if (!empty($auth) and !exists_auth_plugin($auth)) {
print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
}
////////////////////////////////////////////////////////////////////////////////
// process actions
if (!confirm_sesskey()) {
redirect($returnurl);
}
switch ($action) {
case 'disable':
// remove from enabled list
$key = array_search($auth, $authsenabled);
if ($key !== false) {
unset($authsenabled[$key]);
set_config('auth', implode(',', $authsenabled));
}
if ($auth == $CFG->registerauth) {
set_config('registerauth', '');
}
session_gc(); // remove stale sessions
break;
case 'enable':
// add to enabled list
if (!in_array($auth, $authsenabled)) {
$authsenabled[] = $auth;
$authsenabled = array_unique($authsenabled);
set_config('auth', implode(',', $authsenabled));
}
session_gc(); // remove stale sessions
break;
case 'down':
$key = array_search($auth, $authsenabled);
// check auth plugin is valid
if ($key === false) {
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
}
// move down the list
if ($key < (count($authsenabled) - 1)) {
$fsave = $authsenabled[$key];
$authsenabled[$key] = $authsenabled[$key + 1];
$authsenabled[$key + 1] = $fsave;
set_config('auth', implode(',', $authsenabled));
}
break;
case 'up':
$key = array_search($auth, $authsenabled);
// check auth is valid
if ($key === false) {
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
}
// move up the list
if ($key >= 1) {
$fsave = $authsenabled[$key];
$authsenabled[$key] = $authsenabled[$key - 1];
$authsenabled[$key - 1] = $fsave;
set_config('auth', implode(',', $authsenabled));
}
break;
default:
break;
}
redirect($returnurl);
?>
-179
View File
@@ -1,179 +0,0 @@
<?php
/**
* Edit configuration for an individual auth plugin
*/
require_once '../config.php';
require_once $CFG->libdir.'/adminlib.php';
$auth = required_param('auth', PARAM_PLUGIN);
$PAGE->set_pagetype('admin-auth-' . $auth);
admin_externalpage_setup('authsetting'.$auth);
$authplugin = get_auth_plugin($auth);
$err = array();
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageauths";
// save configuration changes
if ($frm = data_submitted() and confirm_sesskey()) {
$authplugin->validate_form($frm, $err);
if (count($err) == 0) {
// save plugin config
if ($authplugin->process_config($frm)) {
// save field lock configuration
foreach ($frm as $name => $value) {
if (preg_match('/^lockconfig_(.+?)$/', $name, $matches)) {
$plugin = "auth/$auth";
$name = $matches[1];
set_config($name, $value, $plugin);
}
}
redirect($returnurl);
exit;
}
} else {
foreach ($err as $key => $value) {
$focus = "form.$key";
}
}
} else {
$frmlegacystyle = get_config('auth/'.$auth);
$frmnewstyle = get_config('auth_'.$auth);
$frm = (object)array_merge((array)$frmlegacystyle, (array)$frmnewstyle);
}
$user_fields = $authplugin->userfields;
//$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "institution", "department", "address", "city", "country", "description", "idnumber", "lang");
/// Get the auth title (from core or own auth lang files)
$authtitle = $authplugin->get_title();
/// Get the auth descriptions (from core or own auth lang files)
$authdescription = $authplugin->get_description();
// output configuration form
echo $OUTPUT->header();
// choose an authentication method
echo "<form id=\"authmenu\" method=\"post\" action=\"auth_config.php\">\n";
echo "<div>\n";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
echo "<input type=\"hidden\" name=\"auth\" value=\"".$auth."\" />\n";
// auth plugin description
echo $OUTPUT->box_start();
echo $OUTPUT->heading($authtitle);
echo $OUTPUT->box_start('informationbox');
echo $authdescription;
echo $OUTPUT->box_end();
echo "<hr />\n";
$authplugin->config_form($frm, $err, $user_fields);
echo $OUTPUT->box_end();
echo '<p style="text-align: center"><input type="submit" value="' . get_string("savechanges") . "\" /></p>\n";
echo "</div>\n";
echo "</form>\n";
echo $OUTPUT->footer();
exit;
/// Functions /////////////////////////////////////////////////////////////////
// Good enough for most auth plugins
// but some may want a custom one if they are offering
// other options
// Note: lockconfig_ fields have special handling.
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
global $OUTPUT;
echo '<tr><td colspan="3">';
if ($retrieveopts) {
echo $OUTPUT->heading(get_string('auth_data_mapping', 'auth'));
} else {
echo $OUTPUT->heading(get_string('auth_fieldlocks', 'auth'));
}
echo '</td></tr>';
$lockoptions = array ('unlocked' => get_string('unlocked', 'auth'),
'unlockedifempty' => get_string('unlockedifempty', 'auth'),
'locked' => get_string('locked', 'auth'));
$updatelocaloptions = array('oncreate' => get_string('update_oncreate', 'auth'),
'onlogin' => get_string('update_onlogin', 'auth'));
$updateextoptions = array('0' => get_string('update_never', 'auth'),
'1' => get_string('update_onupdate', 'auth'));
$pluginconfig = get_config("auth/$auth");
// helptext is on a field with rowspan
if (empty($helptext)) {
$helptext = '&nbsp;';
}
foreach ($user_fields as $field) {
// Define some vars we'll work with
if (!isset($pluginconfig->{"field_map_$field"})) {
$pluginconfig->{"field_map_$field"} = '';
}
if (!isset($pluginconfig->{"field_updatelocal_$field"})) {
$pluginconfig->{"field_updatelocal_$field"} = '';
}
if (!isset($pluginconfig->{"field_updateremote_$field"})) {
$pluginconfig->{"field_updateremote_$field"} = '';
}
if (!isset($pluginconfig->{"field_lock_$field"})) {
$pluginconfig->{"field_lock_$field"} = '';
}
// define the fieldname we display to the user
$fieldname = $field;
if ($fieldname === 'lang') {
$fieldname = get_string('language');
} elseif (preg_match('/^(.+?)(\d+)$/', $fieldname, $matches)) {
$fieldname = get_string($matches[1]) . ' ' . $matches[2];
} elseif ($fieldname == 'url') {
$fieldname = get_string('webpage');
} else {
$fieldname = get_string($fieldname);
}
if ($retrieveopts) {
$varname = 'field_map_' . $field;
echo '<tr valign="top"><td align="right">';
echo '<label for="lockconfig_'.$varname.'">'.$fieldname.'</label>';
echo '</td><td>';
echo "<input id=\"lockconfig_{$varname}\" name=\"lockconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\" />";
echo '<div style="text-align: right">';
echo '<label for="menulockconfig_field_updatelocal_'.$field.'">'.get_string('auth_updatelocal', 'auth') . '</label>&nbsp;';
echo html_writer::select($updatelocaloptions, "lockconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, false);
echo '<br />';
if ($updateopts) {
echo '<label for="menulockconfig_field_updateremote_'.$field.'">'.get_string('auth_updateremote', 'auth') . '</label>&nbsp;';
echo html_writer::select($updateextoptions, "lockconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, false);
echo '<br />';
}
echo '<label for="menulockconfig_field_lock_'.$field.'">'.get_string('auth_fieldlock', 'auth') . '</label>&nbsp;';
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
echo '</div>';
} else {
echo '<tr valign="top"><td align="right">';
echo '<label for="menulockconfig_field_lock_'.$field.'">'.$fieldname.'</label>';
echo '</td><td>';
echo html_writer::select($lockoptions, "lockconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, false);
}
echo '</td>';
if (!empty($helptext)) {
echo '<td rowspan="' . count($user_fields) . '">' . $helptext . '</td>';
$helptext = '';
}
echo '</tr>';
}
}
+137
View File
@@ -0,0 +1,137 @@
<?PHP // $Id$
// backup.php - allows admin to edit all configuration variables for scheduled backups
require_once("../config.php");
require_once("../backup/lib.php");
require_once("../backup/backup_scheduled.php");
require_login();
if (!isadmin()) {
error("Only an admin can use this page");
}
if (!$site = get_site()) {
error("Site isn't defined!");
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
//Initialise error variables
$error = false;
$sche_destination_error = "";
/// If data submitted, then process and store.
if ($config = data_submitted()) {
//First of all we check that everything is correct
//Check for trailing slash and backslash in backup_sche_destination
if (!empty($backup_sche_destination) and
(substr($backup_sche_destination,-1) == "/" or substr($backup_sche_destination,-1) == "\\")) {
$error = true;
$sche_destination_error = get_string("pathslasherror");
//Now check that backup_sche_destination dir exists
} else if (!empty($backup_sche_destination) and
!is_dir($backup_sche_destination)) {
$error = true;
$sche_destination_error = get_string("pathnotexists");
}
//We need to do some weekdays conversions prior to continue
$i = 0;
$temp = "";
$a_config = (array)$config;
while ($i<7) {
$tocheck = "dayofweek_".$i;
if (isset($a_config[$tocheck])) {
$temp .= "1";
} else {
$temp .= "0";
}
unset($a_config[$tocheck]);
$i++;
}
$a_config['backup_sche_weekdays'] = $temp;
$config = (object)$a_config;
//weekdays conversions done. Continue
print_header();
foreach ($config as $name => $value) {
backup_set_config($name, $value);
}
//And now, we execute schedule_backup_next_execution() for each course in the server to have the next
//execution time updated automatically everytime it's changed.
$status = true;
//get admin
$admin = get_admin();
if (!$admin) {
$status = false;
}
//get backup config
if (! $backup_config = backup_get_config()) {
$status = false;
}
if ($status) {
//get courses
if ($courses = get_records("course")) {
//For each course, we check (insert, update) the backup_course table
//with needed data
foreach ($courses as $course) {
//We check if the course exists in backup_course
$backup_course = get_record("backup_courses","courseid",$course->id);
//If it doesn't exist, create
if (!$backup_course) {
$temp_backup_course->courseid = $course->id;
$newid = insert_record("backup_courses",$temp_backup_course);
//And get it from db
$backup_course = get_record("backup_courses","id",$newid);
}
//Now, calculate next execution of the course
$nextstarttime = schedule_backup_next_execution ($backup_course,$backup_config,time(),$admin->timezone);
//Save it to db
set_field("backup_courses","nextstarttime",$nextstarttime,"courseid",$backup_course->courseid);
}
}
}
if (!$error) {
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
exit;
}
}
/// Otherwise print the form.
$stradmin = get_string("administration");
$strconfiguration = get_string("configuration");
$strbackup = get_string("backup");
print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname,
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> ".
$strbackup);
echo "<p align=right><a href=\"../backup/log.php\">".get_string("logs")."</a></p>";
print_heading($strbackup);
print_simple_box("<center>".get_string("adminhelpbackup")."</center>", "center", "50%");
echo "<br />";
print_simple_box_start("center", "", "$THEME->cellheading");
//Check for required functions...
if(!function_exists('utf8_encode')) {
print_simple_box("<font color=\"red\">You need to add XML support to your PHP installation</font>", "center", "70%", "$THEME->cellheading", "20", "noticebox");
}
include ("$CFG->dirroot/backup/config.html");
print_simple_box_end();
print_footer();
?>
+36 -48
View File
@@ -1,76 +1,64 @@
<?php
<?PHP // $Id$
// block.php - allows admin to edit all local configuration variables for a block
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/blocklib.php');
$blockid = required_param('block', PARAM_INT);
require_login();
if(!$blockrecord = blocks_get_record($blockid)) {
print_error('blockdoesnotexist', 'error');
if (!isadmin()) {
error('Only an admin can use this page');
}
if (!$site = get_site()) {
error("Site isn't defined!");
}
admin_externalpage_setup('blocksetting'.$blockrecord->name);
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
$block = block_instance($blockrecord->name);
require_variable($_REQUEST['block']);
$blockid = intval($_REQUEST['block']);
if(($blockrecord = get_record('blocks', 'id', $blockid)) === false) {
error('This block does not exist');
}
$block = block_instance($blockrecord->name, NULL);
if($block === false) {
print_error('blockcannotinistantiate', 'error');
error('Problem in instantiating block object');
}
// Define the data we're going to silently include in the instance config form here,
// so we can strip them from the submitted data BEFORE handling it.
$hiddendata = array(
'block' => $blockid,
'sesskey' => sesskey()
);
/// If data submitted, then process and store.
/// If data submitted, then process and store.
if ($config = data_submitted()) {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', 'error');
}
if(!$block->has_config()) {
print_error('blockcannotconfig', 'error');
}
$remove = array_keys($hiddendata);
foreach($remove as $item) {
unset($config->$item);
}
$block->config_save($config);
unset($config->block); // This will always be set if we have reached this point
$block->handle_config($config);
print_header();
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
exit;
}
/// Otherwise print the form.
/// Otherwise print the form.
$stradmin = get_string('administration');
$strconfiguration = get_string('configuration');
$strmanageblocks = get_string('manageblocks');
$strblockname = $block->get_title();
echo $OUTPUT->header();
print_header($site->shortname.': '.$strblockname.": $strconfiguration", $site->fullname,
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> ".
"<a href=\"blocks.php\">$strmanageblocks</a> -> ".$strblockname);
echo $OUTPUT->heading($strblockname);
print_heading($strblockname);
echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
'It must be updated by a developer to use a settings.php file.');
echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
print_simple_box('<center>'.get_string('configwarning').'</center>', 'center', '50%');
echo '<br />';
echo '<form method="post" action="block.php">';
echo '<p>';
foreach($hiddendata as $name => $val) {
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
}
echo '</p>';
echo $OUTPUT->box_start();
include($CFG->dirroot.'/blocks/'. $block->name() .'/config_global.html');
echo $OUTPUT->box_end();
echo '</form>';
echo $OUTPUT->footer();
$block->print_config();
print_footer();
?>
+113 -195
View File
@@ -1,259 +1,177 @@
<?php
<?PHP // $Id$
// Allows the admin to configure blocks (hide/show, delete and configure)
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->libdir.'/blocklib.php');
admin_externalpage_setup('manageblocks');
optional_variable($_GET['hide']);
optional_variable($_GET['show']);
optional_variable($_GET['delete']);
optional_variable($_GET['confirm'], 0);
$delete = $_GET['delete']; // Dependency remover
require_login();
if (!isadmin()) {
error("Only administrators can use this page!");
}
if (!$site = get_site()) {
error("Site isn't defined!");
}
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$unprotect = optional_param('unprotect', 0, PARAM_INT);
$protect = optional_param('protect', 0, PARAM_INT);
/// Print headings
$stradministration = get_string('administration');
$strconfiguration = get_string('configuration');
$strmanageblocks = get_string('manageblocks');
$strdelete = get_string('delete');
$strversion = get_string('version');
$strhide = get_string('hide');
$strshow = get_string('show');
$strsettings = get_string('settings');
$strcourses = get_string('blockinstances', 'admin');
$strcourses = get_string('courses');
$strname = get_string('name');
$strshowblockcourse = get_string('showblockcourse');
$strprotecthdr = get_string('blockprotect', 'admin'). $OUTPUT->help_icon('blockprotect','admin');
$strprotect = get_string('blockprotect', 'admin');
$strunprotect = get_string('blockunprotect', 'admin');
print_header("$site->shortname: $strmanageblocks", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanageblocks");
print_heading($strmanageblocks);
/// If data submitted, then process and store.
if (!empty($hide) && confirm_sesskey()) {
if (!$block = $DB->get_record('block', array('id'=>$hide))) {
print_error('blockdoesnotexist', 'error');
if (!empty($_GET['hide']) and confirm_sesskey()) {
if (!$block = get_record('blocks', 'id', $_GET['hide'])) {
error("Block doesn't exist!");
}
$DB->set_field('block', 'visible', '0', array('id'=>$block->id)); // Hide block
admin_get_root(true, false); // settings not required - only pages
set_field('blocks', 'visible', '0', 'id', $block->id); // Hide block
}
if (!empty($show) && confirm_sesskey() ) {
if (!$block = $DB->get_record('block', array('id'=>$show))) {
print_error('blockdoesnotexist', 'error');
if (!empty($_GET['show']) and confirm_sesskey() ) {
if (!$block = get_record('blocks', 'id', $_GET['show'])) {
error("Block doesn't exist!");
}
$DB->set_field('block', 'visible', '1', array('id'=>$block->id)); // Show block
admin_get_root(true, false); // settings not required - only pages
set_field('blocks', 'visible', '1', 'id', $block->id); // Show block
}
if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
$undeletableblocktypes = array('navigation', 'settings');
} else if (is_string($CFG->undeletableblocktypes)) {
$undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
} else {
$undeletableblocktypes = $CFG->undeletableblocktypes;
}
if (!empty($delete) and confirm_sesskey()) {
if (!empty($protect) && confirm_sesskey()) {
if (!$block = $DB->get_record('block', array('id'=>$protect))) {
print_error('blockdoesnotexist', 'error');
}
if (!in_array($block->name, $undeletableblocktypes)) {
$undeletableblocktypes[] = $block->name;
set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
}
admin_get_root(true, false); // settings not required - only pages
}
if (!empty($unprotect) && confirm_sesskey()) {
if (!$block = $DB->get_record('block', array('id'=>$unprotect))) {
print_error('blockdoesnotexist', 'error');
}
if (in_array($block->name, $undeletableblocktypes)) {
$undeletableblocktypes = array_diff($undeletableblocktypes, array($block->name));
set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
}
admin_get_root(true, false); // settings not required - only pages
}
if (!empty($delete) && confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading($strmanageblocks);
if (!$block = blocks_get_record($delete)) {
print_error('blockdoesnotexist', 'error');
if (!$block = get_record('blocks', 'id', $delete)) {
error("Block doesn't exist!");
}
if (get_string_manager()->string_exists('pluginname', "block_$block->name")) {
$strblockname = get_string('pluginname', "block_$block->name");
} else {
$strblockname = $block->name;
}
$blockobject = block_instance($block->name, $site);
$strblockname = $blockobject->get_title();
if (!$confirm) {
echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete='.$block->id.'&confirm=1', 'blocks.php');
echo $OUTPUT->footer();
if (!$_GET['confirm']) {
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
'blocks.php?delete='.$block->id.'&amp;confirm=1&sesskey='.$USER->sesskey,
'blocks.php');
print_footer();
exit;
} else {
uninstall_plugin('block', $block->name);
// Delete block
if (!delete_records('blocks', 'id', $block->id)) {
notify("Error occurred while deleting the $strblockname record from blocks table");
}
blocks_update_every_block_by_id($block->id, 'delete'); // Delete blocks in all courses by id
// Then the tables themselves
if ($tables = $db->Metatables()) {
$prefix = $CFG->prefix.$block->name;
foreach ($tables as $table) {
if (strpos($table, $prefix) === 0) {
if (!execute_sql("DROP TABLE $table", false)) {
notify("ERROR: while trying to drop table $table");
}
}
}
}
$a = new stdClass();
$a->block = $strblockname;
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading($strmanageblocks);
/// Main display starts here
/// Get and sort the existing blocks
if (!$blocks = $DB->get_records('block', array(), 'name ASC')) {
print_error('noblocks', 'error'); // Should never happen
if (false === ($blocks = get_records('blocks'))) {
error('No blocks found!'); // Should never happen
}
$incompatible = array();
foreach ($blocks as $block) {
if(($blockobject = block_instance($block->name, NULL)) === false) {
// Failed to load
continue;
}
$blockbyname[$blockobject->get_title()] = $block->id;
$blockobjects[$block->id] = $blockobject;
}
if(empty($blockbyname)) {
error('One or more blocks are registered in the database, but they all failed to load!');
}
ksort($blockbyname);
/// Print the table of all blocks
$table = new flexible_table('admin-blocks-compatible');
if (empty($THEME->custompix)) {
$pixpath = '../pix';
// [pj] This is not used anywhere, but I'm leaving it in for the future
//$modpixpath = '../mod';
} else {
$pixpath = '../theme/'.$CFG->theme.'/pix';
// [pj] This is not used anywhere, but I'm leaving it in for the future
//$modpixpath = '../theme/'.$CFG->theme.'/pix/mod';
}
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
$table->setup();
$tablerows = array();
$table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings);
$table->align = array ('LEFT', 'RIGHT', 'LEFT', 'CENTER', 'CENTER', 'CENTER');
$table->wrap = array ("NOWRAP", "", "", "", "","");
$table->size = array ("100%", "10", "10", "10", "10","12");
$table->width = "100";
foreach ($blocks as $blockid=>$block) {
$blockname = $block->name;
foreach ($blockbyname as $blockname => $blockid) {
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
$blockobject = false;
$strblockname = '<span class="notifyproblem">'.$blockname.' ('.get_string('missingfromdisk').')</span>';
$plugin = new stdClass();
$plugin->version = $block->version;
// [pj] This is not used anywhere, but I'm leaving it in for the future
//$icon = "<img src=\"$modpixpath/$block->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
$blockobject = $blockobjects[$blockid];
} else {
$plugin = new stdClass();
$plugin->version = '???';
if (file_exists("$CFG->dirroot/blocks/$blockname/version.php")) {
include("$CFG->dirroot/blocks/$blockname/version.php");
}
if (!$blockobject = block_instance($block->name)) {
$incompatible[] = $block;
continue;
}
$strblockname = get_string('pluginname', 'block_'.$blockname);
}
$delete = '<a href="blocks.php?delete='.$blockid.'&amp;sesskey='.sesskey().'">'.$strdelete.'</a>';
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
$settings = ''; // By default, no configuration
if ($blockobject and $blockobject->has_config()) {
$blocksettings = admin_get_root()->locate('blocksetting' . $block->name);
if ($blocksettings instanceof admin_externalpage) {
$settings = '<a href="' . $blocksettings->url . '">' . get_string('settings') . '</a>';
} else if ($blocksettings instanceof admin_settingpage) {
$settings = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=blocksetting'.$block->name.'">'.$strsettings.'</a>';
} else {
$settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
}
if($blockobject->has_config()) {
$settings = '<a href="block.php?block='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strsettings.'</a>';
}
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
// and it should not show up on course search page
$totalcount = $DB->count_records('block_instances', array('blockname'=>$blockname));
$count = $DB->count_records('block_instances', array('blockname'=>$blockname, 'pagetypepattern'=>'course-view-*'));
if ($count>0) {
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&amp;sesskey=".sesskey()."\" ";
$blocklist .= "title=\"$strshowblockcourse\" >$totalcount</a>";
}
else {
$blocklist = "$totalcount";
}
$count = blocks_get_courses_using_block_by_id($blockid);
$class = ''; // Nothing fancy, by default
if (!$blockobject) {
// ignore
$visible = '';
} else if ($blocks[$blockid]->visible) {
$visible = '<a href="blocks.php?hide='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strhide.'">'.
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon" alt="'.$strhide.'" /></a>';
if ($blocks[$blockid]->visible) {
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
'<img src="'.$pixpath.'/i/hide.gif" style="height: 16px; width: 16px;" /></a>';
} else {
$visible = '<a href="blocks.php?show='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strshow.'">'.
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon" alt="'.$strshow.'" /></a>';
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
'<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" /></a>';
$class = ' class="dimmed_text"'; // Leading space required!
}
if ($block->version == $plugin->version) {
$version = $block->version;
} else {
$version = "$block->version ($plugin->version)";
}
if (!$blockobject) {
// ignore
$undeletable = '';
} else if (in_array($blockname, $undeletableblocktypes)) {
$undeletable = '<a href="blocks.php?unprotect='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strunprotect.'">'.
'<img src="'.$OUTPUT->pix_url('t/unlock') . '" class="icon" alt="'.$strunprotect.'" /></a>';
} else {
$undeletable = '<a href="blocks.php?protect='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strprotect.'">'.
'<img src="'.$OUTPUT->pix_url('t/unlock_gray') . '" class="icon" alt="'.$strprotect.'" /></a>';
}
$row = array(
'<span'.$class.'>'.$strblockname.'</span>',
$blocklist,
'<span'.$class.'>'.$version.'</span>',
$visible,
$undeletable,
$delete,
$settings
);
$tablerows[] = array(strip_tags($strblockname), $row); // first element will be used for sorting
$table->data[] = array ('<p'.$class.'>'.$blockobject->get_title().'</p>', $count, $blockobject->get_version(), $visible, $delete, $settings);
}
echo '<p>';
print_table($table);
echo '</p>';
print_footer();
collatorlib::asort($tablerows);
foreach ($tablerows as $row) {
$table->add_data($row[1]);
}
$table->print_html();
if (!empty($incompatible)) {
echo $OUTPUT->heading(get_string('incompatibleblocks', 'blockstable', 'admin'));
$table = new flexible_table('admin-blocks-incompatible');
$table->define_columns(array('block', 'delete'));
$table->define_headers(array($strname, $strdelete));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'incompatibleblockstable generaltable');
$table->setup();
foreach ($incompatible as $block) {
$table->add_data(array(
$block->name,
'<a href="blocks.php?delete='.$block->id.'&amp;sesskey='.sesskey().'">'.$strdelete.'</a>',
));
}
$table->print_html();
}
echo $OUTPUT->footer();
?>
-100
View File
@@ -1,100 +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/>.
/**
* Automated backups CLI cron
*
* This script executes
*
* @package core
* @subpackage cli
* @copyright 2010 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
require_once($CFG->libdir.'/cronlib.php');
// now get cli options
list($options, $unrecognized) = cli_get_params(array('help'=>false),
array('h'=>'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help =
"Execute automated backups.
This script executes automated backups completely and is designed to be
called via cron.
Options:
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/automated_backups.php
";
echo $help;
die;
}
if (CLI_MAINTENANCE) {
echo "CLI maintenance mode active, backup execution suspended.\n";
exit(1);
}
if (moodle_needs_upgrading()) {
echo "Moodle upgrade pending, backup execution suspended.\n";
exit(1);
}
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/gradelib.php');
if (!empty($CFG->showcronsql)) {
$DB->set_debug(true);
}
if (!empty($CFG->showcrondebugging)) {
$CFG->debug = DEBUG_DEVELOPER;
$CFG->debugdisplay = true;
}
$starttime = microtime();
/// emulate normal session
cron_setup_user();
/// Start output log
$timenow = time();
mtrace("Server Time: ".date('r',$timenow)."\n\n");
// Run automated backups if required.
require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php');
backup_cron_automated_helper::run_automated_backup(backup_cron_automated_helper::RUN_IMMEDIATELY);
mtrace("Automated cron backups completed correctly");
$difftime = microtime_diff($starttime, microtime());
mtrace("Execution took ".$difftime." seconds");
-61
View File
@@ -1,61 +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/>.
/**
* CLI cron
*
* This script looks through all the module directories for cron.php files
* and runs them. These files can contain cleanup functions, email functions
* or anything that needs to be run on a regular basis.
*
* @package core
* @subpackage cli
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
require_once($CFG->libdir.'/cronlib.php');
// now get cli options
list($options, $unrecognized) = cli_get_params(array('help'=>false),
array('h'=>'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help =
"Execute periodic cron actions.
Options:
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/cron.php
";
echo $help;
die;
}
cron_run();
-687
View File
@@ -1,687 +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/>.
/**
* This script creates config.php file and prepares database.
*
* This script is not intended for beginners!
* Potential problems:
* - su to apache account or sudo before execution
* - not compatible with Windows platform
*
* @package core
* @subpackage cli
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
// extra execution prevention - we can not just require config.php here
if (isset($_SERVER['REMOTE_ADDR'])) {
exit(1);
}
$help =
"Command line Moodle installer, creates config.php and initializes database.
Please note you must execute this script with the same uid as apache
or use chmod/chown after installation.
Site defaults may be changed via local/defaults.php.
Options:
--chmod=OCTAL-MODE Permissions of new directories created within dataroot.
Default is 2777. You may want to change it to 2770
or 2750 or 750. See chmod man page for details.
--lang=CODE Installation and default site language.
--wwwroot=URL Web address for the Moodle site,
required in non-interactive mode.
--dataroot=DIR Location of the moodle data folder,
must not be web accessible. Default is moodledata
in the parent directory.
--dbtype=TYPE Database type. Default is mysqli
--dbhost=HOST Database host. Default is localhost
--dbname=NAME Database name. Default is moodle
--dbuser=USERNAME Database user. Default is root
--dbpass=PASSWORD Database password. Default is blank
--dbsocket Use database sockets. Available for some databases only.
--prefix=STRING Table prefix for above database tables. Default is mdl_
--fullname=STRING The fullname of the site
--shortname=STRING The shortname of the site
--adminuser=USERNAME Username for the moodle admin account. Default is admin
--adminpass=PASSWORD Password for the moodle admin account,
required in non-interactive mode.
--non-interactive No interactive questions, installation fails if any
problem encountered.
--agree-license Indicates agreement with software license,
required in non-interactive mode.
--allow-unstable Install even if the version is not marked as stable yet,
required in non-interactive mode.
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/install.php --lang=cs
"; //TODO: localize, mark as needed in install - to be translated later when everything is finished
// distro specific customisation
$distrolibfile = dirname(dirname(dirname(__FILE__))).'/install/distrolib.php';
$distro = null;
if (file_exists($distrolibfile)) {
require_once($distrolibfile);
if (function_exists('distro_get_config')) {
$distro = distro_get_config();
}
}
// Nothing to do if config.php exists
$configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
if (file_exists($configfile)) {
require($configfile);
require_once($CFG->libdir.'/clilib.php');
list($options, $unrecognized) = cli_get_params(array('help'=>false), array('h'=>'help'));
if ($options['help']) {
echo $help;
echo "\n\n";
}
if ($DB->get_manager()->table_exists('config')) {
cli_error(get_string('clialreadyinstalled', 'install'));
} else {
cli_error(get_string('clialreadyconfigured', 'install'));
}
}
$olddir = getcwd();
// change directory so that includes below work properly
chdir(dirname($_SERVER['argv'][0]));
// Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
// This is a quick hack. Ideally we should ask the admin for a value. See MDL-22625 for more on this.
if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
@date_default_timezone_set(@date_default_timezone_get());
}
// make sure PHP errors are displayed - helps with diagnosing of problems
@error_reporting(E_ALL);
@ini_set('display_errors', '1');
// we need a lot of memory
@ini_set('memory_limit', '128M');
/** Used by library scripts to check they are being called by Moodle */
define('MOODLE_INTERNAL', true);
// Check that PHP is of a sufficient version
if (version_compare(phpversion(), "5.3.2") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
exit(1);
}
// set up configuration
$CFG = new stdClass();
$CFG->lang = 'en';
$CFG->dirroot = dirname(dirname(dirname(__FILE__)));
$CFG->libdir = "$CFG->dirroot/lib";
$CFG->wwwroot = "http://localhost";
$CFG->httpswwwroot = $CFG->wwwroot;
$CFG->docroot = 'http://docs.moodle.org';
$CFG->running_installer = true;
$CFG->early_install_lang = true;
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
$CFG->admin = array_pop($parts);
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
//the problem is that we need specific version of quickforms and hacked excel files :-(
ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
require_once($CFG->libdir.'/installlib.php');
require_once($CFG->libdir.'/clilib.php');
require_once($CFG->libdir.'/setuplib.php');
require_once($CFG->libdir.'/textlib.class.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/dmllib.php');
require_once($CFG->libdir.'/moodlelib.php');
require_once($CFG->libdir.'/deprecatedlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
require($CFG->dirroot.'/version.php');
$CFG->target_release = $release;
//Database types
$databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
'oci' => moodle_database::get_driver_instance('oci', 'native'),
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
);
foreach ($databases as $type=>$database) {
if ($database->driver_installed() !== true) {
unset($databases[$type]);
}
}
if (empty($databases)) {
$defaultdb = '';
} else {
reset($databases);
$defaultdb = key($databases);
}
// now get cli options
list($options, $unrecognized) = cli_get_params(
array(
'chmod' => isset($distro->directorypermissions) ? sprintf('%04o',$distro->directorypermissions) : '2777', // let distros set dir permissions
'lang' => $CFG->lang,
'wwwroot' => '',
'dataroot' => empty($distro->dataroot) ? str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'): $distro->dataroot, // initialised later after including libs or by distro
'dbtype' => empty($distro->dbtype) ? $defaultdb : $distro->dbtype, // let distro skip dbtype selection
'dbhost' => empty($distro->dbhost) ? 'localhost' : $distro->dbhost, // let distros set dbhost
'dbname' => 'moodle',
'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
'dbpass' => '',
'dbsocket' => false,
'prefix' => 'mdl_',
'fullname' => '',
'shortname' => '',
'adminuser' => 'admin',
'adminpass' => '',
'non-interactive' => false,
'agree-license' => false,
'allow-unstable' => false,
'help' => false
),
array(
'h' => 'help'
)
);
$interactive = empty($options['non-interactive']);
// set up language
$lang = clean_param($options['lang'], PARAM_SAFEDIR);
if (file_exists($CFG->dirroot.'/install/lang/'.$lang)) {
$CFG->lang = $lang;
}
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
echo $help;
die;
}
//Print header
echo get_string('cliinstallheader', 'install', $CFG->target_release)."\n";
//Fist select language
if ($interactive) {
cli_separator();
$languages = get_string_manager()->get_list_of_translations();
// format the langs nicely - 3 per line
$c = 0;
$langlist = '';
foreach ($languages as $key=>$lang) {
$c++;
$length = iconv_strlen($lang, 'UTF-8');
$padded = $lang.str_repeat(' ', 38-$length);
$langlist .= $padded;
if ($c % 3 == 0) {
$langlist .= "\n";
}
}
$default = $CFG->lang;
cli_heading(get_string('availablelangs', 'install'));
echo $langlist."\n";
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->lang);
$error = '';
do {
echo $error;
$input = cli_input($prompt, $default);
$input = clean_param($input, PARAM_SAFEDIR);
if (!file_exists($CFG->dirroot.'/install/lang/'.$input)) {
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
} else {
$error = '';
}
} while ($error !== '');
$CFG->lang = $input;
} else {
// already selected and verified
}
// Set directorypermissions first
$chmod = octdec(clean_param($options['chmod'], PARAM_INT));
if ($interactive) {
cli_separator();
cli_heading(get_string('datarootpermission', 'install'));
$prompt = get_string('clitypevaluedefault', 'admin', decoct($chmod));
$error = '';
do {
echo $error;
$input = cli_input($prompt, decoct($chmod));
$input = octdec(clean_param($input, PARAM_INT));
if (empty($input)) {
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
} else {
$error = '';
}
} while ($error !== '');
$chmod = $input;
} else {
if (empty($chmod)) {
$a = (object)array('option' => 'chmod', 'value' => decoct($chmod));
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
}
$CFG->directorypermissions = $chmod;
//We need wwwroot before we test dataroot
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
$wwwroot = trim($wwwroot, '/');
if ($interactive) {
cli_separator();
cli_heading(get_string('wwwroot', 'install'));
if (strpos($wwwroot, 'http') === 0) {
$prompt = get_string('clitypevaluedefault', 'admin', $wwwroot);
} else {
$wwwroot = null;
$prompt = get_string('clitypevalue', 'admin');
}
$error = '';
do {
echo $error;
$input = cli_input($prompt, $wwwroot);
$input = clean_param($input, PARAM_URL);
$input = trim($input, '/');
if (strpos($input, 'http') !== 0) {
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
} else {
$error = '';
}
} while ($error !== '');
$wwwroot = $input;
} else {
if (strpos($wwwroot, 'http') !== 0) {
$a = (object)array('option'=>'wwwroot', 'value'=>$wwwroot);
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
}
$CFG->wwwroot = $wwwroot;
$CFG->httpswwwroot = $CFG->wwwroot;
//We need dataroot before lang download
$CFG->dataroot = $options['dataroot'];
if ($interactive) {
cli_separator();
$i=0;
while(is_dataroot_insecure()) {
$parrent = dirname($CFG->dataroot);
$i++;
if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
$CFG->dataroot = ''; //can not find secure location for dataroot
break;
}
$CFG->dataroot = dirname($parrent).'/moodledata';
}
cli_heading(get_string('dataroot', 'install'));
$error = '';
do {
if ($CFG->dataroot !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $CFG->dataroot);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
echo $error;
$CFG->dataroot = cli_input($prompt, $CFG->dataroot);
if ($CFG->dataroot === '') {
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
} else if (is_dataroot_insecure()) {
$CFG->dataroot = '';
$error = get_string('pathsunsecuredataroot', 'install')."\n";
} else {
if (install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
$error = '';
} else {
$a = (object)array('dataroot' => $CFG->dataroot);
$error = get_string('pathserrcreatedataroot', 'install', $a)."\n";
}
}
} while ($error !== '');
} else {
if (is_dataroot_insecure()) {
cli_error(get_string('pathsunsecuredataroot', 'install'));
}
if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
$a = (object)array('dataroot' => $CFG->dataroot);
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
}
}
$CFG->tempdir = $CFG->dataroot.'/temp';
$CFG->cachedir = $CFG->dataroot.'/cache';
// download required lang packs
if ($CFG->lang !== 'en') {
$installer = new lang_installer($CFG->lang);
$results = $installer->run();
foreach ($results as $langcode => $langstatus) {
if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
$a = new stdClass();
$a->url = $installer->lang_pack_url($langcode);
$a->dest = $CFG->dataroot.'/lang';
cli_problem(get_string('remotedownloaderror', 'error', $a));
}
}
}
// switch the string_manager instance to stop using install/lang/
$CFG->early_install_lang = false;
$CFG->langotherroot = $CFG->dataroot.'/lang';
$CFG->langlocalroot = $CFG->dataroot.'/lang';
get_string_manager(true);
// make sure we are installing stable release or require a confirmation
if (isset($maturity)) {
if (($maturity < MATURITY_STABLE) and !$options['allow-unstable']) {
$maturitylevel = get_string('maturity'.$maturity, 'admin');
if ($interactive) {
cli_separator();
cli_heading(get_string('notice'));
echo get_string('maturitycorewarning', 'admin', $maturitylevel) . PHP_EOL;
echo get_string('morehelp') . ': ' . get_docs_url('admin/versions') . PHP_EOL;
echo get_string('continue') . PHP_EOL;
$prompt = get_string('cliyesnoprompt', 'admin');
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
if ($input == get_string('clianswerno', 'admin')) {
exit(1);
}
} else {
cli_error(get_string('maturitycorewarning', 'admin'));
}
}
}
// ask for db type - show only drivers available
if ($interactive) {
$options['dbtype'] = strtolower($options['dbtype']);
cli_separator();
cli_heading(get_string('databasetypehead', 'install'));
foreach ($databases as $type=>$database) {
echo " $type \n";
}
if (!empty($databases[$options['dbtype']])) {
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbtype']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
$CFG->dbtype = cli_input($prompt, $options['dbtype'], array_keys($databases));
} else {
if (empty($databases[$options['dbtype']])) {
$a = (object)array('option'=>'dbtype', 'value'=>$options['dbtype']);
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
$CFG->dbtype = $options['dbtype'];
}
$database = $databases[$CFG->dbtype];
// ask for db host
if ($interactive) {
cli_separator();
cli_heading(get_string('databasehost', 'install'));
if ($options['dbhost'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbhost']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
$CFG->dbhost = cli_input($prompt, $options['dbhost']);
} else {
$CFG->dbhost = $options['dbhost'];
}
// ask for db name
if ($interactive) {
cli_separator();
cli_heading(get_string('databasename', 'install'));
if ($options['dbname'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbname']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
$CFG->dbname = cli_input($prompt, $options['dbname']);
} else {
$CFG->dbname = $options['dbname'];
}
// ask for db prefix
if ($interactive) {
cli_separator();
cli_heading(get_string('dbprefix', 'install'));
//TODO: solve somehow the prefix trouble for oci
if ($options['prefix'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['prefix']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
$CFG->prefix = cli_input($prompt, $options['prefix']);
} else {
$CFG->prefix = $options['prefix'];
}
// ask for db user
if ($interactive) {
cli_separator();
cli_heading(get_string('databaseuser', 'install'));
if ($options['dbuser'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbuser']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
$CFG->dbuser = cli_input($prompt, $options['dbuser']);
} else {
$CFG->dbuser = $options['dbuser'];
}
// ask for db password
if ($interactive) {
cli_separator();
cli_heading(get_string('databasepass', 'install'));
do {
if ($options['dbpass'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbpass']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']), $distro);
}
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
} while ($hint_database !== '');
} else {
$CFG->dbpass = $options['dbpass'];
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
if ($hint_database !== '') {
cli_error(get_string('dbconnectionerror', 'install'));
}
}
// ask for fullname
if ($interactive) {
cli_separator();
cli_heading(get_string('fullsitename', 'moodle'));
if ($options['fullname'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['fullname']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
do {
$options['fullname'] = cli_input($prompt, $options['fullname']);
} while (empty($options['fullname']));
} else {
if (empty($options['fullname'])) {
$a = (object)array('option'=>'fullname', 'value'=>$options['fullname']);
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
}
// ask for shortname
if ($interactive) {
cli_separator();
cli_heading(get_string('shortsitename', 'moodle'));
if ($options['shortname'] !== '') {
$prompt = get_string('clitypevaluedefault', 'admin', $options['shortname']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
do {
$options['shortname'] = cli_input($prompt, $options['shortname']);
} while (empty($options['shortname']));
} else {
if (empty($options['shortname'])) {
$a = (object)array('option'=>'shortname', 'value'=>$options['shortname']);
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
}
// ask for admin user name
if ($interactive) {
cli_separator();
cli_heading(get_string('cliadminusername', 'install'));
if (!empty($options['adminuser'])) {
$prompt = get_string('clitypevaluedefault', 'admin', $options['adminuser']);
} else {
$prompt = get_string('clitypevalue', 'admin');
}
do {
$options['adminuser'] = cli_input($prompt, $options['adminuser']);
} while (empty($options['adminuser']) or $options['adminuser'] === 'guest');
} else {
if (empty($options['adminuser']) or $options['adminuser'] === 'guest') {
$a = (object)array('option'=>'adminuser', 'value'=>$options['adminuser']);
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
}
// ask for admin user password
if ($interactive) {
cli_separator();
cli_heading(get_string('cliadminpassword', 'install'));
$prompt = get_string('clitypevalue', 'admin');
do {
$options['adminpass'] = cli_input($prompt);
} while (empty($options['adminpass']) or $options['adminpass'] === 'admin');
} else {
if (empty($options['adminpass']) or $options['adminpass'] === 'admin') {
$a = (object)array('option'=>'adminpass', 'value'=>$options['adminpass']);
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
}
if ($interactive) {
if (!$options['agree-license']) {
cli_separator();
cli_heading(get_string('copyrightnotice'));
echo "Moodle - Modular Object-Oriented Dynamic Learning Environment\n";
echo get_string('gpl3')."\n\n";
echo get_string('doyouagree')."\n";
$prompt = get_string('cliyesnoprompt', 'admin');
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
if ($input == get_string('clianswerno', 'admin')) {
exit(1);
}
}
} else {
if (!$options['agree-license']) {
cli_error(get_string('climustagreelicense', 'install'));
}
}
// Finally we have all info needed for config.php
$configphp = install_generate_configphp($database, $CFG);
umask(0137);
if (($fh = fopen($configfile, 'w')) !== false) {
fwrite($fh, $configphp);
fclose($fh);
}
if (!file_exists($configfile)) {
cli_error('Can not create config file.');
}
// remember selected language
$installlang = $CFG->lang;
// return back to original dir before executing setup.php which changes the dir again
chdir($olddir);
// We have config.php, it is a real php script from now on :-)
require($configfile);
// use selected language
$CFG->lang = $installlang;
$SESSION->lang = $CFG->lang;
require("$CFG->dirroot/version.php");
// Test environment first.
require_once($CFG->libdir . '/environmentlib.php');
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
$errors = environment_get_errors($environment_results);
cli_heading(get_string('environment', 'admin'));
foreach ($errors as $error) {
list($info, $report) = $error;
echo "!! $info !!\n$report\n\n";
}
exit(1);
}
// Test plugin dependencies.
require_once($CFG->libdir . '/pluginlib.php');
if (!plugin_manager::instance()->all_plugins_ok($version)) {
cli_error(get_string('pluginschecktodo', 'admin'));
}
install_cli_database($options, $interactive);
echo get_string('cliinstallfinished', 'install')."\n";
exit(0); // 0 means success
-171
View File
@@ -1,171 +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/>.
/**
* This installs Moodle into empty database, config.php must already exist.
*
* This script is intended for advanced usage such as in Debian packages.
* - sudo to www-data (apache account) before
* - not compatible with Windows platform
*
* @package core
* @subpackage cli
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
// extra execution prevention - we can not just require config.php here
if (isset($_SERVER['REMOTE_ADDR'])) {
exit(1);
}
$help =
"Advanced command line Moodle database installer.
Please note you must execute this script with the same uid as apache.
Site defaults may be changed via local/defaults.php.
Options:
--lang=CODE Installation and default site language. Default is en.
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
--adminpass=PASSWORD Password for the moodle admin account.
--agree-license Indicates agreement with software license.
--fullname=STRING Name of the site
--shortname=STRING Name of the site
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/install_database.php --lang=cs --adminpass=soMePass123 --agree-license
";
// Check that PHP is of a sufficient version
if (version_compare(phpversion(), "5.3.2") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
exit(1);
}
// Nothing to do if config.php does not exist
$configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
if (!file_exists($configfile)) {
fwrite(STDERR, 'config.php does not exist, can not continue'); // do not localize
fwrite(STDERR, "\n");
exit(1);
}
// Include necessary libs
require($configfile);
require_once($CFG->libdir.'/clilib.php');
require_once($CFG->libdir.'/installlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
// make sure no tables are installed yet
if ($DB->get_tables() ) {
cli_error(get_string('clitablesexist', 'install'));
}
$CFG->early_install_lang = true;
get_string_manager(true);
raise_memory_limit(MEMORY_EXTRA);
// now get cli options
list($options, $unrecognized) = cli_get_params(
array(
'lang' => 'en',
'adminuser' => 'admin',
'adminpass' => '',
'fullname' => '',
'shortname' => '',
'agree-license' => false,
'help' => false
),
array(
'h' => 'help'
)
);
if ($options['help']) {
echo $help;
die;
}
if (!$options['agree-license']) {
cli_error('You have to agree to the license. --help prints out the help'); // TODO: localize
}
if ($options['adminpass'] === true or $options['adminpass'] === '') {
cli_error('You have to specify admin password. --help prints out the help'); // TODO: localize
}
$options['lang'] = clean_param($options['lang'], PARAM_SAFEDIR);
if (!file_exists($CFG->dirroot.'/install/lang/'.$options['lang'])) {
$options['lang'] = 'en';
}
$CFG->lang = $options['lang'];
// download required lang packs
if ($CFG->lang !== 'en') {
make_upload_directory('lang');
$installer = new lang_installer($CFG->lang);
$results = $installer->run();
foreach ($results as $langcode => $langstatus) {
if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
$a = new stdClass();
$a->url = $installer->lang_pack_url($langcode);
$a->dest = $CFG->dataroot.'/lang';
cli_problem(get_string('remotedownloaderror', 'error', $a));
}
}
}
// switch the string_manager instance to stop using install/lang/
$CFG->early_install_lang = false;
get_string_manager(true);
require("$CFG->dirroot/version.php");
// Test environment first.
require_once($CFG->libdir . '/environmentlib.php');
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
$errors = environment_get_errors($environment_results);
cli_heading(get_string('environment', 'admin'));
foreach ($errors as $error) {
list($info, $report) = $error;
echo "!! $info !!\n$report\n\n";
}
exit(1);
}
// Test plugin dependencies.
require_once($CFG->libdir . '/pluginlib.php');
if (!plugin_manager::instance()->all_plugins_ok($version)) {
cli_error(get_string('pluginschecktodo', 'admin'));
}
install_cli_database($options, true);
echo get_string('cliinstallfinished', 'install')."\n";
exit(0); // 0 means success
-76
View File
@@ -1,76 +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/>.
/**
* Enable or disable maintenance mode
*
* @package core
* @subpackage cli
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
// now get cli options
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'disable'=>false, 'help'=>false),
array('h'=>'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help =
"Maintenance mode settings.
Current status displayed if not option specified.
Options:
--enable Enable maintenance mode
--disable Disable maintenance mode
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/maintenance.php
"; //TODO: localize - to be translated later when everything is finished
echo $help;
die;
}
cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
if ($options['enable']) {
set_config('maintenance_enabled', 1);
echo get_string('sitemaintenanceon', 'admin')."\n";
exit(0);
} else if ($options['disable']) {
set_config('maintenance_enabled', 0);
echo get_string('sitemaintenanceoff', 'admin')."\n";
exit(0);
}
if (!empty($CFG->maintenance_enabled)) {
echo get_string('clistatusenabled', 'admin')."\n";
} else {
echo get_string('clistatusdisabled', 'admin')."\n";
}
-115
View File
@@ -1,115 +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/>.
/**
* MySQL engine conversion tool.
*
* @package core
* @subpackage cli
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
if ($DB->get_dbfamily() !== 'mysql') {
cli_error('This function is designed for MySQL databases only!');
}
// now get cli options
list($options, $unrecognized) = cli_get_params(array('help'=>false, 'list'=>false, 'engine'=>false),
array('h'=>'help', 'l'=>'list'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
$help =
"MySQL engine conversions script.
It is recommended to stop the web server before the conversion.
Do not use MyISAM if possible, because it is not ACID compliant
and does not support transactions.
Options:
--engine=ENGINE Convert MySQL tables to different engine
-l, --list Show table information
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB
";
if (!empty($options['engine'])) {
$engine = clean_param($options['engine'], PARAM_ALPHA);
echo "Converting tables to '$engine' for $CFG->wwwroot:\n";
$prefix = $DB->get_prefix();
$prefix = str_replace('_', '\\_', $prefix);
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
$rs = $DB->get_recordset_sql($sql);
$converted = 0;
$skipped = 0;
foreach ($rs as $table) {
if ($table->engine === $engine) {
echo str_pad($table->name, 40). " - NO CONVERSION NEEDED\n";
$skipped++;
continue;
}
echo str_pad($table->name, 40). " - ";
$DB->change_database_structure("ALTER TABLE {$table->name} ENGINE = $engine");
echo "DONE\n";
$converted++;
}
$rs->close();
echo "Converted: $converted, skipped: $skipped\n";
exit(0); // success
} else if (!empty($options['list'])) {
echo "List of tables for $CFG->wwwroot:\n";
$prefix = $DB->get_prefix();
$prefix = str_replace('_', '\\_', $prefix);
$sql = "SHOW TABLE STATUS WHERE Name LIKE BINARY '$prefix%'";
$rs = $DB->get_recordset_sql($sql);
$counts = array();
foreach ($rs as $table) {
if (isset($counts[$table->engine])) {
$counts[$table->engine]++;
} else {
$counts[$table->engine] = 1;
}
echo str_pad($table->engine, 10);
echo $table->name . "\n";
}
$rs->close();
echo "\n";
echo "Table engines summary for $CFG->wwwroot:\n";
foreach ($counts as $engine => $count) {
echo "$engine: $count\n";
}
exit(0); // success
} else {
echo $help;
die;
}
-53
View File
@@ -1,53 +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/>.
/**
* @package core
* @subpackage cli
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/clilib.php');
list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
}
if ($options['help']) {
$help =
"Invalidates all Moodle internal caches
Options:
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/purge_caches.php
";
echo $help;
exit(0);
}
purge_all_caches();
exit(0);
-81
View File
@@ -1,81 +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/>.
/**
* This script allows you to reset any local user password.
*
* @package core
* @subpackage cli
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
// now get cli options
list($options, $unrecognized) = cli_get_params(array('help'=>false),
array('h'=>'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help =
"Reset local user passwords, useful especially for admin acounts.
There are no security checks here because anybody who is able to
execute this file may execute any PHP too.
Options:
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/reset_password.php
"; //TODO: localize - to be translated later when everything is finished
echo $help;
die;
}
cli_heading('Password reset'); // TODO: localize
$prompt = "enter username (manual authentication only)"; // TODO: localize
$username = cli_input($prompt);
if (!$user = $DB->get_record('user', array('auth'=>'manual', 'username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
cli_error("Can not find user '$username'");
}
$prompt = "Enter new password"; // TODO: localize
$password = cli_input($prompt);
$errmsg = '';//prevent eclipse warning
if (!check_password_policy($password, $errmsg)) {
cli_error($errmsg);
}
$hashedpassword = hash_internal_user_password($password);
$DB->set_field('user', 'password', $hashedpassword, array('id'=>$user->id));
echo "Password changed\n";
exit(0); // 0 means success
-167
View File
@@ -1,167 +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/>.
/**
* This script creates config.php file and prepares database.
*
* This script is not intended for beginners!
* Potential problems:
* - su to apache account or sudo before execution
* - not compatible with Windows platform
*
* @package core
* @subpackage cli
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
require_once($CFG->libdir.'/clilib.php'); // cli only functions
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/pluginlib.php');
// now get cli options
list($options, $unrecognized) = cli_get_params(
array(
'non-interactive' => false,
'allow-unstable' => false,
'help' => false
),
array(
'h' => 'help'
)
);
$interactive = empty($options['non-interactive']);
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help =
"Command line Moodle upgrade.
Please note you must execute this script with the same uid as apache!
Site defaults may be changed via local/defaults.php.
Options:
--non-interactive No interactive questions or confirmations
--allow-unstable Upgrade even if the version is not marked as stable yet,
required in non-interactive mode.
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php admin/cli/upgrade.php
"; //TODO: localize - to be translated later when everything is finished
echo $help;
die;
}
if (empty($CFG->version)) {
cli_error(get_string('missingconfigversion', 'debug'));
}
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
$CFG->target_release = $release; // used during installation and upgrades
if ($version < $CFG->version) {
cli_error(get_string('downgradedcore', 'error'));
}
$oldversion = "$CFG->release ($CFG->version)";
$newversion = "$release ($version)";
if (!moodle_needs_upgrading()) {
cli_error(get_string('cliupgradenoneed', 'core_admin', $newversion), 0);
}
// Test environment first.
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
$errors = environment_get_errors($environment_results);
cli_heading(get_string('environment', 'admin'));
foreach ($errors as $error) {
list($info, $report) = $error;
echo "!! $info !!\n$report\n\n";
}
exit(1);
}
// Test plugin dependencies.
if (!plugin_manager::instance()->all_plugins_ok($version)) {
cli_error(get_string('pluginschecktodo', 'admin'));
}
if ($interactive) {
$a = new stdClass();
$a->oldversion = $oldversion;
$a->newversion = $newversion;
echo cli_heading(get_string('databasechecking', '', $a)) . PHP_EOL;
}
// make sure we are upgrading to a stable release or display a warning
if (isset($maturity)) {
if (($maturity < MATURITY_STABLE) and !$options['allow-unstable']) {
$maturitylevel = get_string('maturity'.$maturity, 'admin');
if ($interactive) {
cli_separator();
cli_heading(get_string('notice'));
echo get_string('maturitycorewarning', 'admin', $maturitylevel) . PHP_EOL;
echo get_string('morehelp') . ': ' . get_docs_url('admin/versions') . PHP_EOL;
cli_separator();
} else {
cli_error(get_string('maturitycorewarning', 'admin', $maturitylevel));
}
}
}
if ($interactive) {
echo html_to_text(get_string('upgradesure', 'admin', $newversion))."\n";
$prompt = get_string('cliyesnoprompt', 'admin');
$input = cli_input($prompt, '', array(get_string('clianswerno', 'admin'), get_string('cliansweryes', 'admin')));
if ($input == get_string('clianswerno', 'admin')) {
exit(1);
}
}
if ($version > $CFG->version) {
upgrade_core($version, true);
}
set_config('release', $release);
// unconditionally upgrade
upgrade_noncore(true);
// log in as admin - we need doanything permission when applying defaults
$admins = get_admins();
$admin = reset($admins);
session_set_user($admin);
// apply all default settings, just in case do it twice to fill all defaults
admin_apply_default_settings(NULL, false);
admin_apply_default_settings(NULL, false);
echo get_string('cliupgradefinished', 'admin')."\n";
exit(0); // 0 means success
+619
View File
@@ -0,0 +1,619 @@
<form method="post" action="config.php" name="form">
<table cellpadding=9 cellspacing=0 >
<tr valign=top>
<td align=right><p>lang:</td>
<td>
<?php choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", ""); ?>
</td>
<td>
<?php print_string("configlang") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>langmenu:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "langmenu", $config->langmenu, "", "", "");
?>
</td>
<td>
<?php print_string("configlangmenu") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>langlist:</td>
<td>
<input name=langlist type=text size=40 value="<?php p($config->langlist) ?>">
</td>
<td>
<?php print_string("configlanglist") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>locale:</td>
<td>
<input name=locale type=text size=10 value="<?php p($config->locale) ?>">
</td>
<td>
<?php print_string("configlocale") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>timezone:</td>
<td><?php
if (abs($config->timezone) > 13) {
$config->timezone = 99;
}
$timenow = time();
$timeformat = get_string('strftimedaytime');
for ($tz = -26; $tz <= 26; $tz++) {
$zone = (float)$tz/2.0;
$usertime = $timenow + ($tz * 1800);
if ($tz == 0) {
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT)";
} else if ($tz < 0) {
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT$zone)";
} else {
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT+$zone)";
}
}
choose_from_menu ($timezones, "timezone", $config->timezone, get_string("serverlocaltime"), "", "99");
?>
</td>
<td>
<?php print_string("configtimezone") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>country:</td>
<td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
</td>
<td>
<?php print_string("configcountry") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>smtphosts:</td>
<td>
<input name=smtphosts type=text size=30 value="<?php p($config->smtphosts)?>">
</td>
<td>
<?php print_string("configsmtphosts") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>smtpuser:</td>
<td>
<input name=smtpuser type=text size=10 value="<?php p($config->smtpuser)?>">
</td>
<td rowspan=2>
<?php print_string("configsmtpuser") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>smtppass:</td>
<td>
<input name=smtppass type=text size=10 value="<?php p($config->smtppass)?>">
</td>
</tr>
<tr valign=top>
<td align=right><p>noreplyaddress:</td>
<td>
<input name=noreplyaddress type=text size=30 value="<?php p($config->noreplyaddress)?>">
</td>
<td>
<?php print_string("confignoreplyaddress") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>gdversion:</td>
<td>
<?php
unset($options);
$options[0] = get_string("gdnot");
$options[1] = get_string("gd1");
$options[2] = get_string("gd2");
$installed = check_gd_version();
choose_from_menu ($options, "gdversion", $installed, "", "", "");
?>
</td>
<td>
<?php print_string("configgdversion") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>maxeditingtime:</td>
<td>
<?php
unset($options);
$options[3600] = get_string("numminutes", "", 60);
$options[2700] = get_string("numminutes", "", 45);
$options[1800] = get_string("numminutes", "", 30);
$options[900] = get_string("numminutes", "", 15);
$options[300] = get_string("numminutes", "", 5);
$options[60] = get_string("numminutes", "", 1);
choose_from_menu ($options, "maxeditingtime", $config->maxeditingtime, "", "", "");
?>
</td>
<td>
<?php print_string("configmaxeditingtime") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>longtimenosee:</td>
<td>
<?php
unset($options);
$options[1000] = get_string("numdays", "", 1000);
$options[365] = get_string("numdays", "", 365);
$options[180] = get_string("numdays", "", 180);
$options[150] = get_string("numdays", "", 150);
$options[120] = get_string("numdays", "", 120);
$options[90] = get_string("numdays", "", 90);
$options[60] = get_string("numdays", "", 60);
$options[30] = get_string("numdays", "", 30);
$options[21] = get_string("numdays", "", 21);
$options[14] = get_string("numdays", "", 14);
$options[7] = get_string("numdays", "", 7);
choose_from_menu ($options, "longtimenosee", $config->longtimenosee, "", "", "");
?>
</td>
<td>
<?php print_string("configlongtimenosee") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>deleteunconfirmed:</td>
<td>
<?php
unset($options);
$options[0] = get_string("never");
$options[168] = get_string("numdays", "", 7);
$options[144] = get_string("numdays", "", 6);
$options[120] = get_string("numdays", "", 5);
$options[96] = get_string("numdays", "", 4);
$options[72] = get_string("numdays", "", 3);
$options[48] = get_string("numdays", "", 2);
$options[24] = get_string("numdays", "", 1);
$options[12] = get_string("numhours", "", 12);
$options[6] = get_string("numhours", "", 6);
$options[1] = get_string("numhours", "", 1);
choose_from_menu ($options, "deleteunconfirmed", $config->deleteunconfirmed, "", "", "");
?>
</td>
<td>
<?php print_string("configdeleteunconfirmed") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>loglifetime:</td>
<td>
<?php
unset($options);
$options[0] = get_string("neverdeletelogs");
$options[1000] = get_string("numdays", "", 1000);
$options[365] = get_string("numdays", "", 365);
$options[180] = get_string("numdays", "", 180);
$options[150] = get_string("numdays", "", 150);
$options[120] = get_string("numdays", "", 120);
$options[90] = get_string("numdays", "", 90);
$options[60] = get_string("numdays", "", 60);
$options[30] = get_string("numdays", "", 30);
choose_from_menu ($options, "loglifetime", $config->loglifetime, "", "", "");
?>
</td>
<td>
<?php print_string("configloglifetime") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>displayloginfailures:</p></td>
<td>
<?php
unset($options);
$options[''] = get_string('nobody');
$options['admin'] = get_string('administrators');
$options['teacher'] = get_string('administratorsandteachers');
$options['everybody'] = get_string('everybody');
choose_from_menu($options, "displayloginfailures",$config->displayloginfailures,"","","");
?>
</td>
<td>
<?php print_string("configdisplayloginfailures") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>notifyloginfailures:</p></td>
<td>
<?php
unset($options);
$options[''] = get_string('nobody');
$options['mainadmin'] = get_string('administrator');
$options['alladmins'] = get_string('administratorsall');
choose_from_menu($options,"notifyloginfailures",$config->notifyloginfailures,"","","");
?>
</td>
<td>
<?php print_string('confignotifyloginfailures') ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>notifyloginthreshold:</p></td>
<td>
<?php
unset($options);
for ($i=1; $i<=100; $i++) {
$options[$i] = "$i";
}
choose_from_menu($options,"notifyloginthreshold",$config->notifyloginthreshold,"","","");
?>
</td>
<td>
<?php print_string('confignotifyloginthreshold') ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>sessiontimeout:</td>
<td>
<?php
unset($options);
$options[14400] = get_string("numhours", "", 4);
$options[10800] = get_string("numhours", "", 3);
$options[7200] = get_string("numhours", "", 2);
$options[5400] = get_string("numhours", "", "1.5");
$options[3600] = get_string("numminutes", "", 60);
$options[2700] = get_string("numminutes", "", 45);
$options[1800] = get_string("numminutes", "", 30);
$options[900] = get_string("numminutes", "", 15);
$options[300] = get_string("numminutes", "", 5);
choose_from_menu ($options, "sessiontimeout", $config->sessiontimeout, "", "", "");
?>
</td>
<td>
<?php print_string("configsessiontimeout") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>sessioncookie:</td>
<td>
<input name=sessioncookie type=text size=10 value="<?php p($config->sessioncookie)?>">
</td>
<td>
<?php print_string("configsessioncookie") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>zip:</td>
<td>
<input name=zip type=text size=30 value="<?php p($config->zip) ?>">
</td>
<td>
<?php print_string("configzip") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>unzip:</td>
<td>
<input name=unzip type=text size=30 value="<?php p($config->unzip) ?>">
</td>
<td>
<?php print_string("configunzip") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>slasharguments:</td>
<td>
<?php unset($options);
$options[0] = "file.php?file=/pic.jpg";
$options[1] = "file.php/pic.jpg";
choose_from_menu ($options, "slasharguments", $config->slasharguments, "", "", "");
?>
</td>
<td>
<?php print_string("configslasharguments") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>proxyhost:</td>
<td>
<input name=proxyhost type=text size=30 value="<?php p($config->proxyhost) ?>">
</td>
<td rowspan=2>
<?php print_string("configproxyhost") ?>
</td>
</TR>
<tr valign=top>
<td align=right><p>proxyport:</td>
<td>
<input name=proxyport type=text size=5 value="<?php p($config->proxyport) ?>">
</td>
</tr>
<tr valign=top>
<td align=right><p>debug:</td>
<td>
<?php
unset($options);
$options[7] = get_string("no");
$options[15] = get_string("yes");
choose_from_menu ($options, "debug", $config->debug, "", "", "");
?>
</td>
<td>
<?php print_string("configdebug") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>framename:</td>
<td>
<?php
if (empty($config->framename)) {
$config->framename = "_top";
}
?>
<input name=framename type=text size=15 value="<?php p($config->framename)?>">
</td>
<td>
<?php print_string("configframename") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>secureforms:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "secureforms", $config->secureforms, "", "", "");
?>
</td>
<td>
<?php print_string("configsecureforms") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>loginhttps:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "loginhttps", $config->loginhttps, "", "", "");
?>
</td>
<td>
<?php print_string("configloginhttps") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>teacherassignteachers:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "teacherassignteachers", $config->teacherassignteachers, "", "", "");
?>
</td>
<td>
<?php print_string("configteacherassignteachers") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>allusersaresitestudents:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "allusersaresitestudents", $config->allusersaresitestudents, "", "", "");
?>
</td>
<td>
<?php print_string("configallusersaresitestudents") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>showsiteparticipantslist:</td>
<td>
<?php
unset($options);
$options[0] = get_string("siteteachers");
$options[1] = get_string("allteachers");
$options[2] = get_string("studentsandteachers");
choose_from_menu ($options, "showsiteparticipantslist", $config->showsiteparticipantslist, "", "", "");
?>
</td>
<td>
<?php print_string("configshowsiteparticipantslist") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>allowunenroll:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "allowunenroll", $config->allowunenroll, "", "", "");
?>
</td>
<td>
<?php print_string("configallowunenroll") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>maxbytes:</td>
<td>
<?php
$options = get_max_upload_sizes();
choose_from_menu ($options, "maxbytes", $config->maxbytes, "");
?>
</td>
<td>
<?php print_string("configmaxbytes") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>fullnamedisplay:</td>
<td>
<?php
unset($options);
$options['language'] = get_string('language');
$options['firstname lastname'] = get_string('firstname') . ' + ' . get_string('lastname');
$options['lastname firstname'] = get_string('lastname') . ' + ' . get_string('firstname');
$options['firstname'] = get_string('firstname');
choose_from_menu ($options, "fullnamedisplay", $config->fullnamedisplay, "", "", "");
?>
</td>
<td>
<?php print_string("configfullnamedisplay") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>extendedusernamechars:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "extendedusernamechars", $config->extendedusernamechars, "", "", "");
?>
</td>
<td>
<?php print_string("configextendedusernamechars") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>autologinguests:</td>
<td>
<?php
unset($options);
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, "autologinguests", $config->autologinguests, "", "", "");
?>
</td>
<td>
<?php print_string("configautologinguests") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>forcelogin:</td>
<td>
<?php
unset($options);
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, "forcelogin", $config->forcelogin, "", "", "");
?>
</td>
<td>
<?php print_string("configforcelogin") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>forceloginforprofiles:</td>
<td>
<?php
unset($options);
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, "forceloginforprofiles", $config->forceloginforprofiles, "", "", "");
?>
</td>
<td>
<?php print_string("configforceloginforprofiles") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>opentogoogle:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "opentogoogle", $config->opentogoogle, "", "", "");
?>
</td>
<td>
<?php print_string("configopentogoogle") ?>
</td>
</tr>
<tr valign=top>
<td align=right><p>enablerssfeeds:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "enablerssfeeds", $config->enablerssfeeds, "", "", "");
?>
</td>
<td>
<?php
print_string("configenablerssfeeds");
//Check for required functions...
if(!function_exists('utf8_encode')) {
echo "<font color=\"red\"> You need to add XML support to your PHP installation.</font>";
}
?>
</td>
</tr>
<tr valign=top>
<td align=right><p>digestmailtime:</td>
<td>
<?php
$hours = array();
for ($i=0; $i<=23; $i++) {
$hours[$i] = sprintf("%02d",$i);
}
choose_from_menu($hours, 'digestmailtime', $config->digestmailtime, "");
?>
</td>
<td>
<?php
print_string('configdigestmailtime');
?>
</td>
</tr>
<tr>
<td colspan=3 align=center>
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>">
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
</tr>
</table>
</form>
+126
View File
@@ -0,0 +1,126 @@
<?PHP // $Id$
// config.php - allows admin to edit all configuration variables
require_once("../config.php");
if ($site = get_site()) { // If false then this is a new installation
require_login();
if (!isadmin()) {
error("Only the admin can use this page");
}
}
/// This is to overcome the "insecure forms paradox"
if (isset($secureforms) and $secureforms == 0) {
$match = "nomatch";
} else {
$match = "";
}
/// If data submitted, then process and store.
if ($config = data_submitted($match)) {
if (!empty($USER->id)) { // Additional identity check
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
}
validate_form($config, $err);
if (count($err) == 0) {
print_header();
foreach ($config as $name => $value) {
if ($name == "sessioncookie") {
$value = eregi_replace("[^a-zA-Z]", "", $value);
}
unset($conf);
$conf->name = $name;
$conf->value = $value;
if ($current = get_record("config", "name", $name)) {
$conf->id = $current->id;
if (! update_record("config", $conf)) {
notify("Could not update $name to $value");
}
} else {
if (! insert_record("config", $conf)) {
notify("Error: could not add new variable $name !");
}
}
}
redirect("index.php", get_string("changessaved"), 1);
exit;
} else {
foreach ($err as $key => $value) {
$focus = "form.$key";
}
}
}
/// Otherwise fill and print the form.
if (empty($config)) {
$config = $CFG;
if (!$config->locale = get_field("config", "value", "name", "locale")) {
$config->locale = $CFG->lang;
}
}
if (empty($focus)) {
$focus = "";
}
$stradmin = get_string("administration");
$strconfiguration = get_string("configuration");
$strconfigvariables = get_string("configvariables");
if ($site) {
print_header("$site->shortname: $strconfigvariables", $site->fullname,
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $strconfigvariables", $focus);
print_heading($strconfigvariables);
} else {
print_header();
print_heading($strconfigvariables);
print_simple_box(get_string("configintro"), "center", "50%");
echo "<br />";
}
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
print_simple_box_start("center", "", "$THEME->cellheading");
include("config.html");
print_simple_box_end();
/// Lock some options
$httpsurl = str_replace('http://', 'https://', $CFG->wwwroot);
if ($httpsurl != $CFG->wwwroot) {
if ((($fh = @fopen($httpsurl, 'r')) == false) and ($config->loginhttps == 0)) {
echo '<script>'."\n";
echo '<!--'."\n";
echo "eval('document.form.loginhttps.disabled=true');\n";
echo '-->'."\n";
echo '</script>'."\n";
}
}
if ($site) {
print_footer();
}
exit;
/// Functions /////////////////////////////////////////////////////////////////
function validate_form(&$form, &$err) {
// Currently no checks are needed ...
return true;
}
?>
+53
View File
@@ -0,0 +1,53 @@
<?PHP // $Id$
require_once("../config.php");
require_login();
if (!isadmin()) {
error("Only admins can access this page");
}
if (!$site = get_site()) {
redirect("index.php");
}
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
print_header("$site->shortname: $stradministration: $strconfiguration", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> $strconfiguration");
print_heading($strconfiguration);
$table->align = array ("right", "left");
$table->data[] = array("<b><a href=\"config.php\">".get_string("configvariables")."</a></b>",
get_string("adminhelpconfigvariables"));
$table->data[] = array("<b><a href=\"site.php\">".get_string("sitesettings")."</a></b>",
get_string("adminhelpsitesettings"));
$table->data[] = array("<b><a href=\"../theme/index.php\">".get_string("themes")."</a></b>",
get_string("adminhelpthemes"));
$table->data[] = array("<b><a href=\"lang.php\">".get_string("language")."</a></b>",
get_string("adminhelplanguage"));
$table->data[] = array("<b><a href=\"modules.php\">".get_string("managemodules")."</a></b>",
get_string("adminhelpmanagemodules"));
$table->data[] = array("<b><a href=\"blocks.php\">".get_string("manageblocks")."</a></b>",
get_string("adminhelpmanageblocks"));
$table->data[] = array("<b><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a></b>",
get_string("adminhelpmanagefilters"));
if (!isset($CFG->disablescheduledbackups)) {
$table->data[] = array("<b><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a></b>",
get_string("adminhelpbackup"));
}
$table->data[]= array("<b><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a></b>",
get_string("adminhelpeditorsettings"));
print_table($table);
print_footer($site);
?>
+83
View File
@@ -0,0 +1,83 @@
<form name="creatorsform" id="creatorsform" method="post" action="creators.php">
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table align="center" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">
<?php echo count($creators) . " ". $strexistingcreators ?>
</td>
<td></td>
<td valign="top">
<?php echo $usercount . " " . $strpotentialcreators ?>
</td>
</tr>
<tr>
<td valign="top">
<select name="removeselect[]" size="20" id="removeselect" multiple
onFocus="document.creatorsform.add.disabled=true;
document.creatorsform.remove.disabled=false;
document.creatorsform.addselect.selectedIndex=-1;">
<?php
foreach ($creators as $creator) {
$fullname = fullname($creator, true);
echo "<option value=\"$creator->id\">".$fullname.", ".$creator->email."</option>\n";
}
?>
</select></td>
<td valign="top">
<br />
<input name="add" type="submit" id="add" value="&larr;" />
<br />
<input name="remove" type="submit" id="remove" value="&rarr;" />
<br />
</td>
<td valign="top">
<select name="addselect[]" size="20" id="addselect" multiple
onFocus="document.creatorsform.add.disabled=false;
document.creatorsform.remove.disabled=true;
document.creatorsform.removeselect.selectedIndex=-1;">
<?php
if (!empty($searchusers)) {
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
foreach ($searchusers as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
echo "</optgroup>\n";
}
if (!empty($users)) {
foreach ($users as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
}
?>
</select>
<br />
<script>
function
</script>
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
onFocus ="document.creatorsform.add.disabled=true;
document.creatorsform.remove.disabled=true;
document.creatorsform.removeselect.selectedIndex=-1;
document.creatorsform.addselect.selectedIndex=-1;"
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
if (keyCode == 13) {
document.creatorsform.previoussearch.value=1;
document.creatorsform.submit();
} " />
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>"/>
<?php
if (!empty($searchusers)) {
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
}
?>
</td>
</tr>
</table>
</form>
+116
View File
@@ -0,0 +1,116 @@
<?PHP // $Id$
// Admin only script to assign course creator rights to users
require_once("../config.php");
define("MAX_USERS_PER_PAGE", 50);
optional_variable($search, "");
optional_variable($add, "");
optional_variable($remove, "");
if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
require_login();
if (!isadmin()) {
error("You must be an administrator to use this page.");
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
$primaryadmin = get_admin();
/// assign all of the configurable language strings
$stringstoload = array (
"assigncreators",
"administration",
"existingcreators",
"potentialcreators",
"search",
"users",
"searchresults",
"showall"
);
foreach ($stringstoload as $stringtoload){
$strstringtoload = "str" . $stringtoload;
$$strstringtoload = get_string($stringtoload);
}
print_header("$site->shortname: $strassigncreators",
"$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
$strassigncreators", "creatorsform.searchtext");
if (!$frm = data_submitted()) {
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
/// A form was submitted so process the input
} else {
if (!empty($frm->add) and !empty($frm->addselect)) {
foreach ($frm->addselect as $addcreator) {
if (! add_creator($addcreator)) {
error("Could not add course creator with user id $addcreator!");
}
}
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
foreach ($frm->removeselect as $removecreator) {
if (! remove_creator($removecreator)) {
error("Could not remove course creator with user id $removecreator!");
}
}
} else if (!empty($frm->showall)) {
unset($frm->searchtext);
$frm->previoussearch = 0;
}
}
/// Is there a current search?
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
/// Get all existing creators
if (! $creators = get_creators()) {
$creators = array();
}
$creatorsarray = array();
foreach ($creators as $creator) {
$creatorsarray[] = $creator->id;
}
$creatorlist = implode(',', $creatorsarray);
unset($creatorarray);
/// Get search results excluding any current admins
if (!empty($frm->searchtext) and $previoussearch) {
$searchusers = get_users(true, $frm->searchtext, true, $creatorlist, 'firstname ASC, lastname ASC',
'', '', 0, 99999, 'id, firstname, lastname, email');
$usercount = get_users(false, '', true, $creatorlist);
}
/// If no search results then get potential users excluding current creators
if (empty($searchusers)) {
if (!$users = get_users(true, '', true, $creatorlist, 'firstname ASC, lastname ASC', '', '',
0, 99999, 'id, firstname, lastname, email') ) {
$users = array();
}
$usercount = count($users);
}
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
$previoussearch = ($previoussearch) ? '1' : '0';
include('./creators.html');
print_footer();
?>
+186 -82
View File
@@ -1,92 +1,196 @@
<?php
<?PHP // $Id$
// 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/>.
/// This script looks through all the module directories for cron.php files
/// and runs them. These files can contain cleanup functions, email functions
/// or anything that needs to be run on a regular basis.
///
/// This file is best run from cron on the host system (ie outside PHP).
/// The script can either be invoked via the web server or via a standalone
/// version of PHP compiled for CGI.
///
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
/// or php /web/moodle/admin/cron.php
/**
* Web cron
*
* This script looks through all the module directories for cron.php files
* and runs them. These files can contain cleanup functions, email functions
* or anything that needs to be run on a regular basis.
*
* This file is best run from cron on the host system (ie outside PHP).
* It is strongly recommended to add password protection via admin settings.
*
* eg wget -q -O /dev/null 'http: *moodle.somewhere.edu/admin/cron.php?password=SeCreT666'
*
* It is also possible to use CLI script admin/cli/cron.php instead,
* you can not call this script from command line any more.
*
* @package core
* @subpackage admin
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$FULLME = "cron";
$starttime = microtime();
/// The current directory in PHP version 4.3.0 and above isn't necessarily the
/// directory of the script when run from the command line. The require_once()
/// would fail, so we'll have to chdir()
if (defined('STDIN')) {
fwrite(STDERR, "ERROR: This script no longer supports CLI, please use admin/cli/cron.php instead\n");
exit(1);
}
// This is a fake CLI script, it is a really ugly hack which emulates
// CLI via web interface, please do not use this hack elsewhere
define('CLI_SCRIPT', true);
define('WEB_CRON_EMULATED_CLI', 'defined'); // ugly ugly hack, do not use elsewhere please
define('NO_OUTPUT_BUFFERING', true);
require('../config.php');
require_once($CFG->libdir.'/clilib.php');
require_once($CFG->libdir.'/cronlib.php');
// extra safety
session_get_instance()->write_close();
// check if execution allowed
if (!empty($CFG->cronclionly)) {
// This script can only be run via the cli.
print_error('cronerrorclionly', 'admin');
exit;
}
// This script is being called via the web, so check the password if there is one.
if (!empty($CFG->cronremotepassword)) {
$pass = optional_param('password', '', PARAM_RAW);
if ($pass != $CFG->cronremotepassword) {
// wrong password.
print_error('cronerrorpassword', 'admin');
exit;
if (!isset($_SERVER['REMOTE_ADDR']) && isset($_SERVER['argv'][0])) {
chdir(dirname($_SERVER['argv'][0]));
}
}
// send mime type and encoding
if (check_browser_version('MSIE')) {
//ugly IE hack to work around downloading instead of viewing
@header('Content-Type: text/html; charset=utf-8');
echo "<xmp>"; //<pre> is not good enough for us here
} else {
//send proper plaintext header
@header('Content-Type: text/plain; charset=utf-8');
}
require_once("../config.php");
// execute the cron
cron_run();
if (!$alreadyadmin = isadmin()) {
unset($_SESSION['USER']);
unset($USER);
unset($_SESSION['SESSION']);
unset($SESSION);
$USER = get_admin(); /// Temporarily, to provide environment for this script
}
// finish the IE hack
if (check_browser_version('MSIE')) {
echo "</xmp>";
}
/// Start output log
$timenow = time();
mtrace("<pre>");
mtrace("Server Time: ".date('r',$timenow)."\n\n");
/// Run all cron jobs for each module
mtrace("Starting activity modules");
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron)")) {
foreach ($mods as $mod) {
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
if (file_exists($libfile)) {
include_once($libfile);
$cron_function = $mod->name."_cron";
if (function_exists($cron_function)) {
mtrace("Processing module function $cron_function ...", '');
if ($cron_function()) {
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
mtrace("Error: could not update timestamp for $mod->fullname");
}
}
mtrace("done.");
}
}
}
}
mtrace("Finished activity modules");
/// Run all core cron jobs, but not every time since they aren't too important.
/// These don't have a timer to reduce load, so we'll use a random number
/// to randomly choose the percentage of times we should run these jobs.
srand ((double) microtime() * 10000000);
$random100 = rand(0,100);
if ($random100 < 20) { // Approximately 20% of the time.
mtrace("Running clean-up tasks...");
/// Unenrol users who haven't logged in for $CFG->longtimenosee
if ($CFG->longtimenosee) { // value in days
$longtime = $timenow - ($CFG->longtimenosee * 3600 * 24);
if ($students = get_users_longtimenosee($longtime)) {
foreach ($students as $student) {
if (unenrol_student($student->userid, $student->course)) {
mtrace("Deleted student enrolment for user $student->userid from course $student->course");
}
}
}
}
/// Delete users who haven't confirmed within required period
$oneweek = $timenow - ($CFG->deleteunconfirmed * 3600);
if ($users = get_users_unconfirmed($oneweek)) {
foreach ($users as $user) {
if (delete_records("user", "id", $user->id)) {
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
}
}
}
flush();
/// Delete duplicate enrolments (don't know what causes these yet - expired sessions?)
if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid ".
"HAVING count(*) > 1", "", "*,count(*)")) {
foreach ($users as $user) {
delete_records_select("user_students", "userid = '$user->userid' ".
"AND course = '$user->course' AND id <> '$user->id'");
}
}
flush();
/// Delete old logs to save space (this might need a timer to slow it down...)
if (!empty($CFG->loglifetime)) { // value in days
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
delete_records_select("log", "time < '$loglifetime'");
}
flush();
/// Delete old cached texts
if (!empty($CFG->cachetext)) { // Defined in config.php
$cachelifetime = time() - $CFG->cachetext;
delete_records_select("cache_text", "timemodified < '$cachelifetime'");
}
flush();
if (!empty($CFG->notifyloginfailures)) {
notify_login_failures();
}
flush();
} // End of occasional clean-up tasks
if (file_exists("$CFG->dataroot/cronextra.php")) {
mtrace("Running extra commands in $CFG->dataroot/cronextra.php ...");
include("$CFG->dataroot/cronextra.php");
}
if (!isset($CFG->disablescheduledbackups)) { // Defined in config.php
//Execute backup's cron
//Perhaps a long time and memory could help in large sites
@set_time_limit(0);
@ini_set("memory_limit","128M");
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
file_exists("$CFG->dirroot/backup/backuplib.php") and
file_exists("$CFG->dirroot/backup/lib.php") and
file_exists("$CFG->libdir/blocklib.php")) {
include_once("$CFG->dirroot/backup/backup_scheduled.php");
include_once("$CFG->dirroot/backup/backuplib.php");
include_once("$CFG->dirroot/backup/lib.php");
require_once ("$CFG->libdir/blocklib.php");
mtrace("Running backups if required...");
if (! schedule_backup_cron()) {
mtrace("ERORR: Something went wrong while performing backup tasks!!!");
} else {
mtrace("Backup tasks finished.");
}
}
}
if (!empty($CFG->enablerssfeeds)) { //Defined in admin/variables page
if (file_exists("$CFG->dirroot/rss/rsslib.php")) {
include_once("$CFG->dirroot/rss/rsslib.php");
mtrace("Running rssfeeds if required...");
if ( ! cron_rss_feeds()) {
mtrace("Something went wrong while generating rssfeeds!!!");
} else {
mtrace("Rssfeeds finished");
}
}
}
/// Run the enrolment cron, if any
require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
$enrol = new enrolment_plugin();
$enrol->cron();
if (!empty($enrol->log)) {
mtrace($enrol->log);
}
//Unset session variables and destroy it
@session_unset();
@session_destroy();
mtrace("Cron script completed correctly");
$difftime = microtime_diff($starttime, microtime());
mtrace("Execution took ".$difftime." seconds");
?>
+36
View File
@@ -0,0 +1,36 @@
<?PHP // $Id$
// dbperformance.php - shows latest ADOdb stats for the current server
require_once("../config.php");
require_login();
if (!isadmin()) {
error("Only the admin can use this page");
}
$strdatabaseperformance = get_string("databaseperformance");
$stradministration = get_string("administration");
$site = get_site();
if (isset($topframe)) {
print_header("$site->shortname: $strdatabaseperformance", "$site->fullname",
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> Database performance");
exit;
}
if (isset($bottomframe) or isset($_GET['do'])) {
$perf =&NewPerfMonitor($db);
$perf->UI($pollsecs=5);
exit;
}
?>
<head>
<title><?php echo "$site->shortname: $strdatabaseperformance" ?></title>
</head>
<frameset rows="80,*">
<frame src="dbperformance.php?topframe=true">
<frame src="dbperformance.php?bottomframe=true">
</frameset>
+63
View File
@@ -0,0 +1,63 @@
<?PHP //$Id$
// Deletes the moodledata directory, COMPLETELY!!
// BE VERY CAREFUL USING THIS!
require_once("../config.php");
require_login();
if (!isadmin()) {
error("You must be admin to use this script!");
}
$deletedir = $CFG->dataroot; // The directory to delete!
if (!$sure) {
notice_yesno ("Are you completely sure you want to delete everything inside the directory $deletedir ?", "delete.php?sure=yes", "index.php");
exit;
}
if (!$reallysure) {
notice_yesno ("Are you REALLY REALLY completely sure you want to delete everything inside the directory $deletedir (this includes all user images, and any other course files that have been created) ?", "delete.php?sure=yes&reallysure=yes", "index.php");
exit;
}
/// OK, here goes ...
delete_subdirectories($deletedir);
echo "<H1 align=center>Done!</H1>";
print_continue($CFG->wwwroot);
exit;
function delete_subdirectories($rootdir) {
$dir = opendir($rootdir);
while ($file = readdir($dir)) {
if ($file != "." and $file != "..") {
$fullfile = "$rootdir/$file";
if (filetype($fullfile) == "dir") {
delete_subdirectories($fullfile);
echo "Deleting $fullfile ... ";
if (rmdir($fullfile)) {
echo "Done.<BR>";
} else {
echo "FAILED.<BR>";
}
} else {
echo "Deleting $fullfile ... ";
if (unlink("$fullfile")) {
echo "Done.<BR>";
} else {
echo "FAILED.<BR>";
}
}
}
}
closedir($dir);
}
?>
+85
View File
@@ -0,0 +1,85 @@
<form method="post" action="<?php print($GLOBALS['ME']);?>">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table border="0" cellpadding="4" cellspacing="2">
<tr valign=top>
<td align=right><p>htmleditor:</td>
<td>
<?php
unset($options);
$options[0] = get_string("allownot");
$options[1] = get_string("allow");
choose_from_menu ($options, "htmleditor", $CFG->htmleditor, "", "", "");
?>
</td>
<td>
<?php print_string("confightmleditor") ?>
</td>
</tr>
<tr>
<td align="right" valign="top">editorbackgroundcolor:</td>
<td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>"></td>
<td valign="top"><?php print_string("edhelpbgcolor");?></td>
</tr>
<tr>
<td align="right" valign="top">editorfontfamily:</td>
<td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>"></td>
<td valign="top"><?php print_string("edhelpfontfamily");?></td>
</tr>
<tr>
<td align="right" valign="top">editorfontsize:</td>
<td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>"></td>
<td valign="top"><?php print_string("edhelpfontsize");?></td>
</tr>
<tr>
<td align="right" valign="top">editorkillword:</td>
<td valign="top"><select name="killword">
<option value="1"<?php print(!$CFG->editorkillword)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
<option value="0"<?php print(!$CFG->editorkillword)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
</select></td>
<td valign="top"><?php print_string("edhelpcleanword");?></td>
</tr>
<tr>
<td align="right" valign="top">editorspelling:</td>
<td valign="top"><select name="spelling"<?php
if (empty($CFG->aspellpath)) {
echo " disabled=\"disabled\"";
$CFG->editorspelling = false;
}
?>>
<option value="1"<?php print(!$CFG->editorspelling)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
<option value="0"<?php print(!$CFG->editorspelling)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
</select></td>
<td valign="top"><?php print_string("edhelpenablespelling");?></td>
</tr>
<tr><td colspan="3"><br /><?php print_string("edhelpfontlist");?></td></tr>
<?php
if(is_array($fontlist)) {
foreach($fontlist as $fontkey => $fontvalue) {
?>
<tr>
<td>&nbsp;</td>
<td colspan="2"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>">
<input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>"></td>
</tr>
<?php
}
}
?>
<tr>
<td>&nbsp;</td>
<td colspan="2"><input type="text" name="fontname[]" size="15" value="">
<input type="text" name="fontnamevalue[]" size="30" value=""></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>"></td>
</tr>
</table>
</form>
<form method="post" action="<?php print($GLOBALS['ME']);?>">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<center>
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
</center>
</form>
+140
View File
@@ -0,0 +1,140 @@
<?php // $Id$
/// configuration routines for HTMLArea editor
require_once("../config.php");
require_login();
if (!isadmin()) {
error("Only admins can access this page");
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
if ($data = data_submitted()) {
// do we want default values?
if (isset($data->resettodefaults)) {
if(!(reset_to_defaults())) {
error("Editor settings could not be restored!");
}
} else {
if(!(editor_update_config($data))) {
error("Editor settings could not be updated!");
}
}
redirect("$CFG->wwwroot/$CFG->admin/editor.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
} else {
// Generate edit form
$fontlist = editor_convert_to_array($CFG->editorfontlist);
$stradmin = get_string("administration");
$strconfiguration = get_string("configuration");
$streditorsettings = get_string("editorsettings");
$streditorsettingshelp = get_string("adminhelpeditorsettings");
print_header("Editor settings","Editor settings",
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $streditorsettings");
print_heading($streditorsettings);
print_simple_box("<center>$streditorsettingshelp</center>","center","50%");
print("<br />\n");
print_simple_box_start("center", "", "$THEME->cellheading");
include("editor.html");
print_simple_box_end();
print_footer();
}
/// FUNCTIONS
function editor_convert_to_array ($string) {
/// Converts $CFG->editorfontlist to array
if(empty($string) || !is_string($string)) {
return false;
}
$fonts = array();
$lines = explode(";", $string);
foreach($lines as $line) {
if(!empty($line)) {
list($fontkey, $fontvalue) = explode(":", $line);
$fonts[$fontkey] = $fontvalue;
}
}
return $fonts;
}
function editor_update_config ($data) {
/// Updates the editor config values.
if(!is_object($data)) {
return false;
}
// Make array for unwanted characters.
$nochars = array(chr(33),chr(34),chr(35),chr(36),chr(37),
chr(38),chr(39),chr(40),chr(41),chr(42),
chr(43),chr(46),chr(47),chr(58),chr(59),
chr(60),chr(61),chr(62),chr(63),chr(64),
chr(91),chr(92),chr(93),chr(94),chr(95),
chr(96),chr(123),chr(124),chr(125),chr(126));
$fontlist = '';
// make font string
for($i = 0; $i < count($data->fontname); $i++) {
if(!empty($data->fontname[$i])) {
$fontlist .= str_replace($nochars, "", $data->fontname[$i]) .":";
$fontlist .= str_replace($nochars, "", $data->fontnamevalue[$i]) .";";
}
}
// strip last semicolon
$fontlist = substr($fontlist, 0, strlen($fontlist) - 1);
// make array of values to update
$updatedata = array();
$updatedata['htmleditor'] = $data->htmleditor;
$updatedata['editorbackgroundcolor'] = !empty($data->backgroundcolor) ? $data->backgroundcolor : "#ffffff";
$updatedata['editorfontfamily'] = !empty($data->fontfamily) ? str_replace($nochars,"",$data->fontfamily) : "Times New Roman, Times";
$updatedata['editorfontsize'] = !empty($data->fontsize) ? $data->fontsize : "";
$updatedata['editorkillword'] = !empty($data->killword) ? $data->killword : "true";
$updatedata['editorspelling'] = !empty($data->spelling) ? $data->spelling : 0;
$updatedata['editorfontlist'] = $fontlist;
foreach($updatedata as $name => $value) {
if(!(set_config($name, $value))) {
return false;
}
}
return true;
}
function reset_to_defaults () {
global $CFG;
include_once($CFG->dirroot .'/lib/defaults.php');
$updatedata = array();
$updatedata['htmleditor'] = $defaults['htmleditor'];
$updatedata['editorbackgroundcolor'] = $defaults['editorbackgroundcolor'];
$updatedata['editorfontfamily'] = $defaults['editorfontfamily'];
$updatedata['editorfontsize'] = $defaults['editorfontsize'];
$updatedata['editorkillword'] = $defaults['editorkillword'];
$updatedata['editorspelling'] = $defaults['editorspelling'];
$updatedata['editorfontlist'] = $defaults['editorfontlist'];
foreach($updatedata as $name => $value) {
if(!(set_config($name, $value))) {
return false;
}
}
return true;
}
?>
-94
View File
@@ -1,94 +0,0 @@
<?php
/**
* Allows admin to configure editors.
*/
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
$action = optional_param('action', '', PARAM_ACTION);
$editor = optional_param('editor', '', PARAM_PLUGIN);
// get currently installed and enabled auth plugins
$available_editors = editors_get_available();
if (!empty($editor) and empty($available_editors[$editor])) {
redirect ($returnurl);
}
$active_editors = explode(',', $CFG->texteditors);
foreach ($active_editors as $key=>$active) {
if (empty($available_editors[$active])) {
unset($active_editors[$key]);
}
}
////////////////////////////////////////////////////////////////////////////////
// process actions
if (!confirm_sesskey()) {
redirect($returnurl);
}
$return = true;
switch ($action) {
case 'disable':
// remove from enabled list
$key = array_search($editor, $active_editors);
unset($active_editors[$key]);
break;
case 'enable':
// add to enabled list
if (!in_array($editor, $active_editors)) {
$active_editors[] = $editor;
$active_editors = array_unique($active_editors);
}
break;
case 'down':
$key = array_search($editor, $active_editors);
// check auth plugin is valid
if ($key !== false) {
// move down the list
if ($key < (count($active_editors) - 1)) {
$fsave = $active_editors[$key];
$active_editors[$key] = $active_editors[$key + 1];
$active_editors[$key + 1] = $fsave;
}
}
break;
case 'up':
$key = array_search($editor, $active_editors);
// check auth is valid
if ($key !== false) {
// move up the list
if ($key >= 1) {
$fsave = $active_editors[$key];
$active_editors[$key] = $active_editors[$key - 1];
$active_editors[$key - 1] = $fsave;
}
}
break;
default:
break;
}
// at least one editor must be active
if (empty($active_editors)) {
$active_editors = array('textarea');
}
set_config('texteditors', implode(',', $active_editors));
if ($return) {
redirect ($returnurl);
}
+74 -112
View File
@@ -1,127 +1,89 @@
<?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/>.
<?PHP // $Id$
// enrol.php - allows admin to edit all enrollment variables
// Yes, enrol is correct English spelling.
/**
* Enrol config manipulation script.
*
* @package core
* @subpackage enrol
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
include("../config.php");
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$enrol = optional_param('enrol', $CFG->enrol);
$action = required_param('action', PARAM_ACTION);
$enrol = required_param('enrol', PARAM_PLUGIN);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
require_login();
$PAGE->set_url('/admin/enrol.php');
$PAGE->set_context(context_system::instance());
if (!$site = get_site()) {
redirect("index.php");
}
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
require_sesskey();
if (!isadmin()) {
error("Only the admin can use this page");
}
$enabled = enrol_get_plugins(true);
$all = enrol_get_plugins(false);
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
$return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols'));
$enrol = clean_filename($enrol);
require_once("$CFG->dirroot/enrol/$enrol/enrol.php"); /// Open the class
$syscontext = context_system::instance();
$enrolment = new enrolment_plugin();
switch ($action) {
case 'disable':
unset($enabled[$enrol]);
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
$syscontext->mark_dirty(); // resets all enrol caches
break;
case 'enable':
if (!isset($all[$enrol])) {
break;
/// If data submitted, then process and store.
if ($frm = data_submitted()) {
if ($enrolment->process_config($frm)) {
set_config('enrol', $frm->enrol);
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
}
$enabled = array_keys($enabled);
$enabled[] = $enrol;
set_config('enrol_plugins_enabled', implode(',', $enabled));
$syscontext->mark_dirty(); // resets all enrol caches
break;
} else {
$frm = $CFG;
}
case 'up':
if (!isset($enabled[$enrol])) {
break;
}
$enabled = array_keys($enabled);
$enabled = array_flip($enabled);
$current = $enabled[$enrol];
if ($current == 0) {
break; //already at the top
}
$enabled = array_flip($enabled);
$enabled[$current] = $enabled[$current - 1];
$enabled[$current - 1] = $enrol;
set_config('enrol_plugins_enabled', implode(',', $enabled));
break;
/// Otherwise fill and print the form.
case 'down':
if (!isset($enabled[$enrol])) {
break;
}
$enabled = array_keys($enabled);
$enabled = array_flip($enabled);
$current = $enabled[$enrol];
if ($current == count($enabled) - 1) {
break; //already at the end
}
$enabled = array_flip($enabled);
$enabled[$current] = $enabled[$current + 1];
$enabled[$current + 1] = $enrol;
set_config('enrol_plugins_enabled', implode(',', $enabled));
break;
case 'uninstall':
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
} else {
$strplugin = $enrol;
}
if (!$confirm) {
$uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1));
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return);
echo $OUTPUT->footer();
exit;
} else { // Delete everything!!
uninstall_plugin('enrol', $enrol);
$syscontext->mark_dirty(); // resets all enrol caches
$a = new stdClass();
$a->plugin = $strplugin;
$a->directory = "$CFG->dirroot/enrol/$enrol";
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
echo $OUTPUT->continue_button($return);
echo $OUTPUT->footer();
exit;
}
}
/// get language strings
$str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
redirect($return);
$modules = get_list_of_plugins("enrol");
foreach ($modules as $module) {
$options[$module] = get_string("enrolname", "enrol_$module");
}
asort($options);
print_header("$site->shortname: $str->enrolments", "$site->fullname",
"<a href=\"index.php\">$str->administration</a> ->
<a href=\"users.php\">$str->users</a> -> $str->enrolments");
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
echo "<div align=\"center\"><p><b>";
/// Choose an enrolment method
echo get_string('chooseenrolmethod').': ';
choose_from_menu ($options, "enrol", $enrol, "",
"document.location='enrol.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
echo "</b></p></div>";
/// Print current enrolment type description
print_simple_box_start("center", "80%", "$THEME->cellheading");
print_heading($options[$enrol]);
print_simple_box_start("center", "60%", "$THEME->cellcontent");
print_string("description", "enrol_$enrol");
print_simple_box_end();
echo "<hr>";
// print_heading($str->settings);
$enrolment->config_form($frm);
echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
echo "</form>";
print_simple_box_end();
print_footer();
exit;
?>
-109
View File
@@ -1,109 +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/>.
/**
* This file is the admin frontend to execute all the checks available
* in the environment.xml file. It includes database, php and
* php_extensions. Also, it's possible to update the xml file
* from moodle.org be able to check more and more versions.
*
* @package core
* @subpackage admin
* @copyright 2006 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
// Parameters
$action = optional_param('action', '', PARAM_ACTION);
$version = optional_param('version', '', PARAM_FILE); //
$extraurlparams = array();
if ($version) {
$extraurlparams['version'] = $version;
}
admin_externalpage_setup('environment', '', $extraurlparams);
// Handle the 'updatecomponent' action
if ($action == 'updatecomponent' && confirm_sesskey()) {
// Create component installer and execute it
if ($cd = new component_installer('http://download.moodle.org',
'environment',
'environment.zip')) {
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
switch ($status) {
case COMPONENT_ERROR:
if ($cd->get_error() == 'remotedownloaderror') {
$a = new stdClass();
$a->url = 'http://download.moodle.org/environment/environment.zip';
$a->dest = $CFG->dataroot . '/';
print_error($cd->get_error(), 'error', $PAGE->url, $a);
die();
} else {
print_error($cd->get_error(), 'error', $PAGE->url);
die();
}
case COMPONENT_UPTODATE:
redirect($PAGE->url, get_string($cd->get_error(), 'error'));
die;
case COMPONENT_INSTALLED:
redirect($PAGE->url, get_string('componentinstalled', 'admin'));
die;
}
}
}
// Get current Moodle version
$current_version = $CFG->release;
// Calculate list of versions
$versions = array();
if ($contents = load_environment_xml()) {
if ($env_versions = get_list_of_environment_versions($contents)) {
// Set the current version at the beginning
$env_version = normalize_version($current_version); //We need this later (for the upwards)
$versions[$env_version] = $current_version;
// If no version has been previously selected, default to $current_version
if (empty($version)) {
$version = $env_version;
}
//Iterate over each version, adding bigger than current
foreach ($env_versions as $env_version) {
if (version_compare(normalize_version($current_version), $env_version, '<')) {
$versions[$env_version] = $env_version;
}
}
// Add 'upwards' to the last element
$versions[$env_version] = $env_version.' '.get_string('upwards', 'admin');
} else {
$versions = array('error' => get_string('error'));
}
}
// Get the results of the environment check.
list($envstatus, $environment_results) = check_moodle_environment($version);
// Display the page.
$output = $PAGE->get_renderer('core', 'admin');
echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
-674
View File
@@ -1,674 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<COMPATIBILITY_MATRIX>
<MOODLE version="1.5">
<DATABASE level="required">
<VENDOR name="mysql" version="3.23" />
<VENDOR name="postgres" version="7.4" />
</DATABASE>
<PHP version="4.1.0" level="required" />
<PHP_EXTENSIONS>
<PHP_EXTENSION name="mbstring" level="optional" />
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="1.6">
<DATABASE level="required">
<VENDOR name="mysql" version="4.1.16">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
</VENDOR>
<VENDOR name="postgres" version="7.4" />
</DATABASE>
<PHP version="4.3.0" level="required" />
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="optional">
<FEEDBACK>
<ON_CHECK message="iconvrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="1.7">
<UNICODE level="optional">
<FEEDBACK>
<ON_CHECK message="unicoderecommended" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="4.1.16">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
</VENDOR>
<VENDOR name="postgres" version="7.4" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="9.0" />
</DATABASE>
<PHP version="4.3.0" level="required">
<RESTRICT function="restrict_php50_version" message="php50restricted" />
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="optional">
<FEEDBACK>
<ON_CHECK message="iconvrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="1.8">
<UNICODE level="required">
<FEEDBACK>
<ON_ERROR message="unicoderequired" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="4.1.16">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="postgres" version="7.4" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="9.0" />
</DATABASE>
<PHP version="4.3.0" level="required">
<RESTRICT function="restrict_php50_version" message="php50restricted" />
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="optional">
<FEEDBACK>
<ON_CHECK message="iconvrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="curl" level="optional">
<FEEDBACK>
<ON_CHECK message="curlrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="openssl" level="optional">
<FEEDBACK>
<ON_CHECK message="opensslrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="tokenizer" level="optional">
<FEEDBACK>
<ON_CHECK message="tokenizerrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="xmlrpc" level="optional">
<FEEDBACK>
<ON_CHECK message="xmlrpcrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="ctype" level="optional">
<FEEDBACK>
<ON_CHECK message="ctyperecommended" />
</FEEDBACK>
</PHP_EXTENSION>
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="1.9">
<UNICODE level="required">
<FEEDBACK>
<ON_ERROR message="unicoderequired" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="4.1.16">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="postgres" version="8.0" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="9.0" />
</DATABASE>
<PHP version="4.3.0" level="required">
<RESTRICT function="restrict_php50_version" message="php50restricted" />
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="optional">
<FEEDBACK>
<ON_CHECK message="iconvrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="curl" level="optional">
<FEEDBACK>
<ON_CHECK message="curlrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="openssl" level="optional">
<FEEDBACK>
<ON_CHECK message="opensslrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="tokenizer" level="optional">
<FEEDBACK>
<ON_CHECK message="tokenizerrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="xmlrpc" level="optional">
<FEEDBACK>
<ON_CHECK message="xmlrpcrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="ctype" level="optional">
<FEEDBACK>
<ON_CHECK message="ctyperecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="pcre" level="required">
</PHP_EXTENSION>
</PHP_EXTENSIONS>
<CUSTOM_CHECKS>
<CUSTOM_CHECK file="question/upgrade.php" function="question_check_no_rqp_questions" level="optional">
<FEEDBACK>
<ON_CHECK message="qtyperqpwillberemovedanyway" />
<ON_OK message="qtyperqpwillberemoved" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="question/upgrade.php" function="question_random_check" level="optional">
<FEEDBACK>
<ON_OK message="questioncwqpfsok" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="required">
<FEEDBACK>
<ON_CHECK message="globalswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="2.0" requires="1.9">
<UNICODE level="required">
<FEEDBACK>
<ON_ERROR message="unicoderequired" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="10.2" />
<VENDOR name="sqlite" version="2.0" />
</DATABASE>
<PHP version="5.2.8" level="required">
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="required">
<FEEDBACK>
<ON_CHECK message="iconvrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="curl" level="required">
<FEEDBACK>
<ON_CHECK message="curlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="openssl" level="optional">
<FEEDBACK>
<ON_CHECK message="opensslrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="tokenizer" level="optional">
<FEEDBACK>
<ON_CHECK message="tokenizerrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="xmlrpc" level="optional">
<FEEDBACK>
<ON_CHECK message="xmlrpcrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="soap" level="optional">
<FEEDBACK>
<ON_CHECK message="soaprecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="ctype" level="required">
<FEEDBACK>
<ON_ERROR message="ctyperequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="zip" level="required">
<FEEDBACK>
<ON_ERROR message="ziprequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="gd" level="optional">
<FEEDBACK>
<ON_CHECK message="gdrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="simplexml" level="required">
<FEEDBACK>
<ON_CHECK message="simplexmlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="spl" level="required">
<FEEDBACK>
<ON_CHECK message="splrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="pcre" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="dom" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="xml" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="intl" level="optional">
<FEEDBACK>
<ON_CHECK message="intlrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="json" level="required">
</PHP_EXTENSION>
</PHP_EXTENSIONS>
<PHP_SETTINGS>
<PHP_SETTING name="memory_limit" value="40M" level="required">
<FEEDBACK>
<ON_ERROR message="settingmemorylimit" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="safe_mode" value="0" level="optional">
<FEEDBACK>
<ON_CHECK message="settingsafemode" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="file_uploads" value="1" level="optional">
<FEEDBACK>
<ON_CHECK message="settingfileuploads" />
</FEEDBACK>
</PHP_SETTING>
</PHP_SETTINGS>
<CUSTOM_CHECKS>
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_php533" level="optional">
<FEEDBACK>
<ON_CHECK message="php533warning" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="2.1" requires="1.9">
<UNICODE level="required">
<FEEDBACK>
<ON_ERROR message="unicoderequired" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="10.2" />
<VENDOR name="sqlite" version="2.0" />
</DATABASE>
<PHP version="5.3.2" level="required">
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="required">
<FEEDBACK>
<ON_CHECK message="iconvrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="curl" level="required">
<FEEDBACK>
<ON_CHECK message="curlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="openssl" level="optional">
<FEEDBACK>
<ON_CHECK message="opensslrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="tokenizer" level="optional">
<FEEDBACK>
<ON_CHECK message="tokenizerrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="xmlrpc" level="optional">
<FEEDBACK>
<ON_CHECK message="xmlrpcrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="soap" level="optional">
<FEEDBACK>
<ON_CHECK message="soaprecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="ctype" level="required">
<FEEDBACK>
<ON_ERROR message="ctyperequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="zip" level="required">
<FEEDBACK>
<ON_ERROR message="ziprequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="gd" level="optional">
<FEEDBACK>
<ON_CHECK message="gdrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="simplexml" level="required">
<FEEDBACK>
<ON_CHECK message="simplexmlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="spl" level="required">
<FEEDBACK>
<ON_CHECK message="splrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="pcre" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="dom" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="xml" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="intl" level="optional">
<FEEDBACK>
<ON_CHECK message="intlrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="json" level="required">
</PHP_EXTENSION>
</PHP_EXTENSIONS>
<PHP_SETTINGS>
<PHP_SETTING name="memory_limit" value="40M" level="required">
<FEEDBACK>
<ON_ERROR message="settingmemorylimit" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="safe_mode" value="0" level="optional">
<FEEDBACK>
<ON_CHECK message="settingsafemode" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="file_uploads" value="1" level="optional">
<FEEDBACK>
<ON_CHECK message="settingfileuploads" />
</FEEDBACK>
</PHP_SETTING>
</PHP_SETTINGS>
</MOODLE>
<MOODLE version="2.2" requires="1.9">
<UNICODE level="required">
<FEEDBACK>
<ON_ERROR message="unicoderequired" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="10.2" />
<VENDOR name="sqlite" version="2.0" />
</DATABASE>
<PHP version="5.3.2" level="required">
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="required">
<FEEDBACK>
<ON_CHECK message="iconvrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="curl" level="required">
<FEEDBACK>
<ON_CHECK message="curlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="openssl" level="optional">
<FEEDBACK>
<ON_CHECK message="opensslrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="tokenizer" level="optional">
<FEEDBACK>
<ON_CHECK message="tokenizerrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="xmlrpc" level="optional">
<FEEDBACK>
<ON_CHECK message="xmlrpcrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="soap" level="optional">
<FEEDBACK>
<ON_CHECK message="soaprecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="ctype" level="required">
<FEEDBACK>
<ON_ERROR message="ctyperequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="zip" level="required">
<FEEDBACK>
<ON_ERROR message="ziprequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="gd" level="optional">
<FEEDBACK>
<ON_CHECK message="gdrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="simplexml" level="required">
<FEEDBACK>
<ON_CHECK message="simplexmlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="spl" level="required">
<FEEDBACK>
<ON_CHECK message="splrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="pcre" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="dom" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="xml" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="intl" level="optional">
<FEEDBACK>
<ON_CHECK message="intlrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="json" level="required">
</PHP_EXTENSION>
</PHP_EXTENSIONS>
<PHP_SETTINGS>
<PHP_SETTING name="memory_limit" value="40M" level="required">
<FEEDBACK>
<ON_ERROR message="settingmemorylimit" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="safe_mode" value="0" level="optional">
<FEEDBACK>
<ON_CHECK message="settingsafemode" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="file_uploads" value="1" level="optional">
<FEEDBACK>
<ON_CHECK message="settingfileuploads" />
</FEEDBACK>
</PHP_SETTING>
</PHP_SETTINGS>
</MOODLE>
<MOODLE version="2.3" requires="2.2">
<UNICODE level="required">
<FEEDBACK>
<ON_ERROR message="unicoderequired" />
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
<VENDOR name="mssql_n" version="9.0" />
<VENDOR name="oracle" version="10.2" />
<VENDOR name="sqlite" version="2.0" />
</DATABASE>
<PHP version="5.3.2" level="required">
</PHP>
<PHP_EXTENSIONS>
<PHP_EXTENSION name="iconv" level="required">
<FEEDBACK>
<ON_CHECK message="iconvrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="mbstring" level="optional">
<FEEDBACK>
<ON_CHECK message="mbstringrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="curl" level="required">
<FEEDBACK>
<ON_CHECK message="curlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="openssl" level="optional">
<FEEDBACK>
<ON_CHECK message="opensslrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="tokenizer" level="optional">
<FEEDBACK>
<ON_CHECK message="tokenizerrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="xmlrpc" level="optional">
<FEEDBACK>
<ON_CHECK message="xmlrpcrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="soap" level="optional">
<FEEDBACK>
<ON_CHECK message="soaprecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="ctype" level="required">
<FEEDBACK>
<ON_ERROR message="ctyperequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="zip" level="required">
<FEEDBACK>
<ON_ERROR message="ziprequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="gd" level="optional">
<FEEDBACK>
<ON_CHECK message="gdrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="simplexml" level="required">
<FEEDBACK>
<ON_CHECK message="simplexmlrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="spl" level="required">
<FEEDBACK>
<ON_CHECK message="splrequired" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="pcre" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="dom" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="xml" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="intl" level="optional">
<FEEDBACK>
<ON_CHECK message="intlrecommended" />
</FEEDBACK>
</PHP_EXTENSION>
<PHP_EXTENSION name="json" level="required">
</PHP_EXTENSION>
<PHP_EXTENSION name="hash" level="required"/>
</PHP_EXTENSIONS>
<PHP_SETTINGS>
<PHP_SETTING name="memory_limit" value="40M" level="required">
<FEEDBACK>
<ON_ERROR message="settingmemorylimit" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="safe_mode" value="0" level="optional">
<FEEDBACK>
<ON_CHECK message="settingsafemode" />
</FEEDBACK>
</PHP_SETTING>
<PHP_SETTING name="file_uploads" value="1" level="optional">
<FEEDBACK>
<ON_CHECK message="settingfileuploads" />
</FEEDBACK>
</PHP_SETTING>
</PHP_SETTINGS>
</MOODLE>
</COMPATIBILITY_MATRIX>
+141
View File
@@ -0,0 +1,141 @@
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
<form name="filters" id="filters" method="post" action="filters.php">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table align="center" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top"><div align="right">
<br />
<input name="up" type="submit" id="up" value="&uarr;" />
<br />
<input name="down" type="submit" id="down" value="&darr;" />
<br />
</div></td>
<td valign="top">
<?php p($stractive) ?>
<br />
<select name="iselect" size="20" id="iselect"
onclick="document.filters.add.disabled=true;
document.filters.remove.disabled=false;
document.filters.uselect.selectedIndex=-1;">
<?php
$runscript = "";
foreach ($installedfilters as $filter) {
if ($selectedfilter == $filter) {
$selected = " selected ";
$runscript = "eval(\"document.filters.add.disabled=true\");
eval(\"document.filters.remove.disabled=false\");
eval(\"document.filters.uselect.selectedIndex=-1\");";
} else {
$selected = "";
}
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
}
?>
</select></td>
<td valign="top">
<br />
<input name="add" type="submit" id="add" value="&larr;" />
<br />
<input name="remove" type="submit" id="remove" value="&rarr;" />
<br />
</td>
<td valign="top">
<?php p($strinactive) ?>
<br />
<select name="uselect" size="20" id="select"
onclick="document.filters.add.disabled=false;
document.filters.remove.disabled=true;
document.filters.iselect.selectedIndex=-1;">
<?php
foreach ($uninstalledfilters as $filter) {
if ($selectedfilter == $filter) {
$selected = " selected ";
$runscript = "eval(\"document.filters.add.disabled=false\");
eval(\"document.filters.remove.disabled=true\");
eval(\"document.filters.iselect.selectedIndex=-1\");";
} else {
$selected = "";
}
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
}
?>
</select></td>
</tr>
</table>
</form>
<script language="Javascript">
<!--
<?php echo $runscript ?>
-->
</script>
<?php print_simple_box_end(); ?>
<br />
<br />
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
<form name="options" id="options" method="post" action="filters.php">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<input type="hidden" name="options" value="1">
<table cellpadding="20">
<tr valign=top>
<td nowrap="nowrap" align="right"><?php p($strcachetext) ?>:</td>
<td>
<?php
unset($options);
$options[10800] = get_string('numhours', '', 3);
$options[7200] = get_string('numhours', '', 2);
$options[3600] = get_string('numhours', '', 1);
$options[2700] = get_string('numminutes', '', 45);
$options[1800] = get_string('numminutes', '', 30);
$options[900] = get_string('numminutes', '', 15);
$options[600] = get_string('numminutes', '', 10);
$options[540] = get_string('numminutes', '', 9);
$options[480] = get_string('numminutes', '', 8);
$options[420] = get_string('numminutes', '', 7);
$options[360] = get_string('numminutes', '', 6);
$options[300] = get_string('numminutes', '', 5);
$options[240] = get_string('numminutes', '', 4);
$options[180] = get_string('numminutes', '', 3);
$options[120] = get_string('numminutes', '', 2);
$options[60] = get_string('numminutes', '', 1);
$options[30] = get_string('numseconds', '', 30);
$options[0] = get_string('no');
choose_from_menu ($options, "cachetext", $CFG->cachetext, "", "", "");
?>
</td>
<td>
<?php p($strconfigcachetext) ?>
</td>
</tr>
<tr valign=top>
<td nowrap="nowrap" align="right"><?php p($strfilteruploadedfiles) ?>:</td>
<td>
<?php
unset($options);
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, "filteruploadedfiles", $CFG->filteruploadedfiles, "", "", "");
?>
</td>
<td>
<?php p($strconfigfilteruploadedfiles) ?>
</td>
</tr>
<tr valign=top>
<td>&nbsp;</td>
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
<?php print_simple_box_end(); ?>
+141 -252
View File
@@ -1,285 +1,174 @@
<?php
<?PHP // $Id$
// Allows the admin to create, delete and rename course categories
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// 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: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
require_once("../config.php");
/**
* Processes actions from the admin_setting_managefilters object (defined in
* adminlib.php).
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package administration
*//** */
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/adminlib.php');
$action = optional_param('action', '', PARAM_ACTION);
$filterpath = optional_param('filterpath', '', PARAM_PATH);
optional_variable($iselect);
optional_variable($uselect);
optional_variable($add);
optional_variable($remove);
optional_variable($up);
optional_variable($down);
require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $systemcontext);
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
admin_externalpage_setup('managefilters');
$filters = filter_get_global_states();
// In case any new filters have been installed, but not put in the table yet.
$fitlernames = filter_get_all_installed();
$newfilters = $fitlernames;
foreach ($filters as $filter => $notused) {
unset($newfilters[$filter]);
if (!isadmin()) {
error("Only administrators can use this page!");
}
/// Process actions ============================================================
if ($action) {
if (!isset($filters[$filterpath]) && !isset($newfilters[$filterpath])) {
throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath);
}
if (!confirm_sesskey()) {
redirect($returnurl);
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
switch ($action) {
if (!$site = get_site()) {
error("Site isn't defined!");
}
case 'setstate':
if ($newstate = optional_param('newstate', '', PARAM_INTEGER)) {
filter_set_global_state($filterpath, $newstate);
if ($newstate == TEXTFILTER_DISABLED) {
filter_set_applies_to_strings($filterpath, false);
}
unset($newfilters[$filterpath]);
}
break;
/// Print headings
case 'setapplyto':
$applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
filter_set_applies_to_strings($filterpath, $applytostrings);
break;
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
$strmanagefilters = get_string("managefilters");
$strversion = get_string("version");
$strsettings = get_string("settings");
$strup = get_string("up");
$strdown = get_string("down");
$stractive = get_string("active");
$strinactive = get_string("inactive");
$strcachetext = get_string("cachetext", "admin");
$strconfigcachetext = get_string("configcachetext");
$strfilteruploadedfiles = get_string("filteruploadedfiles", "admin");
$strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles");
case 'down':
if (isset($filters[$filterpath])) {
$oldpos = $filters[$filterpath]->sortorder;
if ($oldpos <= count($filters)) {
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
print_header("$site->shortname: $strmanagefilters", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanagefilters");
print_heading($strmanagefilters);
/// Make a list of all available filters and the best names for them we can find
$allfilters = array();
$filterlocations = array("mod", "filter");
foreach ($filterlocations as $filterlocation) {
$plugins = get_list_of_plugins($filterlocation);
foreach ($plugins as $key => $plugin) {
if (is_readable("$CFG->dirroot/$filterlocation/$plugin/filter.php")) {
$name = trim(get_string("filtername", $plugin));
if (empty($name) or $name == "[[filtername]]") {
$name = $plugin;
}
$allfilters["$filterlocation/$plugin"] = $name;
}
}
break;
}
case 'up':
if (isset($filters[$filterpath])) {
$oldpos = $filters[$filterpath]->sortorder;
if ($oldpos >= 1) {
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
/// Make an array of all the currently installed filters
$installedfilters = array();
if (!empty($CFG->textfilters)) {
$installedfilters = explode(',',$CFG->textfilters);
// Do a little cleanup for robustness
foreach ($installedfilters as $key => $installedfilter) {
if (empty($installedfilter)) {
unset($installedfilters[$key]);
set_config("textfilters", implode(',', $installedfilters));
}
}
break;
case 'delete':
if (!empty($filternames[$filterpath])) {
$filtername = $filternames[$filterpath];
} else {
$filtername = $filterpath;
}
if (substr($filterpath, 0, 4) == 'mod/') {
$mod = basename($filterpath);
$a = new stdClass;
$a->filter = $filtername;
$a->module = get_string('modulename', $mod);
print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
}
// If not yet confirmed, display a confirmation message.
if (!optional_param('confirm', '', PARAM_BOOL)) {
$title = get_string('deletefilterareyousure', 'admin', $filtername);
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
echo $OUTPUT->footer();
exit;
}
// Do the deletion.
$title = get_string('deletingfilter', 'admin', $filtername);
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
// Delete all data for this plugin.
filter_delete_all_for_filter($filterpath);
$a = new stdClass;
$a->filter = $filtername;
$a->directory = $filterpath;
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($returnurl);
echo $OUTPUT->footer();
exit;
}
// Add any missing filters to the DB table.
foreach ($newfilters as $filter => $notused) {
filter_set_global_state($filter, TEXTFILTER_DISABLED);
}
$selectedfilter = "none";
// Reset caches and return
if ($action) {
reset_text_filters_cache();
redirect($returnurl);
}
/// If data submitted, then process and store.
/// End of process actions =====================================================
/// Print the page heading.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
$activechoices = array(
TEXTFILTER_DISABLED => get_string('disabled', 'filters'),
TEXTFILTER_OFF => get_string('offbutavailable', 'filters'),
TEXTFILTER_ON => get_string('on', 'filters'),
);
$applytochoices = array(
0 => get_string('content', 'filters'),
1 => get_string('contentandheadings', 'filters'),
);
$filters = filter_get_global_states();
// In case any new filters have been installed, but not put in the table yet.
$filternames = filter_get_all_installed();
$newfilters = $filternames;
foreach ($filters as $filter => $notused) {
unset($newfilters[$filter]);
}
$stringfilters = filter_get_string_filters();
$table = new html_table();
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
$table->align = array('left', 'left', 'center', 'left', 'left');
$table->width = '100%';
$table->data = array();
$lastactive = null;
foreach ($filters as $filter => $filterinfo) {
if ($filterinfo->active != TEXTFILTER_DISABLED) {
$lastactive = $filter;
if (!empty($options)) {
if ($config = data_submitted()) {
unset($config->options);
foreach ($config as $name => $value) {
set_config($name, $value);
}
}
}
// iterate through filters adding to display table
$firstrow = true;
foreach ($filters as $filter => $filterinfo) {
$applytostrings = isset($stringfilters[$filter]) && $filterinfo->active != TEXTFILTER_DISABLED;
$row = get_table_row($filterinfo, $firstrow, $filter == $lastactive, $applytostrings);
$table->data[] = $row;
if ($filterinfo->active == TEXTFILTER_DISABLED) {
$table->rowclasses[] = 'dimmed_text';
} else {
$table->rowclasses[] = '';
if (!empty($add) and !empty($uselect)) {
$selectedfilter = $uselect;
if (!in_array($selectedfilter, $installedfilters)) {
$installedfilters[] = $selectedfilter;
set_config("textfilters", implode(',', $installedfilters));
}
$firstrow = false;
}
foreach ($newfilters as $filter => $filtername) {
$filterinfo = new stdClass;
$filterinfo->filter = $filter;
$filterinfo->active = TEXTFILTER_DISABLED;
$row = get_table_row($filterinfo, false, false, false);
$table->data[] = $row;
$table->rowclasses[] = 'dimmed_text';
}
echo html_writer::table($table);
echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
echo $OUTPUT->footer();
/// Display helper functions ===================================================
function filters_action_url($filterpath, $action) {
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
}
function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) {
global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!!
$row = array();
$filter = $filterinfo->filter;
// Filter name
if (!empty($filternames[$filter])) {
$row[] = $filternames[$filter];
} else {
$row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>';
}
// Disable/off/on
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
$row[] = $OUTPUT->render($select);
// Re-order
$updown = '';
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" /> ';
if ($filterinfo->active != TEXTFILTER_DISABLED) {
if (!$isfirstrow) {
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up')));
} else {
$updown .= $spacer;
} else if (!empty($remove) and !empty($iselect)) {
$selectedfilter = $iselect;
foreach ($installedfilters as $key => $installedfilter) {
if ($installedfilter == $selectedfilter) {
unset($installedfilters[$key]);
}
}
if (!$islastactive) {
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down')));
} else {
$updown .= $spacer;
set_config("textfilters", implode(',', $installedfilters));
} else if ((!empty($up) or !empty($down)) and !empty($iselect)) {
if (!empty($up)) {
if ($allfilters[$iselect]) {
foreach ($installedfilters as $key => $installedfilter) {
if ($installedfilter == $iselect) {
$movefilter = $key;
break;
}
$swapfilter = $key;
}
}
}
if (!empty($down)) {
if ($allfilters[$iselect]) {
$choosenext = false;
foreach ($installedfilters as $key => $installedfilter) {
if ($choosenext) {
$swapfilter = $key;
break;
}
if ($installedfilter == $iselect) {
$movefilter = $key;
$choosenext = true;
}
}
}
}
if (isset($swapfilter) and isset($movefilter)) {
$tempfilter = $installedfilters[$swapfilter];
$installedfilters[$swapfilter] = $installedfilters[$movefilter];
$installedfilters[$movefilter] = $tempfilter;
set_config("textfilters", implode(',', $installedfilters));
}
$selectedfilter = $iselect;
}
/// Make an array of all the currently uninstalled filters
$uninstalledfilters = array();
foreach ($allfilters as $filter => $name) {
$installed = false;
foreach ($installedfilters as $installedfilter) {
if ($installedfilter == $filter) {
$installed = true;
}
}
if (!$installed) {
$uninstalledfilters[] = $filter;
}
}
$row[] = $updown;
// Apply to strings.
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
$row[] = $OUTPUT->render($select);
/// Print the current form
// Settings link, if required
if (filter_has_global_settings($filter)) {
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' .
str_replace('/', '',$filter) . '">' . get_string('settings') . '</a>';
} else {
$row[] = '';
}
include("filters.html");
// Delete
if (substr($filter, 0, 4) != 'mod/') {
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
} else {
$row[] = '';
}
return $row;
}
print_footer();
?>
-150
View File
@@ -1,150 +0,0 @@
<?php
/** This expects the output from a command like
* clamscan -r --infected --no-summary <files> 2>&1 | php -d error_log=/path/to/log thisfile.php
* also it's important that the output of clamscan prints the FULL PATH to each infected file, so use absolute paths for area to scan
* also it should be run as root, or whatever the webserver runs as so that it has the right permissions in the quarantine dir etc.
* php -d error_log=/path/to/log thisfile.php will override the default error log for php cli, which is stderr, so if you want this script to just print stuff out, use php thisfile.php instead.
*/
die('TODO: MDL-19380');
$fd = fopen('php://stdin','r');
if (!$fd) {
exit();
}
require_once(dirname(dirname(__FILE__)).'/config.php');
require_once($CFG->libdir.'/eventslib.php');
require_once($CFG->dirroot.'/lib/uploadlib.php'); // contains virus handling stuff.
$site = get_site();
while(!feof($fd)) {
$entry = fgets($fd);
if (strlen(trim($entry)) == 0) {
continue;
}
if (!$file = validate_line($entry)) {
continue;
}
$bits = explode('/',$file);
$a->filename = $bits[count($bits)-1];
if (!$log = $DB->get_record("log", array("module"=>"upload", "info"=>$file, "action"=>"upload"))) {
$a->action = clam_handle_infected_file($file,0,false);
clam_replace_infected_file($file);
notify_admins_unknown($file,$a);
continue;
}
$action = clam_handle_infected_file($file,$log->userid,true);
clam_replace_infected_file($file);
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid";
$course = $DB->get_record_sql($sql, array('courseid' => $log->course));
context_instance_preload($course);
$user = $DB->get_record("user", array("id"=>$log->userid));
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
$a->date = userdate($log->time);
$a->action = $action;
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$a->user = fullname($user);
notify_user($user,$subject,$a);
notify_admins($user,$subject,$a);
}
fclose($fd);
function notify_user($user,$subject,$a) {
if (!$user) {
return false;
}
$body = get_string('virusfoundlater','moodle',$a);
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = get_admin();
$eventdata->userto = $user;
$eventdata->subject = $subject;
$eventdata->fullmessage = $body;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
}
function notify_admins($user,$subject,$a) {
$admins = get_admins();
$body = get_string('virusfoundlateradmin','moodle',$a);
foreach ($admins as $admin) {
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = $admin;
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $body;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
}
}
function notify_admins_unknown($file,$a) {
global $site;
$admins = get_admins();
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
$body = get_string('virusfoundlateradminnolog','moodle',$a);
foreach ($admins as $admin) {
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = $admin;
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $body;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
}
}
function validate_line($line) {
global $CFG;
if (strpos($line,"FOUND") === false) {
return false;
}
$index = strpos($line,":");
$file = substr($line,0,$index);
if (!(strpos($file,$CFG->dataroot) === false)) {
if (!file_exists($file)) {
return false;
}
}
else {
if ($file{0} == "/") {
$file = $CFG->dataroot.$file;
}
else {
$file = $CFG->dataroot."/".$file;
}
if (!file_exists($file)) {
return false;
}
}
// clean up
$file = preg_replace('/\.\//','/',$file);
$file = preg_replace('/\/\//','/',$file);
return $file;
}
+330 -333
View File
@@ -1,369 +1,366 @@
<?php
<?PHP // $Id$
// 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/>.
/**
* Main administration script.
*
* @package core
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Check that config.php exists, if not then call the install script
if (!file_exists('../config.php')) {
header('Location: ../install.php');
die();
}
// Check that PHP is of a sufficient version as soon as possible
if (version_compare(phpversion(), '5.3.2') < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
echo "Please upgrade your server software or install older Moodle version.";
die();
}
// make sure iconv is available and actually works
if (!function_exists('iconv')) {
// this should not happen, this must be very borked install
echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
die();
}
if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
// known to be broken in mid-2011 MAMP installations
echo 'Broken iconv PHP extension detected, installation/upgrade can not continue.';
die();
}
define('NO_OUTPUT_BUFFERING', true);
require('../config.php');
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
$id = optional_param('id', '', PARAM_TEXT);
$confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
$confirmrelease = optional_param('confirmrelease', 0, PARAM_BOOL);
$confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
$showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
// Check some PHP server settings
$PAGE->set_url('/admin/index.php');
$PAGE->set_pagelayout('admin'); // Set a default pagelayout
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
if (ini_get_bool('session.auto_start')) {
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
}
if (ini_get_bool('magic_quotes_runtime')) {
print_error('phpvaroff', 'debug', '', (object)array('name'=>'magic_quotes_runtime', 'link'=>$documentationlink));
}
if (!ini_get_bool('file_uploads')) {
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
}
if (is_float_problem()) {
print_error('phpfloatproblem', 'admin', '', $documentationlink);
}
// Set some necessary variables during set-up to avoid PHP warnings later on this page
if (!isset($CFG->release)) {
$CFG->release = '';
}
if (!isset($CFG->version)) {
$CFG->version = '';
}
$version = null;
$release = null;
require("$CFG->dirroot/version.php"); // defines $version, $release and $maturity
$CFG->target_release = $release; // used during installation and upgrades
if (!$version or !$release) {
print_error('withoutversion', 'debug'); // without version, stop
}
if (!isset($maturity)) {
// Fallback for now. Should probably be removed in the future.
$maturity = MATURITY_STABLE;
}
// Turn off xmlstrictheaders during upgrade.
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
$CFG->xmlstrictheaders = false;
if (!core_tables_exist()) {
$PAGE->set_pagelayout('maintenance');
$PAGE->set_popup_notification_allowed(false);
// fake some settings
$CFG->docroot = 'http://docs.moodle.org';
$strinstallation = get_string('installation', 'install');
// remove current session content completely
session_get_instance()->terminate_current();
if (empty($agreelicense)) {
$strlicense = get_string('license');
$PAGE->navbar->add($strlicense);
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
$PAGE->set_heading($strinstallation);
$PAGE->set_cacheable(false);
$output = $PAGE->get_renderer('core', 'admin');
echo $output->install_licence_page();
die();
}
if (empty($confirmrelease)) {
require_once($CFG->libdir.'/environmentlib.php');
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
$strcurrentrelease = get_string('currentrelease');
$PAGE->navbar->add($strcurrentrelease);
$PAGE->set_title($strinstallation);
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
$PAGE->set_cacheable(false);
$output = $PAGE->get_renderer('core', 'admin');
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
die();
/// Check that config.php exists, if not then call the install script
if (!file_exists("../config.php")) {
header('Location: ../install.php');
die;
}
//TODO: add a page with list of non-standard plugins here
require_once("../config.php");
include_once("$CFG->dirroot/lib/adminlib.php"); // Contains various admin-only functions
$strdatabasesetup = get_string('databasesetup');
upgrade_init_javascript();
$PAGE->navbar->add($strdatabasesetup);
$PAGE->set_title($strinstallation.' - Moodle '.$CFG->target_release);
$PAGE->set_heading($strinstallation);
$PAGE->set_cacheable(false);
/// Check that PHP is of a sufficient version
$output = $PAGE->get_renderer('core', 'admin');
echo $output->header();
if (!$DB->setup_is_unicodedb()) {
if (!$DB->change_db_encoding()) {
// If could not convert successfully, throw error, and prevent installation
print_error('unicoderequired', 'admin');
}
if (!check_php_version("4.1.0")) {
$version = phpversion();
print_heading("Sorry, Moodle requires PHP 4.1.0 or later (currently using version $version)");
die;
}
install_core($version, true);
}
/// Check some PHP server settings
// Check version of Moodle code on disk compared with database
// and upgrade if possible.
$documentationlink = "please read the <A HREF=\"../doc/?frame=install.html&sub=webserver\">install documentation</A>";
$stradministration = get_string('administration');
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
if (empty($CFG->version)) {
print_error('missingconfigversion', 'debug');
}
if ($version > $CFG->version) { // upgrade
purge_all_caches();
$PAGE->set_pagelayout('maintenance');
$PAGE->set_popup_notification_allowed(false);
if (empty($confirmupgrade)) {
$a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)";
$strdatabasechecking = get_string('databasechecking', '', $a);
$PAGE->set_title($stradministration);
$PAGE->set_heading($strdatabasechecking);
$PAGE->set_cacheable(false);
$output = $PAGE->get_renderer('core', 'admin');
echo $output->upgrade_confirm_page($a->newversion, $maturity);
die();
} else if (empty($confirmrelease)){
require_once($CFG->libdir.'/environmentlib.php');
list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
$strcurrentrelease = get_string('currentrelease');
$PAGE->navbar->add($strcurrentrelease);
$PAGE->set_title($strcurrentrelease);
$PAGE->set_heading($strcurrentrelease);
$PAGE->set_cacheable(false);
$output = $PAGE->get_renderer('core', 'admin');
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
die();
} else if (empty($confirmplugins)) {
$strplugincheck = get_string('plugincheck');
$PAGE->navbar->add($strplugincheck);
$PAGE->set_title($strplugincheck);
$PAGE->set_heading($strplugincheck);
$PAGE->set_cacheable(false);
$output = $PAGE->get_renderer('core', 'admin');
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), $version, $showallplugins,
new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)),
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
die();
} else {
// Launch main upgrade
upgrade_core($version, true);
if (ini_get_bool('session.auto_start')) {
error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
}
} else if ($version < $CFG->version) {
// better stop here, we can not continue with plugin upgrades or anything else
throw new moodle_exception('downgradedcore', 'error', new moodle_url('/admin/'));
}
// Updated human-readable release version if necessary
if ($release <> $CFG->release) { // Update the release version
set_config('release', $release);
}
if (moodle_needs_upgrading()) {
if (!$PAGE->headerprinted) {
// means core upgrade or installation was not already done
if (!$confirmplugins) {
$strplugincheck = get_string('plugincheck');
$PAGE->set_pagelayout('maintenance');
$PAGE->set_popup_notification_allowed(false);
$PAGE->navbar->add($strplugincheck);
$PAGE->set_title($strplugincheck);
$PAGE->set_heading($strplugincheck);
$PAGE->set_cacheable(false);
$output = $PAGE->get_renderer('core', 'admin');
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), $version, $showallplugins,
new moodle_url('/admin/index.php'),
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
die();
}
if (ini_get_bool('magic_quotes_runtime')) {
error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
}
// install/upgrade all plugins and other parts
upgrade_noncore(true);
}
// If this is the first install, indicate that this site is fully configured
// except the admin password
if (during_initial_install()) {
set_config('rolesactive', 1); // after this, during_initial_install will return false.
set_config('adminsetuppending', 1);
// we need this redirect to setup proper session
upgrade_finished("index.php?sessionstarted=1&amp;lang=$CFG->lang");
}
if (!ini_get_bool('file_uploads')) {
error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
}
// make sure admin user is created - this is the last step because we need
// session to be working properly in order to edit admin account
if (!empty($CFG->adminsetuppending)) {
$sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL);
if (!$sessionstarted) {
redirect("index.php?sessionstarted=1&lang=$CFG->lang");
} else {
$sessionverify = optional_param('sessionverify', 0, PARAM_BOOL);
if (!$sessionverify) {
$SESSION->sessionverify = 1;
redirect("index.php?sessionstarted=1&sessionverify=1&lang=$CFG->lang");
} else {
if (empty($SESSION->sessionverify)) {
print_error('installsessionerror', 'admin', "index.php?sessionstarted=1&lang=$CFG->lang");
/// Check that config.php has been edited
if ($CFG->wwwroot == "http://example.com/moodle") {
error("Moodle has not been configured yet. You need to to edit config.php first.");
}
/// Check settings in config.php
$dirroot = dirname(realpath("../index.php"));
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
error("Please fix your settings in config.php:
<P>You have:
<P>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
<P>but it should be:
<P>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
"./");
}
/// Set some necessary variables during set-up to avoid PHP warnings later on this page
if (!isset($CFG->framename)) {
$CFG->framename = "_top";
}
if (!isset($CFG->release)) {
$CFG->release = "";
}
if (!isset($CFG->version)) {
$CFG->version = "";
}
/// Turn off time limits, sometimes upgrades can be slow.
@set_time_limit(0);
/// Check if the main tables have been installed yet or not.
if (! $tables = $db->Metatables() ) { // No tables yet at all.
$maintables = false;
} else { // Check for missing main tables
$maintables = true;
$mtables = array("config", "course", "course_categories", "course_modules",
"course_sections", "log", "log_display", "modules",
"user", "user_admins", "user_students", "user_teachers");
foreach ($mtables as $mtable) {
if (!in_array($CFG->prefix.$mtable, $tables)) {
$maintables = false;
break;
}
unset($SESSION->sessionverify);
}
}
// at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that
$adminuser = get_complete_user_data('id', reset(explode(',', $CFG->siteadmins)));
if ($adminuser->password === 'adminsetuppending') {
// prevent installation hijacking
if ($adminuser->lastip !== getremoteaddr()) {
print_error('installhijacked', 'admin');
if (! $maintables) {
if (empty($agreelicence)) {
$strlicense = get_string("license");
print_header($strlicense, $strlicense, $strlicense, "", "", false, "&nbsp;", "&nbsp;");
print_heading("<A HREF=\"http://moodle.org\">Moodle</A> - Modular Object-Oriented Dynamic Learning Environment");
print_heading(get_string("copyrightnotice"));
print_simple_box_start("center");
echo text_to_html(get_string("gpl"));
print_simple_box_end();
echo "<br />";
notice_yesno(get_string("doyouagree"), "index.php?agreelicence=true",
"http://moodle.org/doc/?frame=licence.html");
exit;
}
// login user and let him set password and admin details
$adminuser->newadminuser = 1;
complete_user_login($adminuser);
redirect("$CFG->wwwroot/user/editadvanced.php?id=$adminuser->id"); // Edit thyself
$strdatabasesetup = get_string("databasesetup");
$strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup, "", "", false, "&nbsp;", "&nbsp;");
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
$db->debug = true;
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
$db->debug = false;
notify($strdatabasesuccess, "green");
} else {
$db->debug = false;
error("Error: Main databases NOT set up successfully");
}
} else {
error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle. See the lib/db directory.");
}
print_continue("index.php");
die;
}
/// Insert default values for any important configuration variables
include_once("$CFG->dirroot/lib/defaults.php");
foreach ($defaults as $name => $value) {
if (!isset($CFG->$name)) {
$CFG->$name = $value;
set_config($name, $value);
$configchange = true;
}
}
/// If any new configurations were found then send to the config page to check
if (!empty($configchange)) {
redirect("config.php");
}
/// Check version of Moodle code on disk compared with database
/// and upgrade if possible.
include_once("$CFG->dirroot/version.php"); # defines $version
include_once("$CFG->dirroot/lib/db/$CFG->dbtype.php"); # defines upgrades
if ($CFG->version) {
if ($version > $CFG->version) { // upgrade
$a->oldversion = $CFG->version;
$a->newversion = $version;
$strdatabasechecking = get_string("databasechecking", "", $a);
$strdatabasesuccess = get_string("databasesuccess");
print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking,
"", "", false, "&nbsp;", "&nbsp;");
print_heading($strdatabasechecking);
$db->debug=true;
if (main_upgrade($CFG->version)) {
$db->debug=false;
if (set_config("version", $version)) {
notify($strdatabasesuccess, "green");
print_continue("index.php");
die;
} else {
notify("Upgrade failed! (Could not update version in config table)");
}
} else {
$db->debug=false;
notify("Upgrade failed! See /version.php");
}
} else if ($version < $CFG->version) {
notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
}
} else {
unset_config('adminsetuppending');
$strcurrentversion = get_string("currentversion");
print_header($strcurrentversion, $strcurrentversion, $strcurrentversion,
"", "", false, "&nbsp;", "&nbsp;");
if (set_config("version", $version)) {
print_heading("You are currently using Moodle version $version (Release $release)");
print_continue("index.php");
die;
} else {
$db->debug=true;
if (main_upgrade(0)) {
print_continue("index.php");
} else {
error("A problem occurred inserting current version into databases");
}
$db->debug=false;
}
}
} else {
// just make sure upgrade logging is properly terminated
upgrade_finished('upgradesettings.php');
}
/// Updated human-readable release version if necessary
// Turn xmlstrictheaders back on now.
$CFG->xmlstrictheaders = $origxmlstrictheaders;
unset($origxmlstrictheaders);
if ($release <> $CFG->release) { // Update the release version
$strcurrentrelease = get_string("currentrelease");
print_header($strcurrentrelease, $strcurrentrelease, $strcurrentrelease, "", "", false, "&nbsp;", "&nbsp;");
print_heading("Moodle $release");
if (!set_config("release", $release)) {
notify("ERROR: Could not update release version in database!!");
}
print_continue("index.php");
print_simple_box_start("CENTER");
include("$CFG->dirroot/lang/en/docs/release.html");
print_simple_box_end();
print_continue("index.php");
exit;
}
// Check for valid admin user - no guest autologin
require_login(0, false);
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context);
// check that site is properly customized
$site = get_site();
if (empty($site->shortname)) {
// probably new installation - lets return to frontpage after this step
// remove settings that we want uninitialised
unset_config('registerauth');
redirect('upgradesettings.php?return=site');
}
/// Upgrade backup/restore system if necessary
require_once("$CFG->dirroot/backup/lib.php");
upgrade_backup_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
if (!empty($id) and $id == $CFG->siteidentifier) {
set_config('registered', time());
}
/// Upgrade blocks system if necessary
require_once("$CFG->dirroot/lib/blocklib.php");
upgrade_blocks_db("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
// setup critical warnings before printing admin tree block
$insecuredataroot = is_dataroot_insecure(true);
$SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
/// Check all blocks and load (or upgrade them if necessary)
upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
$adminroot = admin_get_root();
/// Check all enrolment plugins and upgrade if necessary
upgrade_enrol_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
/// Find and check all main modules and load them up or upgrade them if necessary
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
// Check if there are any new admin settings which have still yet to be set
if (any_new_admin_settings($adminroot)){
redirect('upgradesettings.php');
}
// Everything should now be set up, and the user is an admin
// Print default admin page with notifications.
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
/// Set up the overall site name etc.
if (! $site = get_site()) {
redirect("site.php");
}
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
$cronoverdue = ($lastcron < time() - 3600 * 24);
$dbproblems = $DB->diagnose();
$maintenancemode = !empty($CFG->maintenance_enabled);
/// Set up the admin user
if (! record_exists("user_admins")) { // No admin user yet
redirect("user.php");
}
admin_externalpage_setup('adminnotifications');
$output = $PAGE->get_renderer('core', 'admin');
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
$cronoverdue, $dbproblems, $maintenancemode);
/// Check for valid admin user
require_login();
if (!isadmin()) {
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
/// At this point everything is set up and the user is an admin, so print menu
$stradministration = get_string("administration");
print_header("$site->shortname: $stradministration","$site->fullname", "$stradministration");
print_simple_box_start("center", "100%", "$THEME->cellcontent2", 20);
print_heading($stradministration);
if (!empty($CFG->upgrade)) { // Print notice about extra upgrading that needs to be done
print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
"$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center");
print_spacer(10,10);
}
$table->tablealign = "right";
$table->align = array ("right", "left");
$table->wrap = array ("nowrap", "nowrap");
$table->cellpadding = 4;
$table->cellspacing = 3;
$table->width = "40%";
$configdata = "<font size=+1>&nbsp;</font><a href=\"config.php\">".get_string("configvariables")."</a> - <font size=1>".
get_string("adminhelpconfigvariables")."</font><br />";
$configdata .= "<font size=+1>&nbsp;</font><a href=\"site.php\">".get_string("sitesettings")."</a> - <font size=1>".
get_string("adminhelpsitesettings")."</font><br />";
$configdata .= "<font size=+1>&nbsp;</font><a href=\"../theme/index.php\">".get_string("themes")."</a> - <font size=1>".
get_string("adminhelpthemes")."</font><br />";
$configdata .= "<font size=+1>&nbsp;</font><a href=\"lang.php\">".get_string("language")."</a> - <font size=1>".
get_string("adminhelplanguage")."</font><br />";
$configdata .= "<font size=+1>&nbsp;</font><a href=\"modules.php\">".get_string("managemodules")."</a> - <font size=1>".
get_string("adminhelpmanagemodules")."</font><br />";
$configdata .= "<font size=+1>&nbsp;</font><a href=\"blocks.php\">".get_string("manageblocks")."</a> - <font size=1>".
get_string("adminhelpmanageblocks")."</font><br />";
$configdata .= "<font size=+1>&nbsp;</font><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a> - <font size=1>".
get_string("adminhelpmanagefilters")."</font><br />";
if (!isset($CFG->disablescheduledbackups)) {
$configdata .= "<font size=+1>&nbsp;</font><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a> - <font size=1>".
get_string("adminhelpbackup")."</font><br />";
}
$configdata .= "<font size=+1>&nbsp;</font><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a> - <font size=1>".
get_string("adminhelpeditorsettings")."</font><br />";
$table->data[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>",
$configdata);
$userdata = "<font size=+1>&nbsp;</font><a href=\"auth.php?sesskey=$USER->sesskey\">".get_string("authentication")."</a> - <font size=1>".
get_string("adminhelpauthentication")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"user.php\">".get_string("edituser")."</a> - <font size=1>".
get_string("adminhelpedituser")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".
get_string("addnewuser")."</a> - <font size=1>".
get_string("adminhelpaddnewuser")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".
get_string("uploadusers")."</a> - <font size=1>".
get_string("adminhelpuploadusers")."</font><br />";
$userdata .= "<hr><font size=+1>&nbsp;</font><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a> - <font size=1>".
get_string("adminhelpenrolments")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a> - <font size=1>".
get_string("adminhelpassignstudents")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a> - <font size=1>".
get_string("adminhelpassignteachers").
" <img src=\"../pix/t/user.gif\" height=11 width=11></font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a> - <font size=1>".
get_string("adminhelpassigncreators")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a> - <font size=1>".
get_string("adminhelpassignadmins")."</font><br />";
$table->data[] = array("<font size=+1><b><a href=\"users.php\">".get_string("users")."</a></b>", $userdata);
$table->data[] = array("<font size=+1><b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("courses")."</a></b>",
"<font size=+1>&nbsp;</font>".get_string("adminhelpcourses"));
$table->data[] = array("<font size=+1><b><a href=\"../course/log.php?id=$site->id\">".get_string("logs")."</a></b>",
"<font size=+1>&nbsp;</font>".get_string("adminhelplogs"));
$table->data[] = array("<font size=+1><b><a href=\"../files/index.php?id=$site->id\">".get_string("sitefiles")."</a></b>",
"<font size=+1>&nbsp;</font>".get_string("adminhelpsitefiles"));
if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
$table->data[] = array("<font size=+1><b><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></b>",
"<font size=+1>&nbsp;</font>".get_string("adminhelpmanagedatabase"));
}
print_table($table);
//////////////////////////////////////////////////////////////////////////////////////////////////
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO REMOVE OR MODIFY THE COPYRIGHT NOTICE BELOW ////
$copyrighttext = "<a href=\"http://moodle.org/\">Moodle</a> ".
"<a href=\"../doc/?frame=release.html\">$CFG->release</a> ($CFG->version)<br />".
"Copyright &copy; 1999-2004 Martin Dougiamas<br />".
"<a href=\"../doc/?frame=licence.html\">GNU Public License</a>";
echo "<center><p><font size=1>$copyrighttext</font></p></center>";
//////////////////////////////////////////////////////////////////////////////////////////////////
echo "<table border=0 align=center width=100%><tr>";
echo "<td align=center width=33%>";
print_single_button("$CFG->wwwroot/doc", NULL, get_string("documentation"));
echo "</td>";
echo "<td align=center width=33%>";
print_single_button("phpinfo.php", NULL, get_string("phpinfo"));
echo "</td>";
echo "<td align=center width=33%>";
$options['sesskey'] = $USER->sesskey;
print_single_button("register.php", $options, get_string("registration"));
echo "</td>";
echo "<tr></table>";
print_simple_box_end();
print_footer($site);
?>
+324
View File
@@ -0,0 +1,324 @@
<?PHP // $Id$
require_once("../config.php");
optional_variable($mode, "");
optional_variable($currentfile, "moodle.php");
require_login();
if (!isadmin()) {
error("You need to be admin to edit this page");
}
if (! $site = get_site()) {
error("Site not defined!");
}
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
$strlanguage = get_string("language");
$strcurrentlanguage = get_string("currentlanguage");
$strmissingstrings = get_string("missingstrings");
$strcomparelanguage = get_string("comparelanguage");
$strthislanguage = get_string("thislanguage");
switch ($mode) {
case "missing":
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strmissingstrings";
$title = $strmissingstrings;
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/admin/lang.php">'.
'<input type="hidden" name="mode" value="compare" />'.
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
'<input type="submit" value="'.$strcomparelanguage.'" /></form>';
break;
case "compare":
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strcomparelanguage";
$title = $strcomparelanguage;
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/admin/lang.php">'.
'<input type="hidden" name="mode" value="missing" />'.
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
'<input type="submit" value="'.$strmissingstrings.'" /></form>';
break;
default:
$title = $strlanguage;
$navigation = $strlanguage;
$button = '';
break;
}
$currentlang = current_language();
print_header("$site->shortname: $title", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $navigation",
'', '', true, $button);
if (!$mode) {
$currlang = current_language();
$langs = get_list_of_languages();
echo "<table align=center><tr><td align=\"right\">";
echo "<b>$strcurrentlanguage:</b>";
echo "</td><td>";
echo popup_form ("$CFG->wwwroot/admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
echo "</td></tr></table>";
print_heading("<a href=\"lang.php?mode=missing&sesskey=$USER->sesskey\">$strmissingstrings</a>");
print_heading("<a href=\"lang.php?mode=compare&sesskey=$USER->sesskey\">$strcomparelanguage</a>");
echo "<center><hr noshade size=1>";
$options["lang"] = $currentlang;
print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
echo "</center>";
print_footer();
exit;
}
// Get a list of all the root files in the English directory
$langdir = "$CFG->dirroot/lang/$currentlang";
$enlangdir = "$CFG->dirroot/lang/en";
if (! $stringfiles = get_directory_list($enlangdir, "", false)) {
error("Could not find English language pack!");
}
foreach ($stringfiles as $key => $file) {
if (substr($file, -4) != ".php") {
unset($stringfiles[$key]);
}
}
if ($mode == "missing" and confirm_sesskey()) {
// For each file, check that a counterpart exists, then check all the strings
foreach ($stringfiles as $file) {
if (!file_exists("$langdir/$file")) {
if (!touch("$langdir/$file")) {
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$file")."</font></p>";
continue;
}
}
unset($string);
include("$enlangdir/$file");
$enstring = $string;
unset($string);
include("$langdir/$file");
$first = true;
foreach ($enstring as $key => $value) {
if (!isset($string[$key]) or $string[$key] == "") {
$value = htmlspecialchars($value);
$value = str_replace("$"."a", "\\$"."a", $value);
$value = str_replace("%%","%",$value);
if ($first) {
echo "<p><b>".get_string("stringsnotset","","$langdir/$file")."</b></p><pre>";
$first = false;
$somethingfound = true;
}
echo "$"."string['$key'] = \"$value\";<br />";
}
}
if (!$first) {
echo '</pre><hr />';
}
}
if (! $files = get_directory_list("$CFG->dirroot/lang/en/help", "CVS")) {
error("Could not find English language help files!");
}
foreach ($files as $filekey => $file) { // check all the help files.
if (!file_exists("$langdir/help/$file")) {
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/help/$file")."</font></p>";
$somethingfound = true;
continue;
}
}
if (! $files = get_directory_list("$CFG->dirroot/lang/en/docs", "CVS")) {
error("Could not find English language docs files!");
}
foreach ($files as $filekey => $file) { // check all the docs files.
if (!file_exists("$langdir/docs/$file")) {
echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/docs/$file")."</FONT></P>";
$somethingfound = true;
continue;
}
}
if (!empty($somethingfound)) {
print_continue("lang.php");
} else {
notice(get_string("languagegood"), "lang.php");
}
} else if ($mode == "compare" and confirm_sesskey()) {
if (isset($_POST['currentfile'])){ // Save a file
$newstrings = $_POST;
unset($newstrings['currentfile']);
if (lang_save_file($langdir, $currentfile, $newstrings)) {
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
} else {
error("Could not save the file '$currentfile'!", "lang.php?mode=compare&currentfile=$currentfile&sesskey=$USER->sesskey");
}
}
print_heading_with_help($strcomparelanguage, "langedit");
print_simple_box_start("center", "80%");
echo '<center><font size="2">';
foreach ($stringfiles as $file) {
if ($file == $currentfile) {
echo "<b>$file</b> &nbsp; ";
} else {
echo "<a href=\"lang.php?mode=compare&currentfile=$file&sesskey=$USER->sesskey\">$file</a> &nbsp; ";
}
}
echo '</font></center>';
print_simple_box_end();
print_heading("$currentfile", "center", 4);
if (!file_exists("$langdir/$currentfile")) {
if (!touch("$langdir/$currentfile")) {
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$currentfile")."</font></p>";
continue;
}
}
error_reporting(0);
if ($f = fopen("$langdir/$currentfile","r+")) {
$editable = true;
fclose($f);
} else {
$editable = false;
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")."</font></p>";
}
error_reporting(7);
unset($string);
include("$enlangdir/$currentfile");
$enstring = $string;
if ($currentlang != 'en') {
$enstring['thislanguage'] = "<< TRANSLATORS: Specify the name of your language here. If possible use Unicode Numeric Character References >>";
$enstring['thischarset'] = "<< TRANSLATORS: Specify the character set of your language here. Note that all text created while this language is active will be stored using this character set, so don't change it once you have set it. Example: iso-8859-1 >>";
$enstring['thisdirection'] = "<< TRANSLATORS: This string specifies the direction of your text, either left-to-right or right-to-left. Insert either 'ltr' or 'rtl' here. >>";
$enstring['parentlanguage'] = "<< TRANSLATORS: If your language has a Parent Language that Moodle should use when strings are missing from your language pack, then specify the code for it here. If you leave this blank then English will be used. Example: nl >>";
}
ksort($enstring);
unset($string);
include("$langdir/$currentfile");
if ($editable) {
echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
}
echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>";
foreach ($enstring as $key => $envalue) {
$envalue = nl2br(htmlspecialchars($envalue));
$envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
$envalue = str_replace("%%","%",$envalue);
$envalue = str_replace("\\","",$envalue); // Delete all slashes
echo "\n\n<tr>";
echo "<td dir=ltr lang=en width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>\n";
echo "<td dir=ltr lang=en width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>\n";
$value = $string[$key];
$value = str_replace("\r","",$value); // Bad character caused by Windows
$value = preg_replace("/\n{3,}/", "\n\n", $value); // Collapse runs of blank lines
$value = trim($value, "\n"); // Delete leading/trailing lines
$value = str_replace("\\","",$value); // Delete all slashes
$value = str_replace("%%","%",$value);
$value = str_replace("<","&lt;",$value);
$value = str_replace(">","&gt;",$value);
$value = str_replace('"',"&quot;",$value);
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
if ($editable) {
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>\n";
if (isset($string[$key])) {
$valuelen = strlen($value);
} else {
$valuelen = strlen($envalue);
}
$cols=50;
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
$rows = ceil($valuelen / $cols);
echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>\n";
} else {
if ($valuelen) {
$cols = $valuelen + 2;
}
echo "<input type=\"text\" name=\"string-$key\" value=\"$value\" size=\"$cols\"></td>";
}
echo "</TD>\n";
} else {
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>\n";
}
}
if ($editable) {
echo "<tr><td colspan=2>&nbsp;<td><br />";
echo " <input type=\"hidden\" name=\"currentfile\" value=\"$currentfile\">";
echo " <input type=\"hidden\" name=\"mode\" value=\"compare\">";
echo " <input type=\"submit\" name=\"update\" value=\"".get_string("savechanges").": $currentfile\">";
echo "</td></tr>";
}
echo "</table>";
echo "</form>";
}
print_footer();
//////////////////////////////////////////////////////////////////////
function lang_save_file($path, $file, $strings) {
// Thanks to Petri Asikainen for the original version of code
// used to save language files.
//
// $path is a full pathname to the file
// $file is the file to overwrite.
// $strings is an array of strings to write
global $CFG, $USER;
error_reporting(0);
if (!$f = fopen("$path/$file","w")) {
return false;
}
error_reporting(7);
fwrite($f, "<?PHP // \$Id\$ \n");
fwrite($f, " // $file - created with Moodle $CFG->release ($CFG->version)\n\n\n");
ksort($strings);
foreach ($strings as $key => $value) {
list($id, $stringname) = explode("-",$key);
if ($CFG->lang != "zh_hk" and $CFG->lang != "zh_tw") { // Some MB languages include backslash bytes
$value = str_replace("\\","",$value); // Delete all slashes
}
$value = str_replace("'", "\\'", $value); // Add slashes for '
$value = str_replace('"', "\\\"", $value); // Add slashes for "
$value = str_replace("%","%%",$value); // Escape % characters
$value = str_replace("\r", "",$value); // Remove linefeed characters
if ($id == "string" and $value != ""){
fwrite($f,"\$string['$stringname'] = '$value';\n");
}
}
fwrite($f,"\n?>\n");
fclose($f);
return true;
}
?>
-50
View File
@@ -1,50 +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/>.
/**
* This file contains functions used by the admin pages
*
* @since 2.1
* @package admin
* @copyright 2011 Andrew Davis
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Return a list of page types
* @param string $pagetype current page type
* @param stdClass $parentcontext Block's parent context
* @param stdClass $currentcontext Current context of block
*/
function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
$array = array(
'admin-*' => get_string('page-admin-x', 'pagetype'),
$pagetype => get_string('page-admin-current', 'pagetype')
);
// Add the missing * (any page) option for them. MDL-30340
// TODO: These pages are really 'pagetype-varying' - MDL-30564 -
// and some day we should stop behaving that way, so proper pagetypes
// can be specified for it (like course-category-* or so).
// Luckly... the option we are introducing '*' is independent
// of that varying behavior, so will work.
if ($pagetype == 'admin-course-category') {
$array += array(
'*' => get_string('page-x', 'pagetype')
);
}
return $array;
}
-57
View File
@@ -1,57 +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/>.
/**
* Allows admin to configure licenses.
*/
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/licenselib.php');
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";
$action = optional_param('action', '', PARAM_ACTION);
$license = optional_param('license', '', PARAM_SAFEDIR);
////////////////////////////////////////////////////////////////////////////////
// process actions
if (!confirm_sesskey()) {
redirect($returnurl);
}
$return = true;
switch ($action) {
case 'disable':
license_manager::disable($license);
break;
case 'enable':
license_manager::enable($license);
break;
default:
break;
}
if ($return) {
redirect ($returnurl);
}
-110
View File
@@ -1,110 +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/>.
/**
* Provides an overview of installed local plugins
*
* Displays the list of found local plugins, their version (if found) and
* a link to delete the local plugin.
*
* @see http://docs.moodle.org/dev/Local_customisation
* @package admin
* @copyright 2010 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
admin_externalpage_setup('managelocalplugins');
$delete = optional_param('delete', '', PARAM_PLUGIN);
$confirm = optional_param('confirm', '', PARAM_BOOL);
/// If data submitted, then process and store.
if (!empty($delete) and confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('localplugins'));
if (!$confirm) {
if (get_string_manager()->string_exists('pluginname', 'local_' . $delete)) {
$strpluginname = get_string('pluginname', 'local_' . $delete);
} else {
$strpluginname = $delete;
}
echo $OUTPUT->confirm(get_string('localplugindeleteconfirm', '', $strpluginname),
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
$PAGE->url);
echo $OUTPUT->footer();
die();
} else {
uninstall_plugin('local', $delete);
$a = new stdclass();
$a->name = $delete;
$pluginlocation = get_plugin_types();
$a->directory = $pluginlocation['local'] . '/' . $delete;
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
echo $OUTPUT->continue_button($PAGE->url);
echo $OUTPUT->footer();
die();
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('localplugins'));
/// Print the table of all installed local plugins
$table = new flexible_table('localplugins_administration_table');
$table->define_columns(array('name', 'version', 'delete'));
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
$table->define_baseurl($PAGE->url);
$table->set_attribute('id', 'localplugins');
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
$table->setup();
$plugins = array();
foreach (get_plugin_list('local') as $plugin => $plugindir) {
if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
$strpluginname = get_string('pluginname', 'local_' . $plugin);
} else {
$strpluginname = $plugin;
}
$plugins[$plugin] = $strpluginname;
}
collatorlib::asort($plugins);
foreach ($plugins as $plugin => $name) {
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
$delete = html_writer::link($delete, get_string('delete'));
$version = get_config('local_' . $plugin);
if (!empty($version->version)) {
$version = $version->version;
} else {
$version = '?';
}
$table->add_data(array($name, $version, $delete));
}
$table->print_html();
echo $OUTPUT->footer();
-77
View File
@@ -1,77 +0,0 @@
#!/usr/bin/php
<?php
/*
* Utility to debug mailouts - will save the content of emails to a
* logfile instead of sending them out. Use it as a sendmail
* "stand-in" when testing mailouts.
*
* It is not Moodle specific - use it anywhere by setting the php
* "sendmail_path" setting to this file with a logfile parameter.
*
* - Set in php.ini (not settable in config.php):
* sendmail_path=/path-to-moodle/admin/mailout-debugger.php');
* Or from the commandline
* php -d sendmail_path='/path-to-moodle/admin/mailout-debugger.php' /path/to/cron.php
*
* - Create a file in admin called mailout-debugger.enable
* (this is a security check to prevent execution in prod environments)
* touch /path/to/moodle/admin/mailout-debugger.enable
*
* - Mark as executable: chmod ugo+rx mailout-debugger.php
*
* - Run your admin/cron.php
*
* - Read /tmp/moodle-mailout.log
*
*
* This script will create logfiles in /tmp/ or in $TMPDIR if set.
* On windows, use php -r 'print sys_get_temp_dir()' to see where the file is saved.
*/
// Security check.
if (!file_exists(dirname(__FILE__).'/mailout-debugger.enable')) {
mdie("Disabled.");
}
$tmpdir=sys_get_temp_dir(); // default
if (isset($_SERVER['REMOTE_ADDR'])) {
mdie("should not be called from web server!");
}
if (isset($_ENV['TMPDIR']) && is_dir($_ENV['TMPDIR'])) {
$tmpdir = $_ENV['TMPDIR'];
}
$tmpfile = $tmpdir . '/moodle-mailout.log';
$fh = fopen($tmpfile, 'a+', false)
or mdie("Error openning $tmpfile on append\n");
fwrite($fh, "==== ".strftime("%a %b %e %H:%M:%S %Y", time())." ====\n");
fwrite($fh, "==== Commandline: " . implode(' ',$argv) . "\n");
$stdin = fopen('php://stdin', 'r');
while ($line = fgets($stdin)) {
fwrite($fh, $line);
}
fwrite($fh, "\n");
fclose($fh);
fclose($stdin);
/**
* Print an error to STDOUT and exit with a non-zero code. For commandline scripts.
* Default errorcode is 1.
*
* Very useful for perl-like error-handling:
*
* do_something() or mdie("Something went wrong");
*
* @param string $msg Error message
* @param integer $errorcode Error code to emit
*
*/
function mdie($msg='', $errorcode=1) {
trigger_error($msg);
exit($errorcode);
}
-70
View File
@@ -1,70 +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/>.
/**
* Message outputs configuration page
*
* @package message
* @copyright 2011 Lancaster University Network Services Limited
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot . '/message/lib.php');
require_once($CFG->libdir.'/adminlib.php');
// This is an admin page
admin_externalpage_setup('managemessageoutputs');
// Require site configuration capability
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
// Get the submitted params
$disable = optional_param('disable', 0, PARAM_INT);
$enable = optional_param('enable', 0, PARAM_INT);
if (!empty($disable) && confirm_sesskey()) {
if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
print_error('outputdoesnotexist', 'message');
}
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
}
if (!empty($enable) && confirm_sesskey() ) {
if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
print_error('outputdoesnotexist', 'message');
}
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
}
if ($disable || $enable) {
$url = new moodle_url('message.php');
redirect($url);
}
// Page settings
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
// Grab the renderer
$renderer = $PAGE->get_renderer('core', 'message');
// Display the manage message outputs interface
$processors = get_message_processors();
$messageoutputs = $renderer->manage_messageoutputs($processors);
// Display the page
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('managemessageoutputs', 'message'));
echo $messageoutputs;
echo $OUTPUT->footer();
-234
View File
@@ -1,234 +0,0 @@
<?php
// Allows the admin to control user logins from remote moodles.
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once($CFG->libdir.'/adminlib.php');
include_once($CFG->dirroot.'/mnet/lib.php');
$sort = optional_param('sort', 'username', PARAM_ALPHA);
$dir = optional_param('dir', 'ASC', PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 30, PARAM_INT);
$action = trim(strtolower(optional_param('action', '', PARAM_ALPHA)));
require_login();
admin_externalpage_setup('ssoaccesscontrol');
echo $OUTPUT->header();
if (!extension_loaded('openssl')) {
print_error('requiresopenssl', 'mnet');
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$sesskey = sesskey();
$formerror = array();
// grab the mnet hosts and remove the localhost
$mnethosts = $DB->get_records_menu('mnet_host', array(), 'name', 'id, name');
if (array_key_exists($CFG->mnet_localhost_id, $mnethosts)) {
unset($mnethosts[$CFG->mnet_localhost_id]);
}
// process actions
if (!empty($action) and confirm_sesskey()) {
// boot if insufficient permission
if (!has_capability('moodle/user:delete', $sitecontext)) {
print_error('nomodifyacl','mnet');
}
// fetch the record in question
$id = required_param('id', PARAM_INT);
if (!$idrec = $DB->get_record('mnet_sso_access_control', array('id'=>$id))) {
print_error('recordnoexists','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
}
switch ($action) {
case "delete":
$DB->delete_records('mnet_sso_access_control', array('id'=>$id));
redirect('access_control.php', get_string('deleteuserrecord', 'mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
break;
case "acl":
// require the access parameter, and it must be 'allow' or 'deny'
$accessctrl = trim(strtolower(required_param('accessctrl', PARAM_ALPHA)));
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
print_error('invalidaccessparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
}
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
if ($accessctrl == 'allow') {
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('uset'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
} elseif ($accessctrl == 'deny') {
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
}
}
break;
default:
print_error('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
}
}
// process the form results
if ($form = data_submitted() and confirm_sesskey()) {
// check permissions and verify form input
if (!has_capability('moodle/user:delete', $sitecontext)) {
print_error('nomodifyacl','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
}
if (empty($form->username)) {
$formerror['username'] = get_string('enterausername','mnet');
}
if (empty($form->mnet_host_id)) {
$formerror['mnet_host_id'] = get_string('selectahost','mnet');
}
if (empty($form->accessctrl)) {
$formerror['accessctrl'] = get_string('selectaccesslevel','mnet'); ;
}
// process if there are no errors
if (count($formerror) == 0) {
// username can be a comma separated list
$usernames = explode(',', $form->username);
foreach ($usernames as $username) {
$username = trim(moodle_strtolower($username));
if (!empty($username)) {
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
if ($form->accessctrl == 'allow') {
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user'=>$username, 'host'=>$mnethosts[$form->mnet_host_id])));
} elseif ($form->accessctrl == 'deny') {
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$username, 'host'=>$mnethosts[$form->mnet_host_id])));
}
}
}
}
}
exit;
}
// Explain
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
// Are the needed bits enabled?
$warn = '';
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
$warn = '<p>' . get_string('mnetdisabled','mnet') .'</p>';
}
if (!is_enabled_auth('mnet')) {
$warn .= '<p>' . get_string('authmnetdisabled','mnet').'</p>';
}
if (!empty($warn)) {
$warn = '<p>' . get_string('ssoaclneeds','mnet').'</p>' . $warn;
echo $OUTPUT->box($warn);
}
// output the ACL table
$columns = array("username", "mnet_host_id", "access", "delete");
$headings = array();
$string = array('username' => get_string('username'),
'mnet_host_id' => get_string('remotehost', 'mnet'),
'access' => get_string('accesslevel', 'mnet'),
'delete' => get_string('delete'));
foreach ($columns as $column) {
if ($sort != $column) {
$columnicon = "";
$columndir = "ASC";
} else {
$columndir = $dir == "ASC" ? "DESC" : "ASC";
$columnicon = $dir == "ASC" ? "down" : "up";
$columnicon = " <img src=\"" . $OUTPUT->pix_url('t/' . $columnicon) . "\" alt=\"\" />";
}
$headings[$column] = "<a href=\"?sort=$column&amp;dir=$columndir&amp;\">".$string[$column]."</a>$columnicon";
}
$headings['delete'] = '';
$acl = $DB->get_records('mnet_sso_access_control', null, "$sort $dir", '*'); //, $page * $perpage, $perpage);
$aclcount = $DB->count_records('mnet_sso_access_control');
if (!$acl) {
echo $OUTPUT->heading(get_string('noaclentries','mnet'));
$table = NULL;
} else {
$table = new html_table();
$table->head = $headings;
$table->align = array('left', 'left', 'center');
$table->width = "95%";
foreach ($acl as $aclrecord) {
if ($aclrecord->accessctrl == 'allow') {
$accesscolumn = get_string('allow', 'mnet')
. " (<a href=\"?id={$aclrecord->id}&amp;action=acl&amp;accessctrl=deny&amp;sesskey=".sesskey()."\">"
. get_string('deny', 'mnet') . "</a>)";
} else {
$accesscolumn = get_string('deny', 'mnet')
. " (<a href=\"?id={$aclrecord->id}&amp;action=acl&amp;accessctrl=allow&amp;sesskey=".sesskey()."\">"
. get_string('allow', 'mnet') . "</a>)";
}
$deletecolumn = "<a href=\"?id={$aclrecord->id}&amp;action=delete&amp;sesskey=".sesskey()."\">"
. get_string('delete') . "</a>";
$table->data[] = array (s($aclrecord->username), $aclrecord->mnet_host_id, $accesscolumn, $deletecolumn);
}
}
if (!empty($table)) {
echo html_writer::table($table);
echo '<p>&nbsp;</p>';
$baseurl = new moodle_url('/admin/mnet/access_control.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
echo $OUTPUT->paging_bar($aclcount, $page, $perpage, $baseurl);
}
// output the add form
echo $OUTPUT->box_start();
?>
<div class="mnetaddtoaclform">
<form id="mnetaddtoacl" method="post">
<input type="hidden" name="sesskey" value="<?php echo $sesskey; ?>" />
<?php
// enter a username
echo get_string('username') . ":\n";
if (!empty($formerror['username'])) {
echo '<span class="error"> * </span>';
}
echo '<input type="text" name="username" size="20" maxlength="100" />';
// choose a remote host
echo " " . get_string('remotehost', 'mnet') . ":\n";
if (!empty($formerror['mnet_host_id'])) {
echo '<span class="error"> * </span>';
}
echo html_writer::select($mnethosts, 'mnet_host_id');
// choose an access level
echo " " . get_string('accesslevel', 'mnet') . ":\n";
if (!empty($formerror['accessctrl'])) {
echo '<span class="error"> * </span>';
}
$accessmenu['allow'] = get_string('allow', 'mnet');
$accessmenu['deny'] = get_string('deny', 'mnet');
echo html_writer::select($accessmenu, 'accessctrl');
// submit button
echo '<input type="submit" value="' . get_string('addtoacl', 'mnet') . '" />';
echo "</form></div>\n";
// print errors
foreach ($formerror as $error) {
echo "<br><span class=\"error\">$error<span>";
}
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
-65
View File
@@ -1,65 +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/>.
/**
* Page to allow the administrator to delete networked hosts, with a confirm message
*
* @package core
* @subpackage mnet
* @copyright 2007 Donal McMullan
* @copyright 2007 Martin Langhoff
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once($CFG->libdir . '/adminlib.php');
$step = optional_param('step', 'verify', PARAM_ALPHA);
$hostid = required_param('hostid', PARAM_INT);
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
$mnet = get_mnet_environment();
$PAGE->set_url('/admin/mnet/delete.php');
admin_externalpage_setup('mnetpeer' . $hostid);
require_sesskey();
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);
if ('verify' == $step) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
if ($live_users = $mnet_peer->count_live_sessions() > 0) {
echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
}
$yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
$nourl = new moodle_url('/admin/mnet/peers.php');
echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet') . ': ' . $mnet_peer->name, $yesurl, $nourl);
echo $OUTPUT->footer();
} elseif ('delete' == $step) {
$mnet_peer->delete();
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
}
-133
View File
@@ -1,133 +0,0 @@
<?PHP
// Allows the admin to configure mnet stuff
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
include_once($CFG->dirroot.'/mnet/lib.php');
require_login();
admin_externalpage_setup('net');
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
$site = get_site();
$mnet = get_mnet_environment();
if (!extension_loaded('openssl')) {
echo $OUTPUT->header();
set_config('mnet_dispatcher_mode', 'off');
print_error('requiresopenssl', 'mnet');
}
if (!function_exists('curl_init') ) {
echo $OUTPUT->header();
set_config('mnet_dispatcher_mode', 'off');
print_error('nocurl', 'mnet');
}
if (!isset($CFG->mnet_dispatcher_mode)) {
set_config('mnet_dispatcher_mode', 'off');
}
/// If data submitted, process and store
if (($form = data_submitted()) && confirm_sesskey()) {
if (!empty($form->submit) && $form->submit == get_string('savechanges')) {
if (in_array($form->mode, array("off", "strict", "dangerous"))) {
if (set_config('mnet_dispatcher_mode', $form->mode)) {
redirect('index.php', get_string('changessaved'));
} else {
print_error('invalidaction', '', 'index.php');
}
}
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
$mnet->get_private_key();
$SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])).':'.time();
$formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes'));
$formcancel = new single_button(new moodle_url('index.php', array()), get_string('no'));
echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel);
exit;
} else {
// We're deleting
if (!isset($SESSION->mnet_confirm_delete_key)) {
// fail - you're being attacked?
}
$key = '';
$time = '';
@list($key, $time) = explode(':',$SESSION->mnet_confirm_delete_key);
$mnet->get_private_key();
if($time < time() - 60) {
// fail - you're out of time.
print_error ('deleteoutoftime', 'mnet', 'index.php');
exit;
}
if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) {
// fail - you're being attacked?
print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
exit;
}
$mnet->replace_keys();
redirect('index.php', get_string('keydeleted','mnet'));
exit;
}
}
$hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC');
echo $OUTPUT->header();
?>
<form method="post" action="index.php">
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
<tr>
<td class="generalboxcontent">
<table cellpadding="9" cellspacing="0" >
<tr valign="top">
<td colspan="2" class="header"><?php print_string('aboutyourhost', 'mnet'); ?></td>
</tr>
<tr valign="top">
<td align="right"><?php print_string('publickey', 'mnet'); ?>:</td>
<td><pre><?php echo $mnet->public_key; ?></pre></td>
</tr>
<tr valign="top">
<td align="right"><?php print_string('expires', 'mnet'); ?>:</td>
<td><?php echo userdate($mnet->public_key_expires); ?></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<form method="post" action="index.php">
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
<tr>
<td class="generalboxcontent">
<table cellpadding="9" cellspacing="0" >
<tr valign="top">
<td colspan="2" class="header"><?php print_string('expireyourkey', 'mnet'); ?></td>
</tr>
<tr valign="top">
<td colspan="2"><?php print_string('expireyourkeyexplain', 'mnet'); ?></td>
</tr>
<tr valign="top">
<td align="left" width="10" nowrap="nowrap"><?php print_string('expireyourkey', 'mnet'); ?></td>
<td align="left"><input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<input type="hidden" name="deleteKey" value="" />
<input type="submit" name="submit" value="<?php print_string('delete'); ?>" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
echo $OUTPUT->footer();
-176
View File
@@ -1,176 +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/>.
/**
* This file contains two forms for adding/editing mnet hosts, used by peers.php
*
* @package core
* @subpackage mnet
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
/**
* The very basic first step add new host form - just wwwroot & application
* The second form is loaded up with the information from this one.
*/
class mnet_simple_host_form extends moodleform {
function definition() {
global $DB;
$mform = $this->_form;
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
$mform->setType('wwwroot', PARAM_URL);
$mform->addRule('wwwroot', null, 'required', null, 'client');
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'),
$DB->get_records_menu('mnet_application', array(), 'id,display_name'));
$mform->addRule('applicationid', null, 'required', null, 'client');
$this->add_action_buttons(false, get_string('addhost', 'mnet'));
}
function validation($data) {
global $DB;
$wwwroot = $data['wwwroot'];
// ensure the wwwroot starts with a http or https prefix
if (strtolower(substr($wwwroot, 0, 4)) != 'http') {
$wwwroot = 'http://'.$wwwroot;
}
if ($host = $DB->get_record('mnet_host', array('wwwroot' => $wwwroot))) {
global $CFG;
return array('wwwroot' => get_string('hostexists', 'mnet', $CFG->wwwroot . '/admin/mnet/peers.php?hostid=' . $host->id));
}
return array();
}
}
/**
* The second step of the form - reviewing the host details
* This is also the same form that is used for editing an existing host
*/
class mnet_review_host_form extends moodleform {
function definition() {
global $OUTPUT;
$mform = $this->_form;
$mnet_peer = $this->_customdata['peer'];
$mform->addElement('hidden', 'last_connect_time');
$mform->addElement('hidden', 'id');
$mform->addElement('hidden', 'applicationid');
$mform->addElement('hidden', 'oldpublickey');
$mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
$mform->setType('name', PARAM_NOTAGS);
$mform->addRule('name', get_string('maximumchars', '', 80), 'maxlength', 80, 'client');
$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
$mform->setType('wwwroot', PARAM_URL);
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$themes = array('' => get_string('forceno'));
foreach (array_keys(get_plugin_list('theme')) as $themename) {
$themes[$themename] = get_string('pluginname', 'theme_'.$themename);
}
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
$mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
$mform->setType('public_key', PARAM_PEM);
$mform->addRule('public_key', get_string('required'), 'required');
// finished with form controls, now the static informational stuff
if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
$expires = '';
if ($mnet_peer->public_key_expires < time()) {
$expires = get_string('expired', 'mnet') . ' ';
}
$expires .= userdate($mnet_peer->public_key_expires);
$mform->addElement('static', 'validuntil', get_string('expires', 'mnet'), $expires);
$lastconnect = '';
if ($mnet_peer->last_connect_time == 0) {
$lastconnect = get_string('never', 'mnet');
} else {
$lastconnect = date('H:i:s d/m/Y',$mnet_peer->last_connect_time);
}
$mform->addElement('static', 'lastconnect', get_string('last_connect_time', 'mnet'), $lastconnect);
$mform->addElement('static', 'ipaddress', get_string('ipaddress', 'mnet'), $mnet_peer->ip_address);
if (isset($mnet_peer->currentkey)) { // key being published is not the same as our records
$currentkeystr = '<b>' . get_string('keymismatch', 'mnet') . '</b><br /><br /> ' . $OUTPUT->box('<pre>' . $mnet_peer->currentkey . '</pre>');
$mform->addElement('static', 'keymismatch', get_string('currentkey', 'mnet'), $currentkeystr);
}
$credstr = '';
if ($credentials = $mnet_peer->check_credentials($mnet_peer->public_key)) {
foreach($credentials['subject'] as $key => $credential) {
if (is_scalar($credential)) {
$credstr .= str_pad($key, 16, " ", STR_PAD_LEFT).': '.$credential."\n";
} else {
$credstr .= str_pad($key, 16, " ", STR_PAD_LEFT).': '.var_export($credential,1)."\n";
}
}
}
$mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'),
$OUTPUT->box('<pre>' . $credstr . '</pre>', 'generalbox certdetails'));
}
if ($mnet_peer && !empty($mnet_peer->deleted)) {
$radioarray = array();
$radioarray[] = MoodleQuickForm::createElement('static', 'deletedinfo', '',
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
} else {
$mform->addElement('hidden', 'deleted');
}
// finished with static stuff, print save button
$this->add_action_buttons(false);
}
function validation($data) {
$errors = array();
if ($data['oldpublickey'] == $data['public_key']) {
return;
}
$mnet_peer = new mnet_peer(); // idiotic api
$mnet_peer->wwwroot = $data['wwwroot']; // just hard-set this rather than bootstrap the object
if (empty($data['public_key'])) {
$errors['public_key'] = get_string('publickeyrequired', 'mnet');
} else if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
$errmsg = '';
foreach ($mnet_peer->error as $err) {
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
}
$errors['public_key'] = get_string('invalidpubkey', 'mnet', $errmsg);
}
unset($mnet_peer);
return $errors;
}
}
-280
View File
@@ -1,280 +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/>.
/**
* Page to allow the administrator to configure networked hosts, and add new ones
*
* @package core
* @subpackage mnet
* @copyright 2007 Donal McMullan
* @copyright 2007 Martin Langhoff
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/mnet/lib.php');
require_once($CFG->dirroot.'/admin/mnet/peer_forms.php');
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
/// Initialize variables.
$hostid = optional_param('hostid', 0, PARAM_INT);
$updra = optional_param('updateregisterall', 0, PARAM_INT);
// first process the register all hosts setting if required
if (!empty($updra)) {
set_config('mnet_register_allhosts', optional_param('registerallhosts', 0, PARAM_INT));
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
}
$adminsection = 'mnetpeers';
if ($hostid && $DB->get_field('mnet_host', 'deleted', array('id' => $hostid)) != 1) {
$adminsection = 'mnetpeer' . $hostid;
}
$PAGE->set_url('/admin/mnet/peers.php');
admin_externalpage_setup($adminsection);
if (!extension_loaded('openssl')) {
print_error('requiresopenssl', 'mnet');
}
if (!function_exists('curl_init') ) {
print_error('nocurl', 'mnet');
}
if (!function_exists('xmlrpc_encode_request')) {
print_error('xmlrpc-missing', 'mnet');
}
if (!isset($CFG->mnet_dispatcher_mode)) {
set_config('mnet_dispatcher_mode', 'off');
}
$mnet_peer = new mnet_peer();
$simpleform = new mnet_simple_host_form(); // the one that goes on the bottom of the main page
$reviewform = null; // set up later in different code branches, so mnet_peer can be passed to the constructor
// if the first form has been submitted, bootstrap the peer and load up the review form
if ($formdata = $simpleform->get_data()) {
// ensure we remove trailing slashes
$formdata->wwwroot = trim($formdata->wwwroot);
$formdata->wwwroot = rtrim($formdata->wwwroot, '/');
// ensure the wwwroot starts with a http or https prefix
if (strtolower(substr($formdata->wwwroot, 0, 4)) != 'http') {
$formdata->wwwroot = 'http://'.$formdata->wwwroot;
}
$mnet_peer->set_applicationid($formdata->applicationid);
$application = $DB->get_field('mnet_application', 'name', array('id'=>$formdata->applicationid));
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
// bootstrap the second form straight with the data from the first form
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
$formdata->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
$reviewform->set_data($mnet_peer);
echo $OUTPUT->header();
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
exit;
} else if ($simpleform->is_submitted()) { // validation failed
$noreviewform = true;
}
// editing a host - load up the review form
if (!empty($hostid)) {
// TODO print a nice little heading
$mnet_peer->set_id($hostid);
echo $OUTPUT->header();
$currenttab = 'mnetdetails';
require_once($CFG->dirroot . '/admin/mnet/tabs.php');
if ($hostid != $CFG->mnet_all_hosts_id) {
$mnet_peer->currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
if ($mnet_peer->currentkey == $mnet_peer->public_key) {
unset($mnet_peer->currentkey);
} else {
error_log($mnet_peer->currentkey);
error_log($mnet_peer->public_key);
error_log(md5($mnet_peer->currentkey));
error_log(md5($mnet_peer->public_key));
}
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form)
$mnet_peer->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
$reviewform->set_data((object)$mnet_peer);
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
} else {
// no options for allhosts host - just let the tabs display and print a notification
echo $OUTPUT->notification(get_string('allhosts_no_options', 'mnet'));
}
echo $OUTPUT->footer();
exit;
}
// either we're in the second step of setting up a new host
// or editing an existing host
// try our best to set up the mnet_peer object to pass to the form definition
// unless validation on simpleform failed, in which case fall through.
if (empty($noreviewform) && $id = optional_param('id', 0, PARAM_INT)) {
// we're editing an existing one, so set up the tabs
$currenttab = 'mnetdetails';
$mnet_peer->set_id($id);
require_once($CFG->dirroot . '/admin/mnet/tabs.php');
} else if (empty($noreviewform) && ($wwwroot = optional_param('wwwroot', '', PARAM_URL)) && ($applicationid = optional_param('applicationid', 0, PARAM_INT))) {
$application = $DB->get_field('mnet_application', 'name', array('id'=>$applicationid));
$mnet_peer->bootstrap($wwwroot, null, $application);
}
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer));
if ($formdata = $reviewform->get_data()) {
$mnet_peer->set_applicationid($formdata->applicationid);
$application = $DB->get_field('mnet_application', 'name', array('id'=>$formdata->applicationid));
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
if (!empty($formdata->name) && $formdata->name != $mnet_peer->name) {
$mnet_peer->set_name($formdata->name);
}
if (empty($formdata->theme)) {
$mnet_peer->force_theme = 0;
$mnet_peer->theme = null;
} else {
$mnet_peer->force_theme = 1;
$mnet_peer->theme = $formdata->theme;
}
$mnet_peer->deleted = $formdata->deleted;
$mnet_peer->public_key = $formdata->public_key;
$credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
$mnet_peer->public_key_expires = $credentials['validTo_time_t'];
if ($mnet_peer->commit()) {
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $mnet_peer->id)), get_string('changessaved'));
} else {
print_error('invalidaction', 'error', 'index.php');
}
} else if ($reviewform->is_submitted()) { // submitted, but errors
echo $OUTPUT->header();
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
exit;
}
// normal flow - just display all hosts with links
echo $OUTPUT->header();
$hosts = mnet_get_hosts(true);
// print the table to display the register all hosts setting
$table = new html_table();
$table->head = array(get_string('registerallhosts', 'mnet'));
$registerrow = '';
$registerstr = '';
$registerurl = new moodle_url('/admin/mnet/peers.php', array('updateregisterall' => 1));
if (!empty($CFG->mnet_register_allhosts)) {
$registerrow = get_string('registerhostson', 'mnet');
$registerurl->param('registerallhosts', 0);
$registerstr = get_string('turnitoff', 'mnet');
} else {
$registerrow = get_string('registerhostsoff', 'mnet');
$registerurl->param('registerallhosts', 1);
$registerstr = get_string('turniton', 'mnet');
}
$registerrow .= $OUTPUT->single_button($registerurl, $registerstr);
// simple table with two rows of a single cell
$table->data = array(
array(
get_string('registerallhostsexplain', 'mnet'),
),
array(
$registerrow
),
);
echo html_writer::table($table);
// print the list of all hosts, with little action links and buttons
$table = new html_table();
$table->head = array(
get_string('site'),
get_string('system', 'mnet'),
get_string('last_connect_time', 'mnet'),
'',
);
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
$baseurl = new moodle_url('/admin/mnet/peers.php');
$deleted = array();
foreach($hosts as $host) {
$hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
if (trim($host->name) === '') {
// should not happen but...
$host->name = '???';
}
// process all hosts first since it's the easiest
if ($host->id == $CFG->mnet_all_hosts_id) {
$table->data[] = array(html_writer::link($hosturl, get_string('allhosts', 'core_mnet')), '*', '', '');
continue;
}
// populate the list of deleted hosts
if ($host->deleted) {
$deleted[] = html_writer::link($hosturl, $host->name);
continue;
}
if ($host->last_connect_time == 0) {
$last_connect = get_string('never');
} else {
$last_connect = userdate($host->last_connect_time, get_string('strftimedatetime', 'core_langconfig'));
}
$table->data[] = array(
html_writer::link($hosturl, $host->name),
html_writer::link($host->wwwroot, $host->wwwroot),
$last_connect,
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
);
}
echo html_writer::table($table);
if ($deleted) {
echo $OUTPUT->box(get_string('deletedhosts', 'core_mnet', join(', ', $deleted)), 'deletedhosts');
}
// finally, print the initial form to add a new host
echo $OUTPUT->box_start();
echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
$simpleform->display();
echo $OUTPUT->box_end();
// done
echo $OUTPUT->footer();
exit;
-93
View File
@@ -1,93 +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/>.
/**
* Allows the admin to configure a list of profile fields that are sent/recieved
*
* @package core
* @subpackage mnet
* @copyright 2010 onwards Penny Leach <penny@liip.ch>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot . '/admin/mnet/profilefields_form.php');
$mnet = get_mnet_environment();
require_login();
$hostid = required_param('hostid', PARAM_INT);
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions');
admin_externalpage_setup('mnetpeers');
$form = new mnet_profile_form(null, array('hostid' => $hostid));
if ($data = $form->get_data()) {
if (!isset($data->importdefault)) {
$data->importdefault = 0;
}
if (!isset($data->exportdefault)) {
$data->exportdefault = 0;
}
if (!isset($data->importfields)) {
$data->importfields = array();
}
if (!isset($data->exportfields)) {
$data->exportfields = array();
}
set_config('host' . $hostid . 'importdefault', $data->importdefault, 'mnet');
set_config('host' . $hostid . 'importfields', implode(',', $data->importfields), 'mnet');
set_config('host' . $hostid . 'exportdefault', $data->exportdefault, 'mnet');
set_config('host' . $hostid . 'exportfields', implode(',', $data->exportfields), 'mnet');
redirect(new moodle_url('/admin/mnet/peers.php'), get_string('changessaved'));
} elseif ($form->is_cancelled()) {
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $hostid)));
}
echo $OUTPUT->header();
$currenttab = 'mnetprofilefields';
require_once('tabs.php');
echo $OUTPUT->heading(get_string('peerprofilefielddesc', 'mnet'), 4);
$data = new Stdclass;
$data->importdefault = get_config('mnet', 'host' . $hostid . 'importdefault');
$data->exportdefault = get_config('mnet', 'host' . $hostid . 'exportdefault');
$data->importfields = get_config('mnet', 'host' . $hostid . 'importfields');
$data->exportfields = get_config('mnet', 'host' . $hostid . 'exportfields');
if ($data->importfields === false) {
$data->importdefault = true;
} else {
$data->importfields = explode(',', $data->importfields);
}
if ($data->exportfields === false) {
$data->exportdefault = true;
} else {
$data->exportfields = explode(',', $data->exportfields);
}
$form->set_data($data);
$form->display();
echo $OUTPUT->footer();
-64
View File
@@ -1,64 +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/>.
/**
* Allows the admin to configure a list of profile fields that are sent/recieved
*
* @package core
* @subpackage mnet
* @copyright 2010 onwards Penny Leach <penny@liip.ch>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once($CFG->libdir . '/formslib.php');
/**
* small form to allow the administrator to configure (override) which profile fields are sent/imported over mnet
*/
class mnet_profile_form extends moodleform {
function definition() {
global $CFG;
$mform =& $this->_form;
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
$fields = mnet_profile_field_options();
// Fields to import ----------------------------------------------------
$mform->addElement('header', 'import', get_string('importfields', 'mnet'));
$select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']);
$select->setMultiple(true);
$mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileimportfields));
// Fields to export ----------------------------------------------------
$mform->addElement('header', 'export', get_string('exportfields', 'mnet'));
$select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']);
$select->setMultiple(true);
$mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), str_replace(',', ', ', $CFG->mnetprofileexportfields));
$this->add_action_buttons();
}
}
-92
View File
@@ -1,92 +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/>.
/**
* This page is for configuring which services are published/subscribed on a host
*
* @package core
* @subpackage mnet
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot . '/admin/mnet/services_form.php');
$mnet = get_mnet_environment();
require_login();
admin_externalpage_setup('mnetpeers');
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
$hostid = required_param('hostid', PARAM_INT);
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);
$mform = new mnet_services_form(null, array('peer' => $mnet_peer));
if ($formdata = $mform->get_data()) {
if (!isset($formdata->publish)) {
$formdata->publish = array();
}
if (!isset($formdata->subscribe)) {
$formdata->subscribe = array();
}
foreach($formdata->exists as $key => $value) {
$host2service = $DB->get_record('mnet_host2service', array('hostid'=>$hostid, 'serviceid'=>$key));
$publish = (array_key_exists($key, $formdata->publish)) ? $formdata->publish[$key] : 0;
$subscribe = (array_key_exists($key, $formdata->subscribe)) ? $formdata->subscribe[$key] : 0;
if ($publish != 1 && $subscribe != 1) {
if (false == $host2service) {
// We don't have or need a record - do nothing!
} else {
// We don't need the record - delete it
$DB->delete_records('mnet_host2service', array('hostid' => $hostid, 'serviceid'=>$key));
}
} elseif (false == $host2service && ($publish == 1 || $subscribe == 1)) {
$host2service = new stdClass();
$host2service->hostid = $hostid;
$host2service->serviceid = $key;
$host2service->publish = $publish;
$host2service->subscribe = $subscribe;
$host2service->id = $DB->insert_record('mnet_host2service', $host2service);
} elseif ($host2service->publish != $publish || $host2service->subscribe != $subscribe) {
$host2service->publish = $publish;
$host2service->subscribe = $subscribe;
$DB->update_record('mnet_host2service', $host2service);
}
}
$redirecturl = new moodle_url('/admin/mnet/services.php?hostid=' . $hostid);
redirect($redirecturl, get_string('changessaved'));
}
echo $OUTPUT->header();
$currenttab = 'mnetservices';
require_once($CFG->dirroot . '/admin/mnet/tabs.php');
echo $OUTPUT->box_start();
$s = mnet_get_service_info($mnet_peer, false); // basic data only
$mform->set_data($s);
$mform->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
-74
View File
@@ -1,74 +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/>.
/**
* The form for configuring which services are subscribed and published on a host
*
* @package core
* @subpackage mnet
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once($CFG->libdir . '/formslib.php');
class mnet_services_form extends moodleform {
function definition() {
$mform =& $this->_form;
$mnet_peer =& $this->_customdata['peer'];
$myservices =& mnet_get_service_info($mnet_peer);
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
$count = 0;
foreach ($myservices as $name => $versions) {
$version = current($versions);
$langmodule =
($version['plugintype'] == 'mod'
? ''
: ($version['plugintype'] . '_'))
. $version['pluginname']; // TODO there should be a moodle-wide way to do this
if ($count > 0) {
$mform->addElement('html', '<hr />');
}
$mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
$mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
$pubstr = get_string('publish','mnet');
if (!empty($version['hostsubscribes'])) {
$pubstr .= ' <a class="notifysuccess" title="'.s(get_string('issubscribed','mnet', $mnet_peer->name)).'">&radic;</a> ';
}
$mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
$substr = get_string('subscribe','mnet');
if (!empty($version['hostpublishes'])) {
$substr .= ' <a class="notifysuccess" title="'.s(get_string('ispublished','mnet', $mnet_peer->name)).'">&radic;</a> ';
}
$mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid']. ']', $substr);
$count++;
}
$this->add_action_buttons();
}
}
-56
View File
@@ -1,56 +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/>.
/**
* Tabs to be included on the pages for configuring a single host
* $mnet_peer object must be set and bootstrapped
* $currenttab string must be set
*
* @package core
* @subpackage mnet
* @copyright 2007 Donal McMullan
* @copyright 2007 Martin Langhoff
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
}
$strmnetservices = get_string('mnetservices', 'mnet');
$strmnetlog = get_string('mnetlog', 'mnet');
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
$logurl = $CFG->wwwroot.
'/report/log/index.php?chooselog=1&amp;showusers=1&amp;showcourses=1&amp;host_course='.$mnet_peer->id.
'%2F1&amp;user='.'0'.
'&amp;date=0'.
'&amp;modid=&amp;modaction=0&amp;logformat=showashtml';
$tabs = array();
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
$tabs[] = new tabobject('mnetservices', 'services.php?hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
if ($mnet_peer->application->name == 'moodle' && $mnet_peer->id != $CFG->mnet_all_hosts_id) {
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
}
$tabs[] = new tabobject('mnetprofilefields', 'profilefields.php?hostid=' . $mnet_peer->id, get_string('profilefields', 'mnet'), get_string('profilefields', 'mnet'), false);
} else {
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
}
print_tabs(array($tabs), $currenttab);
-212
View File
@@ -1,212 +0,0 @@
<?php
/**
* A service browser for remote Moodles
*
* This script 'remotely' executes the reflection methods on a remote Moodle,
* and publishes the details of the available services
*
* @package core
* @subpackage mnet
* @author Donal McMullan donal@catalyst.net.nz
* @version 0.0.1
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mnet
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
require_once($CFG->libdir.'/adminlib.php');
include_once($CFG->dirroot.'/mnet/lib.php');
if ($CFG->mnet_dispatcher_mode === 'off') {
print_error('mnetdisabled', 'mnet');
}
require_login();
admin_externalpage_setup('mnettestclient');
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context);
error_reporting(DEBUG_ALL);
echo $OUTPUT->header();
if (!extension_loaded('openssl')) {
print_error('requiresopenssl', 'mnet', '', NULL, true);
}
// optional drilling down parameters
$hostid = optional_param('hostid', 0, PARAM_INT);
$servicename = optional_param('servicename', '', PARAM_SAFEDIR);
$methodid = optional_param('method', 0, PARAM_INT);
$hosts = $DB->get_records('mnet_host');
$moodleapplicationid = $DB->get_field('mnet_application', 'id', array('name' => 'moodle'));
$url = new moodle_url('/admin/mnet/testclient.php');
$PAGE->set_url($url);
echo $OUTPUT->heading(get_string('hostlist', 'mnet'));
foreach ($hosts as $id => $host) {
if (empty($host->wwwroot) || $host->wwwroot == $CFG->wwwroot) {
continue;
}
$newurl = new moodle_url($url, array('hostid' => $host->id));
echo '<p>' . html_writer::link($newurl, $host->wwwroot) . '</p>';
}
if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
$host = $hosts[$hostid];
if ($host->applicationid != $moodleapplicationid) {
echo $OUTPUT->notification(get_string('notmoodleapplication', 'mnet'));
}
$mnet_peer = new mnet_peer();
$mnet_peer->set_wwwroot($host->wwwroot);
$mnet_request = new mnet_xmlrpc_client();
$mnet_request->set_method('system/listServices');
$mnet_request->send($mnet_peer);
$services = $mnet_request->response;
$yesno = array('No', 'Yes');
$servicenames = array();
echo $OUTPUT->heading(get_string('servicesavailableonhost', 'mnet', $host->wwwroot));
$table = new html_table();
$table->head = array(
get_string('serviceid', 'mnet'),
get_string('service', 'mnet'),
get_string('version', 'mnet'),
get_string('theypublish', 'mnet'),
get_string('theysubscribe', 'mnet'),
get_string('options', 'mnet'),
);
$table->data = array();
$yesno = array(get_string('no'), get_string('yes'));
// this query is horrible and has to be remapped afterwards, because of the non-uniqueness
// of the remoterep service (it has two plugins so far that use it)
// it's possible to get a unique list back using a subquery with LIMIT but that would break oracle
// so it's best to just do this small query and then remap the results afterwards
$sql = '
SELECT DISTINCT
' . $DB->sql_concat('r.plugintype', "'_'", 'r.pluginname', "'_'", 's.name') . ' AS uniqueid,
s.name,
r.plugintype,
r.pluginname
FROM
{mnet_service} s
JOIN {mnet_remote_service2rpc} s2r ON s2r.serviceid = s.id
JOIN {mnet_remote_rpc} r ON r.id = s2r.rpcid';
$serviceinfo = array();
foreach ($DB->get_records_sql($sql) as $result) {
$serviceinfo[$result->name] = $result->plugintype . '_' . $result->pluginname;
}
foreach ($services as $id => $servicedata) {
if (array_key_exists($servicedata['name'], $serviceinfo)) {
$service = $serviceinfo[$servicedata['name']];
$servicedata['humanname'] = get_string($servicedata['name'].'_name', $service);
} else {
$servicedata['humanname'] = get_string('unknown', 'mnet');
}
$newurl = new moodle_url($url, array('hostid' => $host->id, 'servicename' => $servicedata['name']));
$table->data[] = array(
$servicedata['name'],
$servicedata['humanname'],
$servicedata['apiversion'],
$yesno[$servicedata['publish']],
$yesno[$servicedata['subscribe']],
html_writer::link($newurl, get_string('listservices', 'mnet'))
);
}
echo html_writer::table($table);
$mnet_request->set_method('system/listMethods');
if (isset($servicename) && array_key_exists($servicename, $serviceinfo)) {
echo $OUTPUT->heading(get_string('methodsavailableonhostinservice', 'mnet', (object)array('host' => $host->wwwroot, 'service' => $servicename)));
$service = $serviceinfo[$servicename];
$mnet_request->add_param($servicename, 'string');
} else {
echo $OUTPUT->heading(get_string('methodsavailableonhost', 'mnet', $host->wwwroot));
}
$mnet_request->send($mnet_peer);
$methods = $mnet_request->response;
$table = new html_table();
$table->head = array(
get_string('method', 'mnet'),
get_string('options', 'mnet'),
);
$table->data = array();
foreach ($methods as $id => $method) {
$params = array('hostid' => $host->id, 'method' => $id+1);
if (isset($servicename)) {
$params['servicename'] = $servicename;
}
$newurl = new moodle_url($url, $params);
$table->data[] = array(
$method,
html_writer::link($newurl, get_string('inspect', 'mnet'))
);
}
echo html_writer::table($table);
if (isset($methodid) && array_key_exists($methodid-1, $methods)) {
$method = $methods[$methodid-1];
$mnet_request = new mnet_xmlrpc_client();
$mnet_request->set_method('system/methodSignature');
$mnet_request->add_param($method, 'string');
$mnet_request->send($mnet_peer);
$signature = $mnet_request->response;
echo $OUTPUT->heading(get_string('methodsignature', 'mnet', $method));
$table = new html_table();
$table->head = array(
get_string('position', 'mnet'),
get_string('name', 'mnet'),
get_string('type', 'mnet'),
get_string('description', 'mnet'),
);
$table->data = array();
$params = $signature['parameters'];
foreach ($params as $pos => $details) {
$table->data[] = array(
$pos,
$details['name'],
$details['type'],
$details['description'],
);
}
$table->data[] = array(
get_string('returnvalue', 'mnet'),
'',
$signature['return']['type'],
$signature['return']['description']
);
echo html_writer::table($table);
$mnet_request->set_method('system/methodHelp');
$mnet_request->add_param($method, 'string');
$mnet_request->send($mnet_peer);
$help = $mnet_request->response;
echo $OUTPUT->heading(get_string('methodhelp', 'mnet', $method));
echo(str_replace('\n', '<br />',$help));
}
}
echo $OUTPUT->footer();
?>
-68
View File
@@ -1,68 +0,0 @@
<?php
echo $OUTPUT->header();
?>
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
<tr>
<th class="header c0" colspan="2"><?php print_string('trustedhosts', 'mnet'); ?></th>
</tr>
<tr>
<td class="cell c1" colspan="2"><?php print_string('trustedhostsexplain', 'mnet'); ?></td>
</tr>
<tr>
<td class="cell c1" colspan="2">
<form method="post" action="trustedhosts.php">
<div>
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<textarea name="hostlist" cols="40" rows="20"><?php echo $trusted_hosts; ?></textarea><br />
<input type="submit" value="<?php print_string('savechanges'); ?>" />
</div>
</form>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
<tr>
<th class="header c0" colspan="2"><?php print_string('testtrustedhosts', 'mnet'); ?></th>
</tr>
<?php
if (!empty($test_ip_address)){
?>
<tr>
<td class="cell c1" colspan="2">
<?php
if ($in_range) {
print_string('is_in_range', 'mnet', $test_ip_address);
echo '<br />';
print_string('validated_by', 'mnet', $validated_by);
} else {
print_string('not_in_range', 'mnet', $test_ip_address);
}
?>
</td>
</tr>
<?php
} else {
?>
<tr>
<td class="cell c1" colspan="2"><?php print_string('testtrustedhostsexplain', 'mnet'); ?></td>
</tr>
<?php
}
?>
<tr>
<td class="cell c1" colspan="2">
<form method="get" action="trustedhosts.php">
<div>
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<input type="text" name="testipaddress" value="<?php echo $test_ip_address; ?>" />
<input type="submit" value="<?php print_string('go'); ?>" />
</div>
</form>
</td>
</tr>
</table>
</div>
<?php
echo $OUTPUT->footer();
?>
-63
View File
@@ -1,63 +0,0 @@
<?php
// Allows the admin to configure services for remote hosts
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
include_once($CFG->dirroot.'/mnet/lib.php');
require_login();
admin_externalpage_setup('trustedhosts');
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
if (!extension_loaded('openssl')) {
echo $OUTPUT->header();
print_error('requiresopenssl', 'mnet', '', NULL, true);
}
$site = get_site();
$trusted_hosts = '';//array();
$old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts');
if (!empty($old_trusted_hosts)) {
$old_trusted_hosts = explode(',', $old_trusted_hosts);
} else {
$old_trusted_hosts = array();
}
$test_ip_address = optional_param('testipaddress', NULL, PARAM_HOST);
$in_range = false;
if (!empty($test_ip_address)) {
foreach($old_trusted_hosts as $host) {
if (address_in_subnet($test_ip_address, $host)) {
$in_range = true;
$validated_by = $host;
break;
}
}
}
/// If data submitted, process and store
if (($form = data_submitted()) && confirm_sesskey()) {
$hostlist = preg_split("/[\s,]+/", $form->hostlist);
foreach($hostlist as $host) {
list($address, $mask) = explode('/', $host.'/');
if (empty($address)) continue;
if (strlen($mask) == 0) $mask = 32;
$trusted_hosts .= trim($address).'/'.trim($mask)."\n";
unset($address, $mask);
}
set_config('mnet_trusted_hosts', str_replace("\n", ',', $trusted_hosts), 'mnet');
} elseif (!empty($old_trusted_hosts)) {
foreach($old_trusted_hosts as $host) {
list($address, $mask) = explode('/', $host.'/');
if (empty($address)) continue;
if (strlen($mask) == 0) $mask = 32;
$trusted_hosts .= trim($address).'/'.trim($mask)."\n";
unset($address, $mask);
}
}
include('./trustedhosts.html');
+60
View File
@@ -0,0 +1,60 @@
<?PHP // $Id$
// module.php - allows admin to edit all local configuration variables for a module
require_once("../config.php");
require_login();
if (!isadmin()) {
error("Only an admin can use this page");
}
if (!$site = get_site()) {
error("Site isn't defined!");
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
/// If data submitted, then process and store.
if ($config = data_submitted()) {
print_header();
foreach ($config as $name => $value) {
set_config($name, $value);
}
redirect("$CFG->wwwroot/$CFG->admin/modules.php", get_string("changessaved"), 1);
exit;
}
/// Otherwise print the form.
require_variable($module);
$module = clean_filename($module);
require_once("$CFG->dirroot/mod/$module/lib.php");
$stradmin = get_string("administration");
$strconfiguration = get_string("configuration");
$strmanagemodules = get_string("managemodules");
$strmodulename = get_string("modulename", $module);
print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
"<a href=\"index.php\">$stradmin</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> ".
"<a href=\"modules.php\">$strmanagemodules</a> -> $strmodulename");
print_heading($strmodulename);
print_simple_box("<center>".get_string("configwarning")."</center>", "center", "50%");
echo "<br />";
print_simple_box_start("center", "", "$THEME->cellheading");
include("$CFG->dirroot/mod/$module/config.html");
print_simple_box_end();
print_footer();
?>
+133 -128
View File
@@ -1,25 +1,30 @@
<?php
// Allows the admin to manage activity modules
<?PHP // $Id$
// Allows the admin to create, delete and rename course categories
require_once('../config.php');
require_once('../course/lib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once("../config.php");
require_once("../course/lib.php");
// defines
define('MODULE_TABLE','module_administration_table');
optional_variable($disable);
optional_variable($enable);
optional_variable($delete);
optional_variable($confirm);
admin_externalpage_setup('managemodules');
require_login();
$show = optional_param('show', '', PARAM_PLUGIN);
$hide = optional_param('hide', '', PARAM_PLUGIN);
$delete = optional_param('delete', '', PARAM_PLUGIN);
$confirm = optional_param('confirm', '', PARAM_BOOL);
if (!isadmin()) {
error("Only administrators can use this page!");
}
if (!$site = get_site()) {
error("Site isn't defined!");
}
/// Print headings
$stractivities = get_string("activities");
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
$strmanagemodules = get_string("managemodules");
$strdelete = get_string("delete");
$strversion = get_string("version");
$strhide = get_string("hide");
@@ -27,166 +32,166 @@
$strsettings = get_string("settings");
$stractivities = get_string("activities");
$stractivitymodule = get_string("activitymodule");
$strshowmodulecourse = get_string('showmodulecourse');
print_header("$site->shortname: $strmanagemodules", "$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"configure.php\">$strconfiguration</a> -> $strmanagemodules");
print_heading($strmanagemodules);
/// If data submitted, then process and store.
if (!empty($hide) and confirm_sesskey()) {
if (!$module = $DB->get_record("modules", array("name"=>$hide))) {
print_error('moduledoesnotexist', 'error');
if (!$module = get_record("modules", "name", $hide)) {
error("Module doesn't exist!");
}
$DB->set_field("modules", "visible", "0", array("id"=>$module->id)); // Hide main module
// Remember the visibility status in visibleold
// and hide...
$sql = "UPDATE {course_modules}
SET visibleold=visible, visible=0
WHERE module=?";
$DB->execute($sql, array($module->id));
// clear the course modinfo cache for courses
// where we just deleted something
$sql = "UPDATE {course}
SET modinfo=''
WHERE id IN (SELECT DISTINCT course
FROM {course_modules}
WHERE visibleold=1 AND module=?)";
$DB->execute($sql, array($module->id));
admin_get_root(true, false); // settings not required - only pages
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
set_field("course_modules", "visible", "0", "module", $module->id); // Hide all related activity modules
}
if (!empty($show) and confirm_sesskey()) {
if (!$module = $DB->get_record("modules", array("name"=>$show))) {
print_error('moduledoesnotexist', 'error');
if (!$module = get_record("modules", "name", $show)) {
error("Module doesn't exist!");
}
$DB->set_field("modules", "visible", "1", array("id"=>$module->id)); // Show main module
$DB->set_field('course_modules', 'visible', '1', array('visibleold'=>1, 'module'=>$module->id)); // Get the previous saved visible state for the course module.
// clear the course modinfo cache for courses
// where we just made something visible
$sql = "UPDATE {course}
SET modinfo = ''
WHERE id IN (SELECT DISTINCT course
FROM {course_modules}
WHERE visible=1 AND module=?)";
$DB->execute($sql, array($module->id));
admin_get_root(true, false); // settings not required - only pages
set_field("modules", "visible", "1", "id", $module->id); // Show main module
set_field("course_modules", "visible", "1", "module", $module->id); // Show all related activity modules
}
if (!empty($delete) and confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading($stractivities);
$strmodulename = get_string("modulename", "$delete");
if (get_string_manager()->string_exists('modulename', $delete)) {
$strmodulename = get_string('modulename', $delete);
} else {
$strmodulename = $delete;
}
if (!$confirm) {
echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php");
echo $OUTPUT->footer();
if (empty($confirm)) {
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
"modules.php?delete=$delete&confirm=$delete&sesskey=$USER->sesskey",
"modules.php");
print_footer();
exit;
} else { // Delete everything!!
if ($delete == "forum") {
print_error("cannotdeleteforummodule", 'forum');
error("You can not delete the forum module!!");
}
uninstall_plugin('mod', $delete);
$a = new stdClass();
if (!$module = get_record("modules", "name", $delete)) {
error("Module doesn't exist!");
}
// OK, first delete all the relevant instances from all course sections
if ($coursemods = get_records("course_modules", "module", $module->id)) {
foreach ($coursemods as $coursemod) {
if (! delete_mod_from_section($coursemod->id, $coursemod->section)) {
notify("Could not delete the $strmodulename with id = $coursemod->id from section $coursemod->section");
}
}
}
// Now delete all the course module records
if (!delete_records("course_modules", "module", $module->id)) {
notify("Error occurred while deleting all $strmodulename records in course_modules table");
}
// Then delete all the logs
if (!delete_records("log", "module", $module->name)) {
notify("Error occurred while deleting all $strmodulename records in log table");
}
// And log_display information
if (!delete_records("log_display", "module", $module->name)) {
notify("Error occurred while deleting all $strmodulename records in log_display table");
}
// And the module entry itself
if (!delete_records("modules", "name", $module->name)) {
notify("Error occurred while deleting the $strmodulename record from modules table");
}
// Then the tables themselves
if ($tables = $db->Metatables()) {
$prefix = $CFG->prefix.$module->name;
foreach ($tables as $table) {
if (strpos($table, $prefix) === 0) {
if (!execute_sql("DROP TABLE $table", false)) {
notify("ERROR: while trying to drop table $table");
}
}
}
}
rebuild_course_cache(); // Because things have changed
$a->module = $strmodulename;
$a->directory = "$CFG->dirroot/mod/$delete";
echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess');
echo $OUTPUT->continue_button("modules.php");
echo $OUTPUT->footer();
exit;
notice(get_string("moduledeletefiles", "", $a), "modules.php");
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading($stractivities);
/// Get and sort the existing modules
if (!$modules = $DB->get_records('modules', array(), 'name ASC')) {
print_error('moduledoesnotexist', 'error');
if (!$modules = get_records("modules")) {
error("No modules found!!"); // Should never happen
}
/// Print the table of all modules
// construct the flexible table ready to display
$table = new flexible_table(MODULE_TABLE);
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
$table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
$table->set_attribute('id', 'modules');
$table->set_attribute('class', 'generaltable');
$table->setup();
foreach ($modules as $module) {
$strmodulename = get_string("modulename", "$module->name");
$modulebyname[$strmodulename] = $module;
}
ksort($modulebyname);
if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) {
$strmodulename = '<span class="notifyproblem">'.$module->name.' ('.get_string('missingfromdisk').')</span>';
$missing = true;
} else {
// took out hspace="\10\", because it does not validate. don't know what to replace with.
$icon = "<img src=\"" . $OUTPUT->pix_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />";
$strmodulename = $icon.' '.get_string('modulename', $module->name);
$missing = false;
}
/// Print the table of all modules
$delete = "<a href=\"modules.php?delete=$module->name&amp;sesskey=".sesskey()."\">$strdelete</a>";
if (empty($THEME->custompix)) {
$pixpath = "../pix";
$modpixpath = "../mod";
} else {
$pixpath = "../theme/$CFG->theme/pix";
$modpixpath = "../theme/$CFG->theme/pix/mod";
}
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") ||
file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) {
$settings = "<a href=\"settings.php?section=modsetting$module->name\">$strsettings</a>";
$table->head = array ($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings);
$table->align = array ("LEFT", "RIGHT", "LEFT", "CENTER", "CENTER", "CENTER");
$table->wrap = array ("NOWRAP", "", "", "", "","");
$table->size = array ("100%", "10", "10", "10", "10","12");
$table->width = "100";
foreach ($modulebyname as $modulename => $module) {
$icon = "<img src=\"$modpixpath/$module->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
$settings = "<a href=\"module.php?module=$module->name&sesskey=$USER->sesskey\">$strsettings</a>";
} else {
$settings = "";
}
try {
$count = $DB->count_records_select($module->name, "course<>0");
} catch (dml_exception $e) {
$count = -1;
}
if ($count>0) {
$countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
"&amp;sesskey=".sesskey()."\" title=\"$strshowmodulecourse\">$count</a>";
} else if ($count < 0) {
$countlink = get_string('error');
} else {
$countlink = "$count";
}
$count = count_records("$module->name");
if ($missing) {
$visible = '';
$class = '';
} else if ($module->visible) {
$visible = "<a href=\"modules.php?hide=$module->name&amp;sesskey=".sesskey()."\" title=\"$strhide\">".
"<img src=\"" . $OUTPUT->pix_url('i/hide') . "\" class=\"icon\" alt=\"$strhide\" /></a>";
$class = '';
if ($module->visible) {
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
"<img src=\"$pixpath/i/hide.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
$class = "";
} else {
$visible = "<a href=\"modules.php?show=$module->name&amp;sesskey=".sesskey()."\" title=\"$strshow\">".
"<img src=\"" . $OUTPUT->pix_url('i/show') . "\" class=\"icon\" alt=\"$strshow\" /></a>";
$class = ' class="dimmed_text"';
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
"<img src=\"$pixpath/i/show.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
$class = "class=\"dimmed_text\"";
}
if ($module->name == "forum") {
$delete = "";
$visible = "";
$class = "";
}
$table->add_data(array(
'<span'.$class.'>'.$strmodulename.'</span>',
$countlink,
'<span'.$class.'>'.$module->version.'</span>',
$visible,
$delete,
$settings
));
$table->data[] = array ("<p $class>$icon $modulename</p>", $count, $module->version, $visible, $delete, $settings);
}
print_table($table);
$table->print_html();
echo $OUTPUT->footer();
echo "<br /><br />";
print_footer();
?>
-166
View File
@@ -1,166 +0,0 @@
<?php
if (!isset($CFG)) {
require('../config.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('oacleanup');
echo $OUTPUT->header();
online_assignment_cleanup(true);
echo $OUTPUT->footer();
}
function online_assignment_cleanup($output=false) {
global $CFG, $DB, $OUTPUT;
if ($output) {
echo $OUTPUT->heading('Online Assignment Cleanup');
echo '<center>';
}
/// We don't want to run this code if we are doing an upgrade from an assignment
/// version earlier than 2005041400
/// because the assignment type field will not exist
$amv = $DB->get_field('modules', 'version', array('name'=>'assignment'));
if ((int)$amv < 2005041400) {
if ($output) {
echo '</center>';
}
return;
}
/// get the module id for assignments from db
$arecord = $DB->get_record('modules', array('name', 'assignment'));
$aid = $arecord->id;
/// get a list of all courses on this site
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT c.* $ctxselect FROM {course} c $ctxjoin";
$courses = $DB->get_records_sql($sql);
/// cycle through each course
foreach ($courses as $course) {
context_instance_preload($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (empty($course->fullname)) {
$fullname = get_string('course').': '.$course->id;
} else {
$fullname = format_string($course->fullname, true, array('context' => $context));
}
if ($output) echo $OUTPUT->heading($fullname);
/// retrieve a list of sections beyond what is currently being shown
$sql = "SELECT *
FROM {course_sections}
WHERE course=? AND section>?
ORDER BY section ASC";
$params = array($course->id, $course->numsections);
if (!($xsections = $DB->get_records_sql($sql, $params))) {
if ($output) echo 'No extra sections<br />';
continue;
}
/// cycle through each of the xtra sections
foreach ($xsections as $xsection) {
if ($output) echo 'Checking Section: '.$xsection->section.'<br />';
/// grab any module instances from the sequence field
if (!empty($xsection->sequence)) {
$instances = explode(',', $xsection->sequence);
/// cycle through the instances
foreach ($instances as $instance) {
/// is this an instance of an online assignment
$sql = "SELECT a.id
FROM {course_modules} cm, {assignment} a
WHERE cm.id = ? AND cm.module = ? AND
cm.instance = a.id AND a.assignmenttype = 'online'";
$params = array($instance, $aid);
/// if record exists then we need to move instance to it's correct section
if ($DB->record_exists_sql($sql, $params)) {
/// check the new section id
/// the journal update erroneously stored it in course_sections->section
$newsection = $xsection->section;
/// double check the new section
if ($newsection > $course->numsections) {
/// get the record for section 0 for this course
if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
continue;
}
$newsection = $zerosection->id;
}
/// grab the section record
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
if ($output) {
echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. $fullname .'<br />';
}
continue;
}
/// explode the sequence
if (($sequence = explode(',', $section->sequence)) === false) {
$sequence = array();
}
/// add instance to correct section
array_push($sequence, $instance);
/// implode the sequence
$section->sequence = implode(',', $sequence);
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
/// now we need to remove the instance from the old sequence
/// grab the old section record
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$fullname.'<br />';
continue;
}
/// explode the sequence
if (($sequence = explode(',', $section->sequence)) === false) {
$sequence = array();
}
/// remove the old value from the array
$key = array_search($instance, $sequence);
unset($sequence[$key]);
/// implode the sequence
$section->sequence = implode(',', $sequence);
$DB->set_field('course_sections', 'sequence', $section->sequence, array('id'=>$section->id));
if ($output) echo 'Online Assignment (instance '.$instance.') moved from section '.$section->id.': to section '.$newsection.'<br />';
}
}
}
/// if the summary and sequence are empty then remove this section
if (empty($xsection->summary) and empty($xsection->sequence)) {
$DB->delete_records('course_sections', array('id'=>$xsection->id));
if ($output) echo 'Deleting empty section '.$xsection->section.'<br />';
}
}
}
echo '</center>';
}
+25 -24
View File
@@ -1,33 +1,34 @@
<?php
<?PHP // $Id$
// phpinfo.php - shows phpinfo for the current server
require_once("../config.php");
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('phpinfo');
require_login();
echo $OUTPUT->header();
if (!isadmin()) {
error("Only the admin can use this page");
}
echo '<div class="phpinfo">';
if (isset($topframe)) {
$stradministration = get_string("administration");
$site = get_site();
print_header("$site->shortname: phpinfo", "$site->fullname",
"<a target=\"$CFG->framename\" href=\"index.php\">$stradministration</a> -> PHP info");
exit;
}
ob_start();
phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES);
$html = ob_get_contents();
ob_end_clean();
/// Delete styles from output
$html = preg_replace('#(\n?<style[^>]*?>.*?</style[^>]*?>)|(\n?<style[^>]*?/>)#is', '', $html);
$html = preg_replace('#(\n?<head[^>]*?>.*?</head[^>]*?>)|(\n?<head[^>]*?/>)#is', '', $html);
/// Delete DOCTYPE from output
$html = preg_replace('/<!DOCTYPE html PUBLIC.*?>/is', '', $html);
/// Delete body and html tags
$html = preg_replace('/<html.*?>.*?<body.*?>/is', '', $html);
$html = preg_replace('/<\/body><\/html>/is', '', $html);
echo $html;
echo '</div>';
echo $OUTPUT->footer();
if (isset($bottomframe)) {
phpinfo();
exit;
}
?>
<head>
<title>PHP info</title>
</head>
<frameset rows="80,*">
<frame src="phpinfo.php?topframe=true">
<frame src="phpinfo.php?bottomframe=true">
</frameset>
-34
View File
@@ -1,34 +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/>.
/**
* UI for general plugins management
*
* @package core
* @subpackage admin
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
admin_externalpage_setup('pluginsoverview');
$output = $PAGE->get_renderer('core', 'admin');
echo $output->plugin_management_page(plugin_manager::instance());
-247
View File
@@ -1,247 +0,0 @@
<?php
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir . '/portfoliolib.php');
require_once($CFG->libdir . '/portfolio/forms.php');
require_once($CFG->libdir . '/adminlib.php');
$portfolio = optional_param('pf', '', PARAM_FORMAT);
$action = optional_param('action', '', PARAM_ALPHA);
$sure = optional_param('sure', '', PARAM_ALPHA);
$display = true; // fall through to normal display
$pagename = 'manageportfolios';
if ($action == 'edit') {
$pagename = 'portfoliosettings' . $portfolio;
} else if ($action == 'delete') {
$pagename = 'portfoliodelete';
} else if (($action == 'newon') || ($action == 'newoff')) {
$pagename = 'portfolionew';
}
// Need to remember this for form
$formaction = $action;
// Check what visibility to show the new repository
if ($action == 'newon') {
$action = 'new';
$visible = 1;
} else if ($action == 'newoff') {
$action = 'new';
$visible = 0;
}
admin_externalpage_setup($pagename);
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$baseurl = "$CFG->wwwroot/$CFG->admin/portfolio.php";
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/portfolio.php?sesskey=" . sesskey();
$configstr = get_string('manageportfolios', 'portfolio');
$return = true; // direct back to the main page
/**
* Helper function that generates a moodle_url object
* relevant to the portfolio
*/
function portfolio_action_url($portfolio) {
global $baseurl;
return new moodle_url($baseurl, array('sesskey'=>sesskey(), 'pf'=>$portfolio));
}
if (($action == 'edit') || ($action == 'new')) {
if (($action == 'edit')) {
$instance = portfolio_instance($portfolio);
$plugin = $instance->get('plugin');
// Since visible is being passed to form
// and used to set the value when a new
// instance is created - we must also
// place the currently visibility into the
// form as well
$visible = $instance->get('visible');
} else {
$instance = null;
$plugin = $portfolio;
}
$PAGE->set_pagetype('admin-portfolio-' . $plugin);
// Display the edit form for this instance
$mform = new portfolio_admin_form('', array('plugin' => $plugin, 'instance' => $instance, 'portfolio' => $portfolio, 'action' => $formaction, 'visible' => $visible));
// End setup, begin output
if ($mform->is_cancelled()){
redirect($baseurl);
exit;
} else if (($fromform = $mform->get_data()) && (confirm_sesskey())) {
// Unset whatever doesn't belong in fromform
foreach (array('pf', 'action', 'plugin', 'sesskey', 'submitbutton') as $key) {
unset($fromform->{$key});
}
// This branch is where you process validated data.
if ($action == 'edit') {
$instance->set_config((array)$fromform);
$instance->save();
} else {
portfolio_static_function($plugin, 'create_instance', $plugin, $fromform->name, $fromform);
}
$savedstr = get_string('instancesaved', 'portfolio');
redirect($baseurl, $savedstr, 1);
exit;
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('configplugin', 'portfolio'));
echo $OUTPUT->box_start();
$mform->display();
echo $OUTPUT->box_end();
$return = false;
}
} else if (($action == 'hide') || ($action == 'show')) {
require_sesskey();
$instance = portfolio_instance($portfolio);
$current = $instance->get('visible');
if (empty($current) && $instance->instance_sanity_check()) {
print_error('cannotsetvisible', 'portfolio', $baseurl);
}
if ($action == 'show') {
$visible = 1;
} else {
$visible = 0;
}
$instance->set('visible', $visible);
$instance->save();
$return = true;
} else if ($action == 'delete') {
$instance = portfolio_instance($portfolio);
if ($sure) {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
if ($instance->delete()) {
$deletedstr = get_string('instancedeleted', 'portfolio');
redirect($baseurl, $deletedstr, 1);
} else {
print_error('instancenotdeleted', 'portfolio', $baseurl);
}
exit;
} else {
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('sure', 'portfolio', $instance->get('name')), $sesskeyurl . '&pf='.$portfolio.'&action=delete&sure=yes', $baseurl);
$return = false;
}
} else {
// If page is loaded directly
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manageportfolios', 'portfolio'));
// Get strings that are used
$strshow = get_string('on', 'portfolio');
$strhide = get_string('off', 'portfolio');
$strdelete = get_string('disabledinstance', 'portfolio');
$strsettings = get_string('settings');
$actionchoicesforexisting = array(
'show' => $strshow,
'hide' => $strhide,
'delete' => $strdelete
);
$actionchoicesfornew = array(
'newon' => $strshow,
'newoff' => $strhide,
'delete' => $strdelete
);
$output = $OUTPUT->box_start('generalbox');
$plugins = get_plugin_list('portfolio');
$plugins = array_keys($plugins);
$instances = portfolio_instances(false, false);
$usedplugins = array();
// to avoid notifications being sent out while admin is editing the page
define('ADMIN_EDITING_PORTFOLIO', true);
$insane = portfolio_plugin_sanity_check($plugins);
$insaneinstances = portfolio_instance_sanity_check($instances);
$table = new html_table();
$table->head = array(get_string('plugin', 'portfolio'), '', '');
$table->data = array();
foreach ($instances as $i) {
$settings = '<a href="' . $sesskeyurl . '&amp;action=edit&amp;pf=' . $i->get('id') . '">' . $strsettings .'</a>';
// Set some commonly used variables
$pluginid = $i->get('id');
$plugin = $i->get('plugin');
$pluginname = $i->get('name');
// Check if the instance is misconfigured
if (array_key_exists($plugin, $insane) || array_key_exists($pluginid, $insaneinstances)) {
if (!empty($insane[$plugin])) {
$information = $insane[$plugin];
} else if (!empty($insaneinstances[$pluginid])) {
$information = $insaneinstances[$pluginid];
}
$table->data[] = array($pluginname, $strdelete . " " . $OUTPUT->help_icon($information, 'portfolio_' . $plugin), $settings);
} else {
if ($i->get('visible')) {
$currentaction = 'show';
} else {
$currentaction = 'hide';
}
$select = new single_select(portfolio_action_url($pluginid, 'pf'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . $pluginid);
$table->data[] = array($pluginname, $OUTPUT->render($select), $settings);
}
if (!in_array($plugin, $usedplugins)) {
$usedplugins[] = $plugin;
}
}
// Create insane plugin array
$insaneplugins = array();
if (!empty($plugins)) {
foreach ($plugins as $p) {
// Check if it can not have multiple instances and has already been used
if (!portfolio_static_function($p, 'allows_multiple_instances') && in_array($p, $usedplugins)) {
continue;
}
// Check if it is misconfigured - if so store in array then display later
if (array_key_exists($p, $insane)) {
$insaneplugins[] = $p;
} else {
$select = new single_select(portfolio_action_url($p, 'pf'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . $p);
$table->data[] = array(portfolio_static_function($p, 'get_name'), $OUTPUT->render($select), '');
}
}
}
// Loop through all the insane plugins
if (!empty($insaneplugins)) {
foreach ($insaneplugins as $p) {
$table->data[] = array(portfolio_static_function($p, 'get_name'), $strdelete . " " . $OUTPUT->help_icon($insane[$p], 'portfolio_' . $p), '');
}
}
$output .= html_writer::table($table);
$output .= $OUTPUT->box_end();
echo $output;
$return = false;
}
if ($return) {
// Redirect to base
redirect($baseurl);
}
echo $OUTPUT->footer();
-80
View File
@@ -1,80 +0,0 @@
#!/usr/bin/php -f
<?php
//error_reporting(0);
//ini_set('display_errors',0);
require_once(dirname(dirname(__FILE__)).'/config.php');
$tmp = explode('@',$_ENV['RECIPIENT']);
$address = $tmp[0];
// BOUNCE EMAILS TO NOREPLY
if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress) {
$user = new stdClass();
$user->email = $_ENV['SENDER'];
if (!validate_email($user->email)) {
die();
}
$site = get_site();
$subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname));
$body = get_string('noreplybouncemessage','moodle',format_string($site->fullname))."\n\n";
$fd = fopen('php://stdin','r');
if ($fd) {
while(!feof($fd)) {
$body .= fgets($fd);
}
fclose($fd);
}
$user->id = 0; // to prevent anything annoying happening
$from->firstname = null;
$from->lastname = null;
$from->email = '<>';
$from->maildisplay = true;
email_to_user($user,$from,$subject,$body);
die ();
}
/// ALL OTHER PROCESSING
// we need to split up the address
$prefix = substr($address,0,4);
$mod = substr($address,4,2);
$modargs = substr($address,6,-16);
$hash = substr($address,-16);
if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier),0,16) != $hash) {
die("HASH DIDN'T MATCH!\n");
}
list(,$modid) = unpack('C',base64_decode($mod.'=='));
if ($modid == '0') { // special
$modname = 'moodle';
}
else {
$modname = $DB->get_field("modules", "name", array("id"=>$modid));
include_once('mod/'.$modname.'/lib.php');
}
$function = $modname.'_process_email';
if (!function_exists($function)) {
die();
}
$fd = fopen('php://stdin','r');
if (!$fd) {
exit();
}
while(!feof($fd)) {
$body .= fgets($fd);
}
$function($modargs,$body);
fclose($fd);
-63
View File
@@ -1,63 +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/>.
/**
* This script triggers a full purging of system caches,
* this is useful mostly for developers who did not disable the caching.
*
* @package core
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$confirm = optional_param('confirm', 0, PARAM_BOOL);
admin_externalpage_setup('purgecaches');
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
if ($confirm) {
require_sesskey();
// Valid request. Purge, and redisplay the form so it is easy to purge again
// in the near future.
purge_all_caches();
redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
} else {
// Show a confirm form.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
$url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
$button = new single_button($url, get_string('purgecaches','admin'), 'post');
// Cancel button takes them back to the page the were on, if possible,
// otherwise to the site home page.
$return = new moodle_url('/');
if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
$return = $_SERVER['HTTP_REFERER'];
}
}
echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
echo $OUTPUT->footer();
}
-302
View File
@@ -1,302 +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/>.
/**
* Allows the admin to manage question behaviours.
*
* @package moodlecore
* @subpackage questionengine
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/tablelib.php');
// Check permissions.
require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/question:config', $systemcontext);
admin_externalpage_setup('manageqbehaviours');
$thispageurl = new moodle_url('/admin/qbehaviours.php');
$behaviours = get_plugin_list('qbehaviour');
$pluginmanager = plugin_manager::instance();
// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql_menu("
SELECT behaviour, COUNT(1)
FROM {question_attempts} GROUP BY behaviour");
$needed = array();
$archetypal = array();
foreach ($behaviours as $behaviour => $notused) {
if (!array_key_exists($behaviour, $counts)) {
$counts[$behaviour] = 0;
}
$needed[$behaviour] = ($counts[$behaviour] > 0) ||
$pluginmanager->other_plugins_that_require('qbehaviour_' . $behaviour);
$archetypal[$behaviour] = question_engine::is_behaviour_archetypal($behaviour);
}
foreach ($counts as $behaviour => $count) {
if (!array_key_exists($behaviour, $behaviours)) {
$counts['missing'] += $count;
}
}
$needed['missing'] = true;
// Work of the correct sort order.
$config = get_config('question');
$sortedbehaviours = array();
foreach ($behaviours as $behaviour => $notused) {
$sortedbehaviours[$behaviour] = question_engine::get_behaviour_name($behaviour);
}
if (!empty($config->behavioursortorder)) {
$sortedbehaviours = question_engine::sort_behaviours($sortedbehaviours,
$config->behavioursortorder, '');
}
if (!empty($config->disabledbehaviours)) {
$disabledbehaviours = explode(',', $config->disabledbehaviours);
} else {
$disabledbehaviours = array();
}
// Process actions ============================================================
// Disable.
if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($behaviours[$disable])) {
print_error('unknownbehaviour', 'question', $thispageurl, $disable);
}
if (array_search($disable, $disabledbehaviours) === false) {
$disabledbehaviours[] = $disable;
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
}
redirect($thispageurl);
}
// Enable.
if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($behaviours[$enable])) {
print_error('unknownbehaviour', 'question', $thispageurl, $enable);
}
if (!$archetypal[$enable]) {
print_error('cannotenablebehaviour', 'question', $thispageurl, $enable);
}
if (($key = array_search($enable, $disabledbehaviours)) !== false) {
unset($disabledbehaviours[$key]);
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
}
redirect($thispageurl);
}
// Move up in order.
if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($behaviours[$up])) {
print_error('unknownbehaviour', 'question', $thispageurl, $up);
}
// This function works fine for behaviours, as well as qtypes.
$neworder = question_reorder_qtypes($sortedbehaviours, $up, -1);
set_config('behavioursortorder', implode(',', $neworder), 'question');
redirect($thispageurl);
}
// Move down in order.
if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($behaviours[$down])) {
print_error('unknownbehaviour', 'question', $thispageurl, $down);
}
// This function works fine for behaviours, as well as qtypes.
$neworder = question_reorder_qtypes($sortedbehaviours, $down, +1);
set_config('behavioursortorder', implode(',', $neworder), 'question');
redirect($thispageurl);
}
// Delete.
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
// Check it is OK to delete this question type.
if ($delete == 'missing') {
print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
}
if (!isset($behaviours[$delete])) {
print_error('unknownbehaviour', 'question', $thispageurl, $delete);
}
$behaviourname = $sortedbehaviours[$delete];
if ($counts[$delete] > 0) {
print_error('cannotdeletebehaviourinuse', 'question', $thispageurl, $behaviourname);
}
if ($needed[$delete] > 0) {
print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
}
// If not yet confirmed, display a confirmation message.
if (!optional_param('confirm', '', PARAM_BOOL)) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
echo $OUTPUT->confirm(
get_string('deletebehaviourareyousuremessage', 'question', $behaviourname),
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
$thispageurl);
echo $OUTPUT->footer();
exit;
}
// Do the deletion.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
// Delete any configuration records.
if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) {
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete));
}
if (($key = array_search($delete, $disabledbehaviours)) !== false) {
unset($disabledbehaviours[$key]);
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
}
$behaviourorder = array_keys($sortedbehaviours);
if (($key = array_search($delete, $behaviourorder)) !== false) {
unset($behaviourorder[$key]);
set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
}
// Then the tables themselves
drop_plugin_tables($delete, get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false);
// Remove event handlers and dequeue pending events
events_uninstall('qbehaviour_' . $delete);
$a = new stdClass();
$a->behaviour = $behaviourname;
$a->directory = get_plugin_directory('qbehaviour', $delete);
echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($thispageurl);
echo $OUTPUT->footer();
exit;
}
// End of process actions ==================================================
// Print the page heading.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manageqbehaviours', 'admin'));
// Set up the table.
$table = new flexible_table('qbehaviouradmintable');
$table->define_baseurl($thispageurl);
$table->define_columns(array('behaviour', 'numqas', 'version', 'requires',
'available', 'delete'));
$table->define_headers(array(get_string('behaviour', 'question'), get_string('numqas', 'question'),
get_string('version'), get_string('requires', 'admin'),
get_string('availableq', 'question'), get_string('delete')));
$table->set_attribute('id', 'qbehaviours');
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
$table->setup();
// Add a row for each question type.
foreach ($sortedbehaviours as $behaviour => $behaviourname) {
$row = array();
// Question icon and name.
$row[] = $behaviourname;
// Count
$row[] = $counts[$behaviour];
// Question version number.
$version = get_config('qbehaviour_' . $behaviour, 'version');
if ($version) {
$row[] = $version;
} else {
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'disabled'));
}
// Other question types required by this one.
$plugin = $pluginmanager->get_plugin_info('qbehaviour_' . $behaviour);
$required = $plugin->get_other_required_plugins();
if (!empty($required)) {
$strrequired = array();
foreach ($required as $component => $notused) {
$strrequired[] = $pluginmanager->plugin_name($component);
}
$row[] = implode(', ', $strrequired);
} else {
$row[] = '';
}
// Are people allowed to select this behaviour?
$rowclass = '';
if ($archetypal[$behaviour]) {
$enabled = array_search($behaviour, $disabledbehaviours) === false;
$icons = question_behaviour_enable_disable_icons($behaviour, $enabled);
if (!$enabled) {
$rowclass = 'dimmed_text';
}
} else {
$icons = $OUTPUT->spacer() . ' ';
}
// Move icons.
$icons .= question_behaviour_icon_html('up', $behaviour, 't/up', get_string('up'), null);
$icons .= question_behaviour_icon_html('down', $behaviour, 't/down', get_string('down'), null);
$row[] = $icons;
// Delete link, if available.
if ($needed[$behaviour]) {
$row[] = '';
} else {
$row[] = html_writer::link(new moodle_url($thispageurl,
array('delete' => $behaviour, 'sesskey' => sesskey())), get_string('delete'),
array('title' => get_string('uninstallbehaviour', 'question')));
}
$table->add_data($row, $rowclass);
}
$table->finish_output();
echo $OUTPUT->footer();
function question_behaviour_enable_disable_icons($behaviour, $enabled) {
if ($enabled) {
return question_behaviour_icon_html('disable', $behaviour, 'i/hide',
get_string('enabled', 'question'), get_string('disable'));
} else {
return question_behaviour_icon_html('enable', $behaviour, 'i/show',
get_string('disabled', 'question'), get_string('enable'));
}
}
function question_behaviour_icon_html($action, $behaviour, $icon, $alt, $tip) {
global $OUTPUT;
return $OUTPUT->action_icon(new moodle_url('/admin/qbehaviours.php',
array($action => $behaviour, 'sesskey' => sesskey())),
new pix_icon($icon, $alt, 'moodle', array('title' => '')),
null, array('title' => $tip)) . ' ';
}
-312
View File
@@ -1,312 +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/>.
/**
* Allows the admin to manage question types.
*
* @package moodlecore
* @subpackage questionbank
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/tablelib.php');
// Check permissions.
require_login();
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/question:config', $systemcontext);
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
admin_externalpage_setup('manageqtypes');
$thispageurl = new moodle_url('/admin/qtypes.php');
$qtypes = question_bank::get_all_qtypes();
$pluginmanager = plugin_manager::instance();
// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql("
SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden
FROM {question} GROUP BY qtype", array());
$needed = array();
foreach ($qtypes as $qtypename => $qtype) {
if (!isset($counts[$qtypename])) {
$counts[$qtypename] = new stdClass;
$counts[$qtypename]->numquestions = 0;
$counts[$qtypename]->numhidden = 0;
}
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0 ||
$pluginmanager->other_plugins_that_require($qtype->plugin_name());
$counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
}
$needed['missingtype'] = true; // The system needs the missing question type.
foreach ($counts as $qtypename => $count) {
if (!isset($qtypes[$qtypename])) {
$counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
$counts['missingtype']->numhidden += $count->numhidden;
}
}
// Work of the correct sort order.
$config = get_config('question');
$sortedqtypes = array();
foreach ($qtypes as $qtypename => $qtype) {
$sortedqtypes[$qtypename] = $qtype->local_name();
}
$sortedqtypes = question_bank::sort_qtype_array($sortedqtypes, $config);
// Process actions ============================================================
// Disable.
if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($qtypes[$disable])) {
print_error('unknownquestiontype', 'question', $thispageurl, $disable);
}
set_config($disable . '_disabled', 1, 'question');
redirect($thispageurl);
}
// Enable.
if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($qtypes[$enable])) {
print_error('unknownquestiontype', 'question', $thispageurl, $enable);
}
if (!$qtypes[$enable]->menu_name()) {
print_error('cannotenable', 'question', $thispageurl, $enable);
}
unset_config($enable . '_disabled', 'question');
redirect($thispageurl);
}
// Move up in order.
if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($qtypes[$up])) {
print_error('unknownquestiontype', 'question', $thispageurl, $up);
}
$neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
question_save_qtype_order($neworder, $config);
redirect($thispageurl);
}
// Move down in order.
if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
if (!isset($qtypes[$down])) {
print_error('unknownquestiontype', 'question', $thispageurl, $down);
}
$neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
question_save_qtype_order($neworder, $config);
redirect($thispageurl);
}
// Delete.
if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
// Check it is OK to delete this question type.
if ($delete == 'missingtype') {
print_error('cannotdeletemissingqtype', 'question', $thispageurl);
}
if (!isset($qtypes[$delete])) {
print_error('unknownquestiontype', 'question', $thispageurl, $delete);
}
$qtypename = $qtypes[$delete]->local_name();
if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
print_error('cannotdeleteqtypeinuse', 'question', $thispageurl, $qtypename);
}
if ($needed[$delete] > 0) {
print_error('cannotdeleteqtypeneeded', 'question', $thispageurl, $qtypename);
}
// If not yet confirmed, display a confirmation message.
if (!optional_param('confirm', '', PARAM_BOOL)) {
$qtypename = $qtypes[$delete]->local_name();
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename),
new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
$thispageurl);
echo $OUTPUT->footer();
exit;
}
// Do the deletion.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
// Delete any configuration records.
if (!unset_all_config_for_plugin('qtype_' . $delete)) {
echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
}
unset_config($delete . '_disabled', 'question');
unset_config($delete . '_sortorder', 'question');
// Then the tables themselves
drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
// Remove event handlers and dequeue pending events
events_uninstall('qtype_' . $delete);
$a = new stdClass();
$a->qtype = $qtypename;
$a->directory = $qtypes[$delete]->plugin_dir();
echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
echo $OUTPUT->continue_button($thispageurl);
echo $OUTPUT->footer();
exit;
}
// End of process actions ==================================================
// Print the page heading.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
// Set up the table.
$table = new flexible_table('qtypeadmintable');
$table->define_baseurl($thispageurl);
$table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
'availableto', 'delete', 'settings'));
$table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'),
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
get_string('delete'), get_string('settings')));
$table->set_attribute('id', 'qtypes');
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
$table->setup();
// Add a row for each question type.
$createabletypes = question_bank::get_creatable_qtypes();
foreach ($sortedqtypes as $qtypename => $localname) {
$qtype = $qtypes[$qtypename];
$row = array();
// Question icon and name.
$fakequestion = new stdClass;
$fakequestion->qtype = $qtypename;
$icon = print_question_icon($fakequestion, true);
$row[] = $icon . ' ' . $localname;
// Number of questions of this type.
if ($counts[$qtypename]->numquestions + $counts[$qtypename]->numhidden > 0) {
if ($counts[$qtypename]->numhidden > 0) {
$strcount = get_string('numquestionsandhidden', 'question', $counts[$qtypename]);
} else {
$strcount = $counts[$qtypename]->numquestions;
}
if ($canviewreports) {
$row[] = html_writer::link(new moodle_url('/report/questioninstances/index.php',
array('qtype' => $qtypename)), $strcount, array('title' => get_string('showdetails', 'admin')));
} else {
$strcount;
}
} else {
$row[] = 0;
}
// Question version number.
$version = get_config('qtype_' . $qtypename, 'version');
if ($version) {
$row[] = $version;
} else {
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'disabled'));
}
// Other question types required by this one.
$plugin = $pluginmanager->get_plugin_info($qtype->plugin_name());
$requiredtypes = $plugin->get_other_required_plugins();
$strtypes = array();
if (!empty($requiredtypes)) {
foreach ($requiredtypes as $required => $notused) {
$strtypes[] = $pluginmanager->plugin_name($required);
}
$row[] = implode(', ', $strtypes);
} else {
$row[] = '';
}
// Are people allowed to create new questions of this type?
$rowclass = '';
if ($qtype->menu_name()) {
$createable = isset($createabletypes[$qtypename]);
$icons = question_types_enable_disable_icons($qtypename, $createable);
if (!$createable) {
$rowclass = 'dimmed_text';
}
} else {
$icons = $OUTPUT->spacer() . ' ';
}
// Move icons.
$icons .= question_type_icon_html('up', $qtypename, 't/up', get_string('up'), '');
$icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
$row[] = $icons;
// Delete link, if available.
if ($needed[$qtypename]) {
$row[] = '';
} else {
$row[] = html_writer::link(new moodle_url($thispageurl,
array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'),
array('title' => get_string('uninstallqtype', 'question')));
}
// Settings link, if available.
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
if ($settings instanceof admin_externalpage) {
$row[] = html_writer::link($settings->url, get_string('settings'));
} else if ($settings instanceof admin_settingpage) {
$row[] = html_writer::link(new moodle_url('/admin/settings.php',
array('section' => 'qtypesetting' . $qtypename)), get_string('settings'));
} else {
$row[] = '';
}
$table->add_data($row, $rowclass);
}
$table->finish_output();
echo $OUTPUT->footer();
function question_types_enable_disable_icons($qtypename, $createable) {
if ($createable) {
return question_type_icon_html('disable', $qtypename, 'i/hide',
get_string('enabled', 'question'), get_string('disable'));
} else {
return question_type_icon_html('enable', $qtypename, 'i/show',
get_string('disabled', 'question'), get_string('enable'));
}
}
function question_type_icon_html($action, $qtypename, $icon, $alt, $tip) {
global $OUTPUT;
return $OUTPUT->action_icon(new moodle_url('/admin/qtypes.php',
array($action => $qtypename, 'sesskey' => sesskey())),
new pix_icon($icon, $alt, 'moodle', array('title' => '')),
null, array('title' => $tip)) . ' ';
}
+137
View File
@@ -0,0 +1,137 @@
<?PHP // $Id$
// register.php - allows admin to register their site on moodle.org
include("../config.php");
require_login();
if (!isadmin()) {
error("Only the admin can use this page");
}
if (!$site = get_site()) {
redirect("index.php");
}
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
}
if (!$admin = get_admin()) {
error("No admins");
}
if (!$admin->country and $CFG->country) {
$admin->country = $CFG->country;
}
if (empty($CFG->siteidentifier)) { // Unique site identification code
set_config('siteidentifier', random_string(32));
}
/// Print headings
$stradministration = get_string("administration");
$strregistration = get_string("registration");
$strregistrationinfo = get_string("registrationinfo");
print_header("$site->shortname: $strregistration", "$site->fullname",
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
print_heading($strregistration);
print_simple_box($strregistrationinfo, "center", "70%");
echo "<br />";
/// Print the form
print_simple_box_start("center", "", "$THEME->cellheading");
echo "<form name=\"form\" action=\"http://moodle.org/register/\" method=post>\n";
echo "<table cellpadding=9 border=0>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>Moodle URL:</td>\n";
echo "<td><p>$CFG->wwwroot</td>\n";
echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\">\n";
echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\">\n";
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\">\n";
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\">\n";
echo "</td></tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>".get_string("currentversion").":</td>\n";
echo "<td><p>$CFG->release ($CFG->version)</td>\n";
echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\">\n";
echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\">\n";
echo "</td></tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>".get_string("fullsitename").":</td>\n";
echo "<td><p><input size=50 type=\"text\" name=\"sitename\" value=\"$site->fullname\"></td>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>".get_string("country").":</td>\n";
echo "<td><p>";
choose_from_menu (get_list_of_countries(), "country", $admin->country, get_string("selectacountry")."...", "", "");
echo "</td>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p><a href=\"http://moodle.org/sites\" title=\"See the current list of sites\" target=_blank>".get_string("publicdirectory")."</a>:</td>\n";
echo "<td><p>";
$options[0] = get_string("publicdirectory0");
$options[1] = get_string("publicdirectory1");
$options[2] = get_string("publicdirectory2");
choose_from_menu ($options, "public", "2", "", "", "");
unset($options);
echo "</td>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td colspan=2><hr size=1 noshade>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>".get_string("administrator").":</td>\n";
echo "<td><p><input size=50 type=\"text\" name=\"adminname\" value=\"".fullname($admin, true)."\"></td>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>".get_string("email").":</td>\n";
echo "<td><p><input size=50 type=\"text\" name=\"adminemail\" value=\"$admin->email\"></td>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right><p>".get_string("registrationemail")."</a>:</td>\n";
echo "<td><p>\n";
$options[0] = get_string("registrationno");
$options[1] = get_string("registrationyes");
choose_from_menu ($options, "mailme", "1", "", "", "");
unset($options);
echo "</td>\n";
echo "</tr>\n";
echo "<tr valign=top>\n";
echo "<td align=right>&nbsp;</td>\n";
echo "<td><p><input type=\"submit\" value=\"".get_string("registrationsend")."\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
print_simple_box_end();
echo "<br />\n";
print_footer();
?>
@@ -1,92 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/*
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* The administrator is redirect to this page from the hub to confirm that the
* site has been registered. It is an administration page. The administrator
* should be using the same browser during all the registration process.
* This page save the token that the hub gave us, in order to call the hub
* directory later by web service.
*/
require('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
$newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
$url = optional_param('url', '', PARAM_URL);
$hubname = optional_param('hubname', '', PARAM_TEXT);
$token = optional_param('token', '', PARAM_TEXT);
$error = optional_param('error', '', PARAM_ALPHANUM);
admin_externalpage_setup('registrationindex');
if (!empty($error) and $error == 'urlalreadyexist') {
throw new moodle_exception('urlalreadyregistered', 'hub',
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
}
//check that we are waiting a confirmation from this hub, and check that the token is correct
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_unconfirmedhub($url);
if (!empty($registeredhub) and $registeredhub->token == $token) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
$hublink = html_writer::tag('a', $hubname, array('href' => $url));
$registeredhub->token = $newtoken;
$registeredhub->confirmed = 1;
$registeredhub->hubname = $hubname;
$registrationmanager->update_registeredhub($registeredhub);
//display notficiation message
$notificationmessage = $OUTPUT->notification(
get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
echo $notificationmessage;
//display continue button
$registrationpage = new moodle_url('/admin/registration/index.php');
$continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue', 'hub')));
$continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align'));
echo $continuebutton;
if (!extension_loaded('xmlrpc')) {
//display notice about xmlrpc
$xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
$xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
echo $OUTPUT->notification($xmlrpcnotification);
}
echo $OUTPUT->footer();
} else {
throw new moodle_exception('wrongtoken', 'hub',
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
}
-467
View File
@@ -1,467 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/*
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* The forms needed by registration pages.
*/
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
/**
* This form display a unregistration form.
*/
class site_unregistration_form extends moodleform {
public function definition() {
$mform = & $this->_form;
$mform->addElement('header', 'site', get_string('unregister', 'hub'));
$huburl = $this->_customdata['huburl'];
$hubname = $this->_customdata['hubname'];
$unregisterlabel = get_string('unregister', 'hub');
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
' ' . get_string('unpublishalluploadedcourses', 'hub'));
$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_INT);
$mform->addElement('hidden', 'unregistration', 1);
$mform->setType('unregistration', PARAM_INT);
$mform->addElement('hidden', 'huburl', $huburl);
$mform->setType('huburl', PARAM_URL);
$mform->addElement('hidden', 'hubname', $hubname);
$mform->setType('hubname', PARAM_TEXT);
$this->add_action_buttons(true, $unregisterlabel);
}
}
/**
* This form display a clean registration data form.
*/
class site_clean_registration_data_form extends moodleform {
public function definition() {
$mform = & $this->_form;
$mform->addElement('header', 'site', get_string('unregister', 'hub'));
$huburl = $this->_customdata['huburl'];
$hubname = $this->_customdata['hubname'];
$unregisterlabel = get_string('forceunregister', 'hub');
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_INT);
$mform->addElement('hidden', 'unregistration', 1);
$mform->setType('unregistration', PARAM_INT);
$mform->addElement('hidden', 'cleanregdata', 1);
$mform->setType('cleanregdata', PARAM_INT);
$mform->addElement('hidden', 'huburl', $huburl);
$mform->setType('huburl', PARAM_URL);
$mform->addElement('hidden', 'hubname', $hubname);
$mform->setType('hubname', PARAM_TEXT);
$this->add_action_buttons(true, $unregisterlabel);
}
}
/**
* This form display a hub selector.
* The hub list is retrieved from Moodle.org hub directory.
* Also displayed, a text field to enter private hub url + its password
*/
class hub_selector_form extends moodleform {
public function definition() {
global $CFG, $OUTPUT;
$mform = & $this->_form;
$mform->addElement('header', 'site', get_string('selecthub', 'hub'));
//retrieve the hub list on the hub directory by web service
$function = 'hubdirectory_get_hubs';
$params = array();
$serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php";
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, 'publichubdirectory');
try {
$hubs = $xmlrpcclient->call($function, $params);
} catch (Exception $e) {
$error = $OUTPUT->notification(get_string('errorhublisting', 'hub', $e->getMessage()));
$mform->addElement('static', 'errorhub', '', $error);
$hubs = array();
}
//remove moodle.org from the hub list
foreach ($hubs as $key => $hub) {
if ($hub['url'] == HUB_MOODLEORGHUBURL) {
unset($hubs[$key]);
}
}
//Public hub list
$options = array();
foreach ($hubs as $hub) {
//to not display a name longer than 100 character (too big)
if (textlib::strlen($hub['name']) > 100) {
$hubname = textlib::substr($hub['name'], 0, 100);
$hubname = $hubname . "...";
} else {
$hubname = $hub['name'];
}
$options[$hub['url']] = $hubname;
$mform->addElement('hidden', clean_param($hub['url'], PARAM_ALPHANUMEXT), $hubname);
$mform->setType(clean_param($hub['url'], PARAM_ALPHANUMEXT), PARAM_ALPHANUMEXT);
}
if (!empty($hubs)) {
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
$options, array("size" => 15));
}
$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
//Private hub
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
array('class' => 'registration_textfield'));
$mform->addElement('text', 'password', get_string('password'),
array('class' => 'registration_textfield'));
$this->add_action_buttons(false, get_string('selecthub', 'hub'));
}
/**
* Check the unlisted URL is a URL
*/
function validation($data, $files) {
global $CFG;
$errors = parent::validation($data, $files);
$unlistedurl = $this->_form->_submitValues['unlistedurl'];
if (!empty($unlistedurl)) {
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
if (empty($unlistedurltotest)) {
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
}
}
return $errors;
}
}
/**
* The site registration form. Information will be sent to a given hub.
*/
class site_registration_form extends moodleform {
public function definition() {
global $CFG, $DB;
$strrequired = get_string('required');
$mform = & $this->_form;
$huburl = $this->_customdata['huburl'];
$hubname = $this->_customdata['hubname'];
$password = $this->_customdata['password'];
$admin = get_admin();
$site = get_site();
//retrieve config for this hub and set default if they don't exist
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
if ($sitename === false) {
$sitename = format_string($site->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
}
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
if ($sitedescription === false) {
$sitedescription = $site->summary;
}
$contactname = get_config('hub', 'site_contactname_' . $cleanhuburl);
if ($contactname === false) {
$contactname = fullname($admin, true);
}
$contactemail = get_config('hub', 'site_contactemail_' . $cleanhuburl);
if ($contactemail === false) {
$contactemail = $admin->email;
}
$contactphone = get_config('hub', 'site_contactphone_' . $cleanhuburl);
if ($contactphone === false) {
$contactphone = $admin->phone1;
}
$imageurl = get_config('hub', 'site_imageurl_' . $cleanhuburl);
$privacy = get_config('hub', 'site_privacy_' . $cleanhuburl);
$address = get_config('hub', 'site_address_' . $cleanhuburl);
$region = get_config('hub', 'site_region_' . $cleanhuburl);
$country = get_config('hub', 'site_country_' . $cleanhuburl);
if ($country === false) {
$country = $admin->country;
}
$language = get_config('hub', 'site_language_' . $cleanhuburl);
if ($language === false) {
$language = current_language();
}
$geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
$contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
$emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
$coursesnumber = get_config('hub', 'site_coursesnumber_' . $cleanhuburl);
$usersnumber = get_config('hub', 'site_usersnumber_' . $cleanhuburl);
$roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl);
$postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
$questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
$resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
$mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
//hidden parameters
$mform->addElement('hidden', 'huburl', $huburl);
$mform->setType('huburl', PARAM_URL);
$mform->addElement('hidden', 'hubname', $hubname);
$mform->setType('hubname', PARAM_TEXT);
$mform->addElement('hidden', 'password', $password);
$mform->setType('password', PARAM_RAW);
//the input parameters
$mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub'));
$mform->addElement('text', 'name', get_string('sitename', 'hub'),
array('class' => 'registration_textfield'));
$mform->addRule('name', $strrequired, 'required', null, 'client');
$mform->setType('name', PARAM_TEXT);
$mform->setDefault('name', $sitename);
$mform->addHelpButton('name', 'sitename', 'hub');
$options = array();
$registrationmanager = new registration_manager();
$options[HUB_SITENOTPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENOTPUBLISHED);
$options[HUB_SITENAMEPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENAMEPUBLISHED);
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
$mform->setDefault('privacy', $privacy);
$mform->addHelpButton('privacy', 'privacy', 'hub');
unset($options);
$mform->addElement('textarea', 'description', get_string('sitedesc', 'hub'),
array('rows' => 8, 'cols' => 41));
$mform->addRule('description', $strrequired, 'required', null, 'client');
$mform->setDefault('description', $sitedescription);
$mform->setType('description', PARAM_TEXT);
$mform->addHelpButton('description', 'sitedesc', 'hub');
$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
$mform->addHelpButton('urlstring', 'siteurl', 'hub');
$languages = get_string_manager()->get_list_of_languages();
collatorlib::asort($languages);
$mform->addElement('select', 'language', get_string('sitelang', 'hub'),
$languages);
$mform->setType('language', PARAM_ALPHANUMEXT);
$mform->addHelpButton('language', 'sitelang', 'hub');
$mform->setDefault('language', $language);
$mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
$mform->addElement('hidden', 'moodleversion', $CFG->version);
$mform->setType('moodleversion', PARAM_INT);
$mform->addHelpButton('versionstring', 'siteversion', 'hub');
$mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
$mform->addElement('hidden', 'moodlerelease', $CFG->release);
$mform->setType('moodlerelease', PARAM_TEXT);
$mform->addHelpButton('releasestring', 'siterelease', 'hub');
$mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'),
array('rows' => 4, 'cols' => 41));
$mform->setType('address', PARAM_TEXT);
$mform->setDefault('address', $address);
$mform->addHelpButton('address', 'postaladdress', 'hub');
//TODO: use the region array I generated
// $mform->addElement('select', 'region', get_string('selectaregion'), array('-' => '-'));
// $mform->setDefault('region', $region);
$mform->addElement('hidden', 'regioncode', '-');
$mform->setType('regioncode', PARAM_ALPHANUMEXT);
$countries = get_string_manager()->get_list_of_countries();
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
$mform->setDefault('countrycode', $country);
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');
$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
array('class' => 'registration_textfield'));
$mform->setDefault('geolocation', $geolocation);
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
array('class' => 'registration_textfield'));
$mform->addRule('contactname', $strrequired, 'required', null, 'client');
$mform->setType('contactname', PARAM_TEXT);
$mform->setDefault('contactname', $contactname);
$mform->addHelpButton('contactname', 'siteadmin', 'hub');
$mform->addElement('text', 'contactphone', get_string('sitephone', 'hub'),
array('class' => 'registration_textfield'));
$mform->setType('contactphone', PARAM_TEXT);
$mform->addHelpButton('contactphone', 'sitephone', 'hub');
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
array('class' => 'registration_textfield'));
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
$mform->setType('contactemail', PARAM_TEXT);
$mform->setDefault('contactemail', $contactemail);
$mform->addHelpButton('contactemail', 'siteemail', 'hub');
$options = array();
$options[0] = get_string("registrationcontactno");
$options[1] = get_string("registrationcontactyes");
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
$mform->setDefault('contactable', $contactable);
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
unset($options);
$options = array();
$options[0] = get_string("registrationno");
$options[1] = get_string("registrationyes");
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
$mform->setDefault('emailalert', $emailalert);
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
unset($options);
//TODO site logo
$mform->addElement('hidden', 'imageurl', ''); //TODO: temporary
$mform->setType('imageurl', PARAM_URL);
/// Display statistic that are going to be retrieve by the hub
$coursecount = $DB->count_records('course') - 1;
$usercount = $DB->count_records('user', array('deleted' => 0));
$roleassigncount = $DB->count_records('role_assignments');
$postcount = $DB->count_records('forum_posts');
$questioncount = $DB->count_records('question');
$resourcecount = $DB->count_records('resource');
require_once($CFG->dirroot . "/course/lib.php");
$participantnumberaverage = number_format(average_number_of_participants(), 2);
$modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
if (HUB_MOODLEORGHUBURL != $huburl) {
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
$mform->setDefault('courses', true);
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
$mform->addElement('checkbox', 'users', '',
" " . get_string('usersnumber', 'hub', $usercount));
$mform->setDefault('users', true);
$mform->addElement('checkbox', 'roleassignments', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->setDefault('roleassignments', true);
$mform->addElement('checkbox', 'posts', '',
" " . get_string('postsnumber', 'hub', $postcount));
$mform->setDefault('posts', true);
$mform->addElement('checkbox', 'questions', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
$mform->setDefault('questions', true);
$mform->addElement('checkbox', 'resources', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->setDefault('resources', true);
$mform->addElement('checkbox', 'participantnumberaverage', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->setDefault('participantnumberaverage', true);
$mform->addElement('checkbox', 'modulenumberaverage', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->setDefault('modulenumberaverage', true);
} else {
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
$mform->addElement('hidden', 'courses', true);
$mform->setType('courses', PARAM_FLOAT);
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
$mform->addElement('static', 'userslabel', '',
" " . get_string('usersnumber', 'hub', $usercount));
$mform->addElement('hidden', 'users', true);
$mform->setType('users', PARAM_FLOAT);
$mform->addElement('static', 'roleassignmentslabel', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->addElement('hidden', 'roleassignments', true);
$mform->setType('roleassignments', PARAM_FLOAT);
$mform->addElement('static', 'postslabel', '',
" " . get_string('postsnumber', 'hub', $postcount));
$mform->addElement('hidden', 'posts', true);
$mform->setType('posts', PARAM_FLOAT);
$mform->addElement('static', 'questionslabel', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
$mform->addElement('hidden', 'questions', true);
$mform->setType('questions', PARAM_FLOAT);
$mform->addElement('static', 'resourceslabel', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->addElement('hidden', 'resources', true);
$mform->setType('resources', PARAM_FLOAT);
$mform->addElement('static', 'participantnumberaveragelabel', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->addElement('hidden', 'participantnumberaverage', true);
$mform->setType('participantnumberaverage', PARAM_FLOAT);
$mform->addElement('static', 'modulenumberaveragelabel', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->addElement('hidden', 'modulenumberaverage', true);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
}
//check if it's a first registration or update
$hubregistered = $registrationmanager->get_registeredhub($huburl);
if (!empty($hubregistered)) {
$buttonlabel = get_string('updatesite', 'hub',
!empty($hubname) ? $hubname : $huburl);
$mform->addElement('hidden', 'update', true);
$mform->setType('update', PARAM_BOOL);
} else {
$buttonlabel = get_string('registersite', 'hub',
!empty($hubname) ? $hubname : $huburl);
}
$this->add_action_buttons(false, $buttonlabel);
}
}
-68
View File
@@ -1,68 +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/>.
/*
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* Thsi page displays a hub selector or a hub URL + password. Then it will redirect to
* the site registration form (with the selected hub as parameter)
*/
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/' . $CFG->admin . '/registration/forms.php');
admin_externalpage_setup('registrationselector');
$hubselectorform = new hub_selector_form();
$fromform = $hubselectorform->get_data();
//// Redirect to the registration form if an URL has been choosen ////
$selectedhuburl = optional_param('publichub', false, PARAM_URL);
$unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
$password = optional_param('password', '', PARAM_RAW);
if (!empty($unlistedhuburl)) {
if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
$huburl = $unlistedhuburl;
}
} else if (!empty($selectedhuburl)) {
$huburl = $selectedhuburl;
}
//redirect
if (!empty($huburl) and confirm_sesskey()) {
$hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
$params = array('sesskey' => sesskey(), 'huburl' => $huburl,
'password' => $password, 'hubname' => $hubname);
redirect(new moodle_url($CFG->wwwroot."/" . $CFG->admin . "/registration/register.php",
$params));
}
//// OUTPUT ////
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
$hubselectorform->display();
echo $OUTPUT->footer();
-168
View File
@@ -1,168 +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/>.
/*
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* On this page the administrator select if he wants to register on Moodle.org or
* a specific hub
*/
require('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
require_once($CFG->dirroot . '/course/publish/lib.php');
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
admin_externalpage_setup('registrationindex');
$renderer = $PAGE->get_renderer('core', 'register');
$unregistration = optional_param('unregistration', 0, PARAM_INT);
$cleanregdata = optional_param('cleanregdata', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_INT);
$huburl = optional_param('huburl', '', PARAM_URL);
$cancel = optional_param('cancel', null, PARAM_ALPHA);
$registrationmanager = new registration_manager();
$publicationmanager = new course_publish_manager();
$errormessage = '';
if (empty($cancel) and $unregistration and $confirm and confirm_sesskey()) {
$hub = $registrationmanager->get_registeredhub($huburl);
//unpublish course and unregister the site by web service
if (!$cleanregdata) {
//check if we need to unpublish courses
//enrollable courses
$unpublishalladvertisedcourses = optional_param('unpublishalladvertisedcourses', 0, PARAM_INT);
$hubcourseids = array();
if ($unpublishalladvertisedcourses) {
$enrollablecourses = $publicationmanager->get_publications($huburl, null, 1);
if (!empty($enrollablecourses)) {
foreach ($enrollablecourses as $enrollablecourse) {
$hubcourseids[] = $enrollablecourse->hubcourseid;
}
}
}
//downloadable courses
$unpublishalluploadedcourses = optional_param('unpublishalluploadedcourses', 0, PARAM_INT);
if ($unpublishalluploadedcourses) {
$downloadablecourses = $publicationmanager->get_publications($huburl, null, 0);
if (!empty($downloadablecourses)) {
foreach ($downloadablecourses as $downloadablecourse) {
$hubcourseids[] = $downloadablecourse->hubcourseid;
}
}
}
//unpublish the courses by web service
if (!empty($hubcourseids)) {
$function = 'hub_unregister_courses';
$params = array('courseids' => $hubcourseids);
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
try {
$result = $xmlrpcclient->call($function, $params);
//delete the published courses
if (!empty($enrollablecourses)) {
$publicationmanager->delete_hub_publications($huburl, 1);
}
if (!empty($downloadablecourses)) {
$publicationmanager->delete_hub_publications($huburl, 0);
}
} catch (Exception $e) {
$errormessage = $e->getMessage();
$errormessage .= html_writer::empty_tag('br') .
get_string('errorunpublishcourses', 'hub');
$confirm = false;
$cleanregdata = 1;
}
}
}
//course unpublish went ok, unregister the site now
if ($confirm) {
$function = 'hub_unregister_site';
$params = array();
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
try {
$result = $xmlrpcclient->call($function, $params);
} catch (Exception $e) {
if (!$cleanregdata) {
$errormessage = $e->getMessage();
$confirm = false;
$cleanregdata = 1;
}
}
}
//check that we are still processing the unregistration,
//it could have been unset if an exception were previsouly catched
if ($confirm) {
$registrationmanager->delete_registeredhub($huburl);
}
}
echo $OUTPUT->header();
//do not check sesskey if confirm = false because this script is linked into email message
if (!empty($errormessage)) {
echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
}
if (empty($cancel) and $unregistration and !$confirm) {
$hub = $registrationmanager->get_registeredhub($huburl);
echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', $hub->hubname), 3, 'main');
if ($cleanregdata) {
$siteunregistrationform = new site_clean_registration_data_form('',
array('huburl' => $huburl, 'hubname' => $hub->hubname));
} else {
$siteunregistrationform = new site_unregistration_form('',
array('huburl' => $huburl, 'hubname' => $hub->hubname));
}
$siteunregistrationform->display();
} else {
$registeredonmoodleorg = false;
$moodleorghub = $registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL);
if (!empty($moodleorghub)) {
$registeredonmoodleorg = true;
}
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
echo $renderer->registrationselector($registeredonmoodleorg);
if (extension_loaded('xmlrpc')) {
$hubs = $registrationmanager->get_registered_on_hubs();
if (!empty($hubs)) {
echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
echo $renderer->registeredonhublisting($hubs);
}
} else { //display notice about xmlrpc
$xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
$xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
echo $OUTPUT->notification($xmlrpcnotification);
}
}
echo $OUTPUT->footer();
-296
View File
@@ -1,296 +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/>.
//// SITE PRIVACY /////
/**
* Site privacy: private
*/
define('HUB_SITENOTPUBLISHED', 'notdisplayed');
/**
* Site privacy: public
*/
define('HUB_SITENAMEPUBLISHED', 'named');
/**
* Site privacy: public and global
*/
define('HUB_SITELINKPUBLISHED', 'linked');
/**
*
* Site registration library
*
* @package course
* @copyright 2010 Moodle Pty Ltd (http://moodle.com)
* @author Jerome Mouneyrac
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class registration_manager {
/**
* Automatically update the registration on all hubs
*/
public function cron() {
global $CFG;
if (extension_loaded('xmlrpc')) {
//check if the last registration cron update was less than a week ago
$lastcron = get_config('registration', 'crontime');
if ($lastcron === false or $lastcron < strtotime("-7 day")) { //set to a week, see MDL-23704
$function = 'hub_update_site_info';
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
//update all hub where the site is registered on
$hubs = $this->get_registered_on_hubs();
foreach ($hubs as $hub) {
//update the registration
$siteinfo = $this->get_site_info($hub->huburl);
$params = array('siteinfo' => $siteinfo);
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
try {
$result = $xmlrpcclient->call($function, $params);
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
} catch (Exception $e) {
$errorparam = new stdClass();
$errorparam->errormessage = $e->getMessage();
$errorparam->hubname = $hub->hubname;
mtrace(get_string('errorcron', 'hub', $errorparam));
}
}
set_config('crontime', time(), 'registration');
}
} else {
mtrace(get_string('errorcronnoxmlrpc', 'hub'));
}
}
/**
* Return the site secret for a given hub
* site identifier is assigned to Mooch
* each hub has a unique and personal site secret.
* @param string $huburl
* @return string site secret
*/
public function get_site_secret_for_hub($huburl) {
global $DB;
$existingregistration = $DB->get_record('registration_hubs',
array('huburl' => $huburl));
if (!empty($existingregistration)) {
return $existingregistration->secret;
}
if ($huburl == HUB_MOODLEORGHUBURL) {
$siteidentifier = get_site_identifier();
} else {
$siteidentifier = random_string(32) . $_SERVER['HTTP_HOST'];
}
return $siteidentifier;
}
/**
* When the site register on a hub, he must call this function
* @param object $hub where the site is registered on
* @return integer id of the record
*/
public function add_registeredhub($hub) {
global $DB;
$id = $DB->insert_record('registration_hubs', $hub);
return $id;
}
/**
* When a site unregister from a hub, he must call this function
* @param string $huburl the huburl to delete
*/
public function delete_registeredhub($huburl) {
global $DB;
$DB->delete_records('registration_hubs', array('huburl' => $huburl));
}
/**
* Get a hub on which the site is registered for a given url or token
* Mostly use to check if the site is registered on a specific hub
* @param string $huburl
* @param string $token
* @return object the hub
*/
public function get_registeredhub($huburl = null, $token = null) {
global $DB;
$params = array();
if (!empty($huburl)) {
$params['huburl'] = $huburl;
}
if (!empty($token)) {
$params['token'] = $token;
}
$params['confirmed'] = 1;
$token = $DB->get_record('registration_hubs', $params);
return $token;
}
/**
* Get the hub which has not confirmed that the site is registered on,
* but for which a request has been sent
* @param string $huburl
* @return object the hub
*/
public function get_unconfirmedhub($huburl) {
global $DB;
$params = array();
$params['huburl'] = $huburl;
$params['confirmed'] = 0;
$token = $DB->get_record('registration_hubs', $params);
return $token;
}
/**
* Update a registered hub (mostly use to update the confirmation status)
* @param object $communication the hub
*/
public function update_registeredhub($communication) {
global $DB;
$DB->update_record('registration_hubs', $communication);
}
/**
* Return all hubs where the site is registered on
*/
public function get_registered_on_hubs() {
global $DB;
$hubs = $DB->get_records('registration_hubs', array('confirmed' => 1));
return $hubs;
}
/**
* Return site information for a specific hub
* @param string $huburl
* @return array site info
*/
public function get_site_info($huburl) {
global $CFG, $DB;
$siteinfo = array();
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
$siteinfo['name'] = get_config('hub', 'site_name_' . $cleanhuburl);
$siteinfo['description'] = get_config('hub', 'site_description_' . $cleanhuburl);
$siteinfo['contactname'] = get_config('hub', 'site_contactname_' . $cleanhuburl);
$siteinfo['contactemail'] = get_config('hub', 'site_contactemail_' . $cleanhuburl);
$siteinfo['contactphone'] = get_config('hub', 'site_contactphone_' . $cleanhuburl);
$siteinfo['imageurl'] = get_config('hub', 'site_imageurl_' . $cleanhuburl);
$siteinfo['privacy'] = get_config('hub', 'site_privacy_' . $cleanhuburl);
$siteinfo['street'] = get_config('hub', 'site_address_' . $cleanhuburl);
$siteinfo['regioncode'] = get_config('hub', 'site_region_' . $cleanhuburl);
$siteinfo['countrycode'] = get_config('hub', 'site_country_' . $cleanhuburl);
$siteinfo['geolocation'] = get_config('hub', 'site_geolocation_' . $cleanhuburl);
$siteinfo['contactable'] = get_config('hub', 'site_contactable_' . $cleanhuburl);
$siteinfo['emailalert'] = get_config('hub', 'site_emailalert_' . $cleanhuburl);
if (get_config('hub', 'site_coursesnumber_' . $cleanhuburl) == -1) {
$coursecount = -1;
} else {
$coursecount = $DB->count_records('course') - 1;
}
$siteinfo['courses'] = $coursecount;
if (get_config('hub', 'site_usersnumber_' . $cleanhuburl) == -1) {
$usercount = -1;
} else {
$usercount = $DB->count_records('user', array('deleted' => 0));
}
$siteinfo['users'] = $usercount;
if (get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl) == -1) {
$roleassigncount = -1;
} else {
$roleassigncount = $DB->count_records('role_assignments');
}
$siteinfo['enrolments'] = $roleassigncount;
if (get_config('hub', 'site_postsnumber_' . $cleanhuburl) == -1) {
$postcount = -1;
} else {
$postcount = $DB->count_records('forum_posts');
}
$siteinfo['posts'] = $postcount;
if (get_config('hub', 'site_questionsnumber_' . $cleanhuburl) == -1) {
$questioncount = -1;
} else {
$questioncount = $DB->count_records('question');
}
$siteinfo['questions'] = $questioncount;
if (get_config('hub', 'site_resourcesnumber_' . $cleanhuburl) == -1) {
$resourcecount = -1;
} else {
$resourcecount = $DB->count_records('resource');
}
$siteinfo['resources'] = $resourcecount;
//TODO
require_once($CFG->dirroot . "/course/lib.php");
if (get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl) == -1) {
$participantnumberaverage = -1;
} else {
$participantnumberaverage = average_number_of_participants();
}
$siteinfo['participantnumberaverage'] = $participantnumberaverage;
if (get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl) == -1) {
$modulenumberaverage = -1;
} else {
$modulenumberaverage = average_number_of_courses_modules();
}
$siteinfo['modulenumberaverage'] = $modulenumberaverage;
$siteinfo['language'] = get_config('hub', 'site_language_' . $cleanhuburl);
$siteinfo['moodleversion'] = $CFG->version;
$siteinfo['moodlerelease'] = $CFG->release;
$siteinfo['url'] = $CFG->wwwroot;
return $siteinfo;
}
/**
* Retrieve the site privacy string matching the define value
* @param string $privacy must match the define into moodlelib.php
* @return string
*/
public function get_site_privacy_string($privacy) {
switch ($privacy) {
case HUB_SITENOTPUBLISHED:
$privacystring = get_string('siteprivacynotpublished', 'hub');
break;
case HUB_SITENAMEPUBLISHED:
$privacystring = get_string('siteprivacypublished', 'hub');
break;
case HUB_SITELINKPUBLISHED:
$privacystring = get_string('siteprivacylinked', 'hub');
break;
}
if (empty($privacystring)) {
throw new moodle_exception('unknownprivacy');
}
return $privacystring;
}
}
?>
-149
View File
@@ -1,149 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/*
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* This page displays the site registration form.
* It handles redirection to the hub to continue the registration workflow process.
* It also handles update operation by web service.
*/
require_once('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
require_once($CFG->dirroot . '/webservice/lib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
admin_externalpage_setup('registrationindex');
$huburl = required_param('huburl', PARAM_URL);
$huburl = rtrim($huburl, "/");
$password = optional_param('password', '', PARAM_TEXT);
$hubname = optional_param('hubname', '', PARAM_TEXT);
if (!confirm_sesskey()) {
throw new moodle_exception('missingparameter');
}
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_registeredhub($huburl);
$siteregistrationform = new site_registration_form('',
array('alreadyregistered' => !empty($registeredhub->token),
'huburl' => $huburl, 'hubname' => $hubname,
'password' => $password));
$fromform = $siteregistrationform->get_data();
if (!empty($fromform) and confirm_sesskey()) {
//save the settings
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
set_config('site_contactname_' . $cleanhuburl, $fromform->contactname, 'hub');
set_config('site_contactemail_' . $cleanhuburl, $fromform->contactemail, 'hub');
set_config('site_contactphone_' . $cleanhuburl, $fromform->contactphone, 'hub');
set_config('site_imageurl_' . $cleanhuburl, $fromform->imageurl, 'hub');
set_config('site_privacy_' . $cleanhuburl, $fromform->privacy, 'hub');
set_config('site_address_' . $cleanhuburl, $fromform->address, 'hub');
set_config('site_region_' . $cleanhuburl, $fromform->regioncode, 'hub');
set_config('site_country_' . $cleanhuburl, $fromform->countrycode, 'hub');
set_config('site_language_' . $cleanhuburl, $fromform->language, 'hub');
set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub');
set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, 'hub');
set_config('site_emailalert_' . $cleanhuburl, $fromform->emailalert, 'hub');
set_config('site_coursesnumber_' . $cleanhuburl, $fromform->courses, 'hub');
set_config('site_usersnumber_' . $cleanhuburl, $fromform->users, 'hub');
set_config('site_roleassignmentsnumber_' . $cleanhuburl, $fromform->roleassignments, 'hub');
set_config('site_postsnumber_' . $cleanhuburl, $fromform->posts, 'hub');
set_config('site_questionsnumber_' . $cleanhuburl, $fromform->questions, 'hub');
set_config('site_resourcesnumber_' . $cleanhuburl, $fromform->resources, 'hub');
set_config('site_modulenumberaverage_' . $cleanhuburl, $fromform->modulenumberaverage, 'hub');
set_config('site_participantnumberaverage_' . $cleanhuburl, $fromform->participantnumberaverage, 'hub');
}
/////// UPDATE ACTION ////////
// update the hub registration
$update = optional_param('update', 0, PARAM_INT);
if ($update and confirm_sesskey()) {
//update the registration
$function = 'hub_update_site_info';
$siteinfo = $registrationmanager->get_site_info($huburl);
$params = array('siteinfo' => $siteinfo);
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
try {
$result = $xmlrpcclient->call($function, $params);
} catch (Exception $e) {
$error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
}
}
/////// FORM REGISTRATION ACTION //////
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
$params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
if (empty($unconfirmedhub)) {
//we save the token into the communication table in order to have a reference
$unconfirmedhub = new stdClass();
$unconfirmedhub->token = $registrationmanager->get_site_secret_for_hub($huburl);
$unconfirmedhub->secret = $unconfirmedhub->token;
$unconfirmedhub->huburl = $huburl;
$unconfirmedhub->hubname = $hubname;
$unconfirmedhub->confirmed = 0;
$unconfirmedhub->id = $registrationmanager->add_registeredhub($unconfirmedhub);
}
$params['token'] = $unconfirmedhub->token;
$params['url'] = $CFG->wwwroot;
redirect(new moodle_url($huburl . '/local/hub/siteregistration.php', $params));
}
}
/////// OUTPUT SECTION /////////////
echo $OUTPUT->header();
//Display update notification result
if (!empty($registeredhub->confirmed)) {
if (!empty($result)) {
echo $OUTPUT->notification(get_string('siteregistrationupdated', 'hub'), 'notifysuccess');
}
}
if (!empty($error)) {
echo $error;
}
$siteregistrationform->display();
echo $OUTPUT->footer();
-129
View File
@@ -1,129 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/**
* Registration renderer.
* @package moodle
* @subpackage registration
* @copyright 2010 Moodle Pty Ltd (http://moodle.com)
* @author Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_register_renderer extends plugin_renderer_base {
/**
* Display a box message confirming a site registration (add or update)
* @param string $confirmationmessage
* @return string
*/
public function registration_confirmation($confirmationmessage) {
$linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'),
array('href' => new moodle_url('/local/hub/index.php')));
$message = $confirmationmessage . html_writer::empty_tag('br') . $linktositelist;
return $this->output->box($message);
}
/**
* Display the page to register on Moodle.org or on a specific hub
*/
public function registrationselector($updatemoodleorg = false) {
global $CFG;
$table = new html_table();
$table->head = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
$table->size = array('50%', '50%');
//$table->attributes['class'] = 'registerindextable';
//Moodle.org information cell
$moodleorgcell = get_string('moodleorgregistrationdetail', 'hub');
$moodleorgcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
$moodleorgcell = html_writer::tag('div', $moodleorgcell, array('class' => 'justifytext'));
//Specific hub information cell
$specifichubcell = get_string('specifichubregistrationdetail', 'hub');
$specifichubcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
$specifichubcell = html_writer::tag('div', $specifichubcell, array('class' => 'justifytext'));
//add information cells
$cells = array($moodleorgcell, $specifichubcell);
$row = new html_table_row($cells);
$table->data[] = $row;
//Moodle.org button cell
$registeronmoodleorgurl = new moodle_url("/" . $CFG->admin . "/registration/register.php",
array('sesskey' => sesskey(), 'huburl' => HUB_MOODLEORGHUBURL
, 'hubname' => 'Moodle.org'));
$registeronmoodleorgbutton = new single_button($registeronmoodleorgurl,
$updatemoodleorg ? get_string('updatesite', 'hub', 'Moodle.org') : get_string('registeronmoodleorg', 'hub'));
$registeronmoodleorgbutton->class = 'centeredbutton';
$registeronmoodleorgbuttonhtml = $this->output->render($registeronmoodleorgbutton);
$moodleorgcell = $registeronmoodleorgbuttonhtml;
//Specific hub button cell
$registeronspecifichuburl = new moodle_url("/" . $CFG->admin . "/registration/hubselector.php",
array('sesskey' => sesskey()));
$registeronspecifichubbutton = new single_button($registeronspecifichuburl,
get_string('registeronspecifichub', 'hub'));
$registeronspecifichubbutton->class = 'centeredbutton';
$registeronspecifichubbuttonhtml = $this->output->render($registeronspecifichubbutton);
$specifichubcell = $registeronspecifichubbuttonhtml;
//add button cells
$cells = array($moodleorgcell, $specifichubcell);
$row = new html_table_row($cells);
$table->data[] = $row;
return html_writer::table($table);
}
/**
* Display the listing of registered on hub
*/
public function registeredonhublisting($hubs) {
global $CFG;
$table = new html_table();
$table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
$table->size = array('80%', '20%');
foreach ($hubs as $hub) {
if ($hub->huburl == HUB_MOODLEORGHUBURL) {
$hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname);
}
$hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl));
$hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));
$unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php",
array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
'unregistration' => 1));
$unregisterbutton = new single_button($unregisterhuburl,
get_string('unregister', 'hub'));
$unregisterbutton->class = 'centeredbutton';
$unregisterbuttonhtml = $this->output->render($unregisterbutton);
//add button cells
$cells = array($hublinkcell, $unregisterbuttonhtml);
$row = new html_table_row($cells);
$table->data[] = $row;
}
return html_writer::table($table);
}
}
-76
View File
@@ -1,76 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/*
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* The administrator is redirect to this page from the hub to renew a registration
* process because
*/
require('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
$url = optional_param('url', '', PARAM_URL);
$hubname = optional_param('hubname', '', PARAM_TEXT);
$token = optional_param('token', '', PARAM_TEXT);
admin_externalpage_setup('registrationindex');
//check that we are waiting a confirmation from this hub, and check that the token is correct
$registrationmanager = new registration_manager();
$registeredhub = $registrationmanager->get_unconfirmedhub($url);
if (!empty($registeredhub) and $registeredhub->token == $token) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
$hublink = html_writer::tag('a', $hubname, array('href' => $url));
$registrationmanager->delete_registeredhub($url);
//Mooch case, need to recreate the siteidentifier
if ($url == HUB_MOODLEORGHUBURL) {
$CFG->siteidentifier = null;
get_site_identifier();
}
$deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
$button = new single_button(new moodle_url('/admin/registration/index.php'),
get_string('restartregistration', 'hub'));
$button->class = 'restartregbutton';
echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button),
array('class' => 'mdl-align'));
echo $OUTPUT->footer();
} else {
throw new moodle_exception('wrongtoken', 'hub',
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
}
-928
View File
@@ -1,928 +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/>.
/**
* Renderer for core_admin subsystem
*
* @package core
* @subpackage admin
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/pluginlib.php');
/**
* Standard HTML output renderer for core_admin subsystem
*/
class core_admin_renderer extends plugin_renderer_base {
/**
* Display the 'Do you acknowledge the terms of the GPL' page. The first page
* during install.
* @return string HTML to output.
*/
public function install_licence_page() {
global $CFG;
$output = '';
$copyrightnotice = text_to_html(get_string('gpl3'));
$copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack
$continue = new single_button(new moodle_url('/admin/index.php', array('lang'=>$CFG->lang, 'agreelicense'=>1)), get_string('continue'), 'get');
$output .= $this->header();
$output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment');
$output .= $this->heading(get_string('copyrightnotice'));
$output .= $this->box($copyrightnotice, 'copyrightnotice');
$output .= html_writer::empty_tag('br');
$output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License");
$output .= $this->footer();
return $output;
}
/**
* Display the 'environment check' page that is displayed during install.
* @param int $maturity
* @param boolean $envstatus final result of the check (true/false)
* @param array $environment_results array of results gathered
* @param string $release moodle release
* @return string HTML to output.
*/
public function install_environment_page($maturity, $envstatus, $environment_results, $release) {
global $CFG;
$output = '';
$output .= $this->header();
$output .= $this->maturity_warning($maturity);
$output .= $this->heading("Moodle $release");
$output .= $this->release_notes_link();
$output .= $this->environment_check_table($envstatus, $environment_results);
if (!$envstatus) {
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'lang' => $CFG->lang)));
} else {
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('agreelicense'=>1, 'confirmrelease'=>1, 'lang'=>$CFG->lang)));
}
$output .= $this->footer();
return $output;
}
/**
* Display the 'You are about to upgrade Moodle' page. The first page
* during upgrade.
* @param string $strnewversion
* @param int $maturity
* @return string HTML to output.
*/
public function upgrade_confirm_page($strnewversion, $maturity) {
$output = '';
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
$cancelurl = new moodle_url('index.php');
$output .= $this->header();
$output .= $this->maturity_warning($maturity);
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
$output .= $this->footer();
return $output;
}
/**
* Display the environment page during the upgrade process.
* @param string $release
* @param boolean $envstatus final result of env check (true/false)
* @param array $environment_results array of results gathered
* @return string HTML to output.
*/
public function upgrade_environment_page($release, $envstatus, $environment_results) {
global $CFG;
$output = '';
$output .= $this->header();
$output .= $this->heading("Moodle $release");
$output .= $this->release_notes_link();
$output .= $this->environment_check_table($envstatus, $environment_results);
if (!$envstatus) {
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
} else {
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
if (empty($CFG->skiplangupgrade) and current_language() !== 'en') {
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
}
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
}
$output .= $this->footer();
return $output;
}
/**
* Display the upgrade page that lists all the plugins that require attention.
* @param plugin_manager $pluginman provides information about the plugins.
* @param int $version the version of the Moodle code from version.php.
* @param bool $showallplugins
* @param moodle_url $reloadurl
* @param moodle_url $continueurl
* @return string HTML to output.
*/
public function upgrade_plugin_check_page(plugin_manager $pluginman, $version, $showallplugins, $reloadurl, $continueurl) {
$output = '';
$output .= $this->header();
$output .= $this->box_start('generalbox');
$output .= $this->container(get_string('pluginchecknotice', 'core_plugin'), 'generalbox', 'notice');
$output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins));
$output .= $this->box_end();
$output .= $this->upgrade_reload($reloadurl);
if ($pluginman->all_plugins_ok($version)) {
$button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get');
$button->class = 'continuebutton';
$output .= $this->render($button);
} else {
$output .= $this->box(get_string('pluginschecktodo', 'admin'), 'environmentbox errorbox');
}
$output .= $this->footer();
return $output;
}
/**
* Display the admin notifications page.
* @param int $maturity
* @param bool $insecuredataroot warn dataroot is invalid
* @param bool $errorsdisplayed warn invalid dispaly error setting
* @param bool $cronoverdue warn cron not running
* @param bool $dbproblems warn db has problems
* @param bool $maintenancemode warn in maintenance mode
* @return string HTML to output.
*/
public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
$cronoverdue, $dbproblems, $maintenancemode) {
$output = '';
$output .= $this->header();
$output .= $this->maturity_info($maturity);
$output .= $this->insecure_dataroot_warning($insecuredataroot);
$output .= $this->display_errors_warning($errorsdisplayed);
$output .= $this->cron_overdue_warning($cronoverdue);
$output .= $this->db_problems($dbproblems);
$output .= $this->maintenance_mode_warning($maintenancemode);
//////////////////////////////////////////////////////////////////////////////////////////////////
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
$output .= $this->moodle_copyright();
//////////////////////////////////////////////////////////////////////////////////////////////////
$output .= $this->footer();
return $output;
}
/**
* Display the plugin management page (admin/plugins.php).
* @param plugin_manager $pluginman
* @return string HTML to output.
*/
public function plugin_management_page(plugin_manager $pluginman) {
$output = '';
$output .= $this->header();
$output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
$output .= $this->box_start('generalbox');
$output .= $this->plugins_control_panel($pluginman);
$output .= $this->box_end();
$output .= $this->footer();
return $output;
}
/**
* Display the plugin management page (admin/environment.php).
* @param array $versions
* @param string $version
* @param boolean $envstatus final result of env check (true/false)
* @param array $environment_results array of results gathered
* @return string HTML to output.
*/
public function environment_check_page($versions, $version, $envstatus, $environment_results) {
$output = '';
$output .= $this->header();
// Print the component download link
$output .= html_writer::tag('div', html_writer::link(
new moodle_url('/admin/environment.php', array('action' => 'updatecomponent', 'sesskey' => sesskey())),
get_string('updatecomponent', 'admin')),
array('class' => 'reportlink'));
// Heading.
$output .= $this->heading(get_string('environment', 'admin'));
// Box with info and a menu to choose the version.
$output .= $this->box_start();
$output .= html_writer::tag('div', get_string('adminhelpenvironment'));
$select = new single_select(new moodle_url('/admin/environment.php'), 'version', $versions, $version, null);
$select->label = get_string('moodleversion');
$output .= $this->render($select);
$output .= $this->box_end();
// The results
$output .= $this->environment_check_table($envstatus, $environment_results);
$output .= $this->footer();
return $output;
}
/**
* Output a warning message, of the type that appears on the admin notifications page.
* @param string $message the message to display.
* @param string $type type class
* @return string HTML to output.
*/
protected function warning($message, $type = 'warning') {
return $this->box($message, 'generalbox admin' . $type);
}
/**
* Render an appropriate message if dataroot is insecure.
* @param bool $insecuredataroot
* @return string HTML to output.
*/
protected function insecure_dataroot_warning($insecuredataroot) {
global $CFG;
if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
} else {
return '';
}
}
/**
* Render an appropriate message if dataroot is insecure.
* @param bool $errorsdisplayed
* @return string HTML to output.
*/
protected function display_errors_warning($errorsdisplayed) {
if (!$errorsdisplayed) {
return '';
}
return $this->warning(get_string('displayerrorswarning', 'admin'));
}
/**
* Render an appropriate message if cron has not been run recently.
* @param bool $cronoverdue
* @return string HTML to output.
*/
public function cron_overdue_warning($cronoverdue) {
if (!$cronoverdue) {
return '';
}
return $this->warning(get_string('cronwarning', 'admin') . '&nbsp;' .
$this->help_icon('cron', 'admin'));
}
/**
* Render an appropriate message if there are any problems with the DB set-up.
* @param bool $dbproblems
* @return string HTML to output.
*/
public function db_problems($dbproblems) {
if (!$dbproblems) {
return '';
}
return $this->warning($dbproblems);
}
/**
* Render an appropriate message if the site in in maintenance mode.
* @param bool $maintenancemode
* @return string HTML to output.
*/
public function maintenance_mode_warning($maintenancemode) {
if (!$maintenancemode) {
return '';
}
$url = new moodle_url('/admin/settings.php', array('section' => 'maintenancemode'));
$url = $url->out(); // get_string() does not support objects in params
return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url));
}
/**
* Display a warning about installing development code if necesary.
* @param int $maturity
* @return string HTML to output.
*/
protected function maturity_warning($maturity) {
if ($maturity == MATURITY_STABLE) {
return ''; // No worries.
}
$maturitylevel = get_string('maturity' . $maturity, 'admin');
return $this->box(
$this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
$this->container($this->doc_link('admin/versions', get_string('morehelp'))),
'generalbox maturitywarning');
}
/**
* Output the copyright notice.
* @return string HTML to output.
*/
protected function moodle_copyright() {
global $CFG;
//////////////////////////////////////////////////////////////////////////////////////////////////
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
$copyrighttext = '<a href="http://moodle.org/">Moodle</a> '.
'<a href="http://docs.moodle.org/dev/Releases" title="'.$CFG->version.'">'.$CFG->release.'</a><br />'.
'Copyright &copy; 1999 onwards, Martin Dougiamas<br />'.
'and <a href="http://docs.moodle.org/dev/Credits">many other contributors</a>.<br />'.
'<a href="http://docs.moodle.org/dev/License">GNU Public License</a>';
//////////////////////////////////////////////////////////////////////////////////////////////////
return $this->box($copyrighttext, 'copyright');
}
/**
* Display a warning about installing development code if necesary.
* @param int $maturity
* @return string HTML to output.
*/
protected function maturity_info($maturity) {
if ($maturity == MATURITY_STABLE) {
return ''; // No worries.
}
$maturitylevel = get_string('maturity' . $maturity, 'admin');
return $this->box(
get_string('maturitycoreinfo', 'admin', $maturitylevel) . ' ' .
$this->doc_link('admin/versions', get_string('morehelp')),
'generalbox adminwarning maturityinfo');
}
/**
* Display a link to the release notes.
* @return string HTML to output.
*/
protected function release_notes_link() {
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
return $this->box($releasenoteslink, 'generalbox releasenoteslink');
}
/**
* Display the reload link that appears on several upgrade/install pages.
* @return string HTML to output.
*/
function upgrade_reload($url) {
return html_writer::empty_tag('br') .
html_writer::tag('div',
html_writer::link($url, $this->pix_icon('i/reload', '') .
get_string('reload'), array('title' => get_string('reload'))),
array('class' => 'continuebutton')) . html_writer::empty_tag('br');
}
/**
* Displays all known plugins and information about their installation or upgrade
*
* This default implementation renders all plugins into one big table. The rendering
* options support:
* (bool)full = false: whether to display up-to-date plugins, too
*
* @param plugin_manager $pluginman provides information about the plugins.
* @param int $version the version of the Moodle code from version.php.
* @param array $options rendering options
* @return string HTML code
*/
public function plugins_check_table(plugin_manager $pluginman, $version, array $options = null) {
$plugininfo = $pluginman->get_plugins();
if (empty($plugininfo)) {
return '';
}
if (empty($options)) {
$options = array(
'full' => false,
);
}
$table = new html_table();
$table->id = 'plugins-check';
$table->head = array(
get_string('displayname', 'core_plugin'),
get_string('rootdir', 'core_plugin'),
get_string('source', 'core_plugin'),
get_string('versiondb', 'core_plugin'),
get_string('versiondisk', 'core_plugin'),
get_string('requires', 'core_plugin'),
get_string('status', 'core_plugin'),
);
$table->colclasses = array(
'displayname', 'rootdir', 'source', 'versiondb', 'versiondisk', 'requires', 'status',
);
$table->data = array();
$numofhighlighted = array(); // number of highlighted rows per this subsection
foreach ($plugininfo as $type => $plugins) {
$header = new html_table_cell($pluginman->plugintype_name_plural($type));
$header->header = true;
$header->colspan = count($table->head);
$header = new html_table_row(array($header));
$header->attributes['class'] = 'plugintypeheader type-' . $type;
$numofhighlighted[$type] = 0;
if (empty($plugins) and $options['full']) {
$msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
$msg->colspan = count($table->head);
$row = new html_table_row(array($msg));
$row->attributes['class'] .= 'msg msg-noneinstalled';
$table->data[] = $header;
$table->data[] = $row;
continue;
}
$plugintyperows = array();
foreach ($plugins as $name => $plugin) {
$row = new html_table_row();
$row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
$icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
} else {
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
}
$displayname = $icon . ' ' . $plugin->displayname;
$displayname = new html_table_cell($displayname);
$rootdir = new html_table_cell($plugin->get_dir());
if ($isstandard = $plugin->is_standard()) {
$row->attributes['class'] .= ' standard';
$source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
} else {
$row->attributes['class'] .= ' extension';
$source = new html_table_cell(get_string('sourceext', 'core_plugin'));
}
$versiondb = new html_table_cell($plugin->versiondb);
$versiondisk = new html_table_cell($plugin->versiondisk);
$statuscode = $plugin->get_status();
$row->attributes['class'] .= ' status-' . $statuscode;
$status = new html_table_cell(get_string('status_' . $statuscode, 'core_plugin'));
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
$statusisboring = in_array($statuscode, array(
plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
$dependenciesok = $pluginman->are_dependencies_satisfied(
$plugin->get_other_required_plugins());
if ($isstandard and $statusisboring and $dependenciesok) {
if (empty($options['full'])) {
continue;
}
} else {
$numofhighlighted[$type]++;
}
$row->cells = array($displayname, $rootdir, $source,
$versiondb, $versiondisk, $requires, $status);
$plugintyperows[] = $row;
}
if (empty($numofhighlighted[$type]) and empty($options['full'])) {
continue;
}
$table->data[] = $header;
$table->data = array_merge($table->data, $plugintyperows);
}
$sumofhighlighted = array_sum($numofhighlighted);
if ($sumofhighlighted == 0) {
$out = $this->output->container_start('nonehighlighted', 'plugins-check-info');
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
if (empty($options['full'])) {
$out .= html_writer::link(new moodle_url('/admin/index.php',
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
get_string('nonehighlightedinfo', 'core_plugin'));
}
$out .= $this->output->container_end();
} else {
$out = $this->output->container_start('somehighlighted', 'plugins-check-info');
$out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
if (empty($options['full'])) {
$out .= html_writer::link(new moodle_url('/admin/index.php',
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
get_string('somehighlightedinfo', 'core_plugin'));
}
$out .= $this->output->container_end();
}
if ($sumofhighlighted > 0 or $options['full']) {
$out .= html_writer::table($table);
}
return $out;
}
/**
* Formats the information that needs to go in the 'Requires' column.
* @param plugin_information $plugin the plugin we are rendering the row for.
* @param plugin_manager $pluginman provides data on all the plugins.
* @param string $version
* @return string HTML code
*/
protected function required_column(plugin_information $plugin, plugin_manager $pluginman, $version) {
$requires = array();
if (!empty($plugin->versionrequires)) {
if ($plugin->versionrequires <= $version) {
$class = 'requires-ok';
} else {
$class = 'requires-failed';
}
$requires[] = html_writer::tag('li',
get_string('moodleversion', 'core_plugin', $plugin->versionrequires),
array('class' => $class));
}
foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
$ok = true;
$otherplugin = $pluginman->get_plugin_info($component);
if (is_null($otherplugin)) {
$ok = false;
} else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
$ok = false;
}
if ($ok) {
$class = 'requires-ok';
} else {
$class = 'requires-failed';
}
if ($requiredversion != ANY_VERSION) {
$str = 'otherpluginversion';
} else {
$str = 'otherplugin';
}
$requires[] = html_writer::tag('li',
get_string($str, 'core_plugin',
array('component' => $component, 'version' => $requiredversion)),
array('class' => $class));
}
if (!$requires) {
return '';
}
return html_writer::tag('ul', implode("\n", $requires));
}
/**
* Displays all known plugins and links to manage them
*
* This default implementation renders all plugins into one big table.
*
* @param plugin_manager $pluginman provides information about the plugins.
* @return string HTML code
*/
public function plugins_control_panel(plugin_manager $pluginman) {
$plugininfo = $pluginman->get_plugins();
if (empty($plugininfo)) {
return '';
}
$table = new html_table();
$table->id = 'plugins-control-panel';
$table->head = array(
get_string('displayname', 'core_plugin'),
get_string('systemname', 'core_plugin'),
get_string('source', 'core_plugin'),
get_string('version', 'core_plugin'),
get_string('availability', 'core_plugin'),
get_string('settings', 'core_plugin'),
get_string('uninstall','core_plugin'),
);
$table->colclasses = array(
'displayname', 'systemname', 'source', 'version', 'availability', 'settings', 'uninstall',
);
foreach ($plugininfo as $type => $plugins) {
$header = new html_table_cell($pluginman->plugintype_name_plural($type));
$header->header = true;
$header->colspan = count($table->head);
$header = new html_table_row(array($header));
$header->attributes['class'] = 'plugintypeheader type-' . $type;
$table->data[] = $header;
if (empty($plugins)) {
$msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
$msg->colspan = count($table->head);
$row = new html_table_row(array($msg));
$row->attributes['class'] .= 'msg msg-noneinstalled';
$table->data[] = $row;
continue;
}
foreach ($plugins as $name => $plugin) {
$row = new html_table_row();
$row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
$icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
} else {
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
}
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
$row->attributes['class'] .= ' missingfromdisk';
} else {
$msg = '';
}
$displayname = $icon . ' ' . $plugin->displayname . ' ' . $msg;
$displayname = new html_table_cell($displayname);
$systemname = new html_table_cell($plugin->type . '_' . $plugin->name);
if ($plugin->is_standard()) {
$row->attributes['class'] .= ' standard';
$source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
} else {
$row->attributes['class'] .= ' extension';
$source = new html_table_cell(get_string('sourceext', 'core_plugin'));
}
$version = new html_table_cell($plugin->versiondb);
$isenabled = $plugin->is_enabled();
if (is_null($isenabled)) {
$availability = new html_table_cell('');
} else if ($isenabled) {
$row->attributes['class'] .= ' enabled';
$icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin'));
$availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin'));
} else {
$row->attributes['class'] .= ' disabled';
$icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin'));
$availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin'));
}
$settingsurl = $plugin->get_settings_url();
if (is_null($settingsurl)) {
$settings = new html_table_cell('');
} else {
$settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin'));
$settings = new html_table_cell($settings);
}
$uninstallurl = $plugin->get_uninstall_url();
$requriedby = $pluginman->other_plugins_that_require($plugin->component);
if (is_null($uninstallurl)) {
$uninstall = new html_table_cell('');
} else if ($requriedby) {
$uninstall = new html_table_cell(get_string('requiredby', 'core_plugin', implode(', ', $requriedby)));
$uninstall->attributes['class'] = 'requiredby';
} else {
$uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
$uninstall = new html_table_cell($uninstall);
}
$row->cells = array(
$displayname, $systemname, $source, $version, $availability, $settings, $uninstall
);
$table->data[] = $row;
}
}
return html_writer::table($table);
}
/**
* This function will render one beautiful table with all the environmental
* configuration and how it suits Moodle needs.
*
* @param boolean $result final result of the check (true/false)
* @param array $environment_results array of results gathered
* @return string HTML to output.
*/
public function environment_check_table($result, $environment_results) {
global $CFG;
// Table headers
$servertable = new html_table();//table for server checks
$servertable->head = array(
get_string('name'),
get_string('info'),
get_string('report'),
get_string('status'),
);
$servertable->align = array('center', 'center', 'left', 'center');
$servertable->wrap = array('nowrap', '', '', 'nowrap');
$servertable->size = array('10', 10, '100%', '10');
$servertable->attributes['class'] = 'environmenttable generaltable';
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
$othertable = new html_table();//table for custom checks
$othertable->head = array(
get_string('info'),
get_string('report'),
get_string('status'),
);
$othertable->align = array('center', 'left', 'center');
$othertable->wrap = array('', '', 'nowrap');
$othertable->size = array(10, '100%', '10');
$othertable->attributes['class'] = 'environmenttable generaltable';
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
// Iterate over each environment_result
$continue = true;
foreach ($environment_results as $environment_result) {
$errorline = false;
$warningline = false;
$stringtouse = '';
if ($continue) {
$type = $environment_result->getPart();
$info = $environment_result->getInfo();
$status = $environment_result->getStatus();
$error_code = $environment_result->getErrorCode();
// Process Report field
$rec = new stdClass();
// Something has gone wrong at parsing time
if ($error_code) {
$stringtouse = 'environmentxmlerror';
$rec->error_code = $error_code;
$status = get_string('error');
$errorline = true;
$continue = false;
}
if ($continue) {
if ($rec->needed = $environment_result->getNeededVersion()) {
// We are comparing versions
$rec->current = $environment_result->getCurrentVersion();
if ($environment_result->getLevel() == 'required') {
$stringtouse = 'environmentrequireversion';
} else {
$stringtouse = 'environmentrecommendversion';
}
} else if ($environment_result->getPart() == 'custom_check') {
// We are checking installed & enabled things
if ($environment_result->getLevel() == 'required') {
$stringtouse = 'environmentrequirecustomcheck';
} else {
$stringtouse = 'environmentrecommendcustomcheck';
}
} else if ($environment_result->getPart() == 'php_setting') {
if ($status) {
$stringtouse = 'environmentsettingok';
} else if ($environment_result->getLevel() == 'required') {
$stringtouse = 'environmentmustfixsetting';
} else {
$stringtouse = 'environmentshouldfixsetting';
}
} else {
if ($environment_result->getLevel() == 'required') {
$stringtouse = 'environmentrequireinstall';
} else {
$stringtouse = 'environmentrecommendinstall';
}
}
// Calculate the status value
if ($environment_result->getBypassStr() != '') { //Handle bypassed result (warning)
$status = get_string('bypassed');
$warningline = true;
} else if ($environment_result->getRestrictStr() != '') { //Handle restricted result (error)
$status = get_string('restricted');
$errorline = true;
} else {
if ($status) { //Handle ok result (ok)
$status = get_string('ok');
} else {
if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
$status = get_string('check');
$warningline = true;
} else { //Handle error result (error)
$status = get_string('check');
$errorline = true;
}
}
}
}
// Build the text
$linkparts = array();
$linkparts[] = 'admin/environment';
$linkparts[] = $type;
if (!empty($info)){
$linkparts[] = $info;
}
if (empty($CFG->docroot)) {
$report = get_string($stringtouse, 'admin', $rec);
} else {
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
}
// Format error or warning line
if ($errorline || $warningline) {
$messagetype = $errorline? 'error':'warn';
} else {
$messagetype = 'ok';
}
$status = '<span class="'.$messagetype.'">'.$status.'</span>';
// Here we'll store all the feedback found
$feedbacktext = '';
// Append the feedback if there is some
$feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), $messagetype);
//Append the bypass if there is some
$feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'warn');
//Append the restrict if there is some
$feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'error');
$report .= $feedbacktext;
// Add the row to the table
if ($environment_result->getPart() == 'custom_check'){
$otherdata[$messagetype][] = array ($info, $report, $status);
} else {
$serverdata[$messagetype][] = array ($type, $info, $report, $status);
}
}
}
//put errors first in
$servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
$othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
// Print table
$output = '';
$output .= $this->heading(get_string('serverchecks', 'admin'));
$output .= html_writer::table($servertable);
if (count($othertable->data)){
$output .= $this->heading(get_string('customcheck', 'admin'));
$output .= html_writer::table($othertable);
}
// Finally, if any error has happened, print the summary box
if (!$result) {
$output .= $this->box(get_string('environmenterrortodo', 'admin'), 'environmentbox errorbox');
}
return $output;
}
}
-134
View File
@@ -1,134 +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/>.
/**
* Provides an overview of installed reports
*
* Displays the list of found reports, their version (if found) and
* a link to delete the report.
*
* The code is based on admin/localplugins.php by David Mudrak.
*
* @package admin
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
admin_externalpage_setup('managereports');
$delete = optional_param('delete', '', PARAM_PLUGIN);
$confirm = optional_param('confirm', '', PARAM_BOOL);
/// If data submitted, then process and store.
if (!empty($delete) and confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('reports'));
if (!$confirm) {
if (get_string_manager()->string_exists('pluginname', 'report_' . $delete)) {
$strpluginname = get_string('pluginname', 'report_' . $delete);
} else {
$strpluginname = $delete;
}
echo $OUTPUT->confirm(get_string('reportsdeleteconfirm', 'admin', $strpluginname),
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
$PAGE->url);
echo $OUTPUT->footer();
die();
} else {
uninstall_plugin('report', $delete);
$a = new stdclass();
$a->name = $delete;
$pluginlocation = get_plugin_types();
$a->directory = $pluginlocation['report'] . '/' . $delete;
echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
echo $OUTPUT->continue_button($PAGE->url);
echo $OUTPUT->footer();
die();
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('reports'));
/// Print the table of all installed report plugins
$table = new flexible_table('reportplugins_administration_table');
$table->define_columns(array('name', 'version', 'delete'));
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
$table->define_baseurl($PAGE->url);
$table->set_attribute('id', 'reportplugins');
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
$table->setup();
$plugins = array();
foreach (get_plugin_list('report') as $plugin => $plugindir) {
if (get_string_manager()->string_exists('pluginname', 'report_' . $plugin)) {
$strpluginname = get_string('pluginname', 'report_' . $plugin);
} else {
$strpluginname = $plugin;
}
$plugins[$plugin] = $strpluginname;
}
collatorlib::asort($plugins);
$like = $DB->sql_like('plugin', '?', true, true, false, '|');
$params = array('report|_%');
$installed = $DB->get_records_select('config_plugins', "$like AND name = 'version'", $params);
$versions = array();
foreach ($installed as $config) {
$name = preg_replace('/^report_/', '', $config->plugin);
$versions[$name] = $config->value;
if (!isset($plugins[$name])) {
$plugins[$name] = $name;
}
}
foreach ($plugins as $plugin => $name) {
$delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
$delete = html_writer::link($delete, get_string('delete'));
if (!isset($versions[$plugin])) {
if (file_exists("$CFG->dirroot/report/$plugin/version.php")) {
// not installed yet
$version = '?';
} else {
// no version info available
$version = '-';
}
} else {
$version = $versions[$plugin];
if (file_exists("$CFG->dirroot/report/$plugin")) {
$version = $versions[$plugin];
} else {
// somebody removed plugin without uninstall
$name = '<span class="notifyproblem">'.$name.' ('.get_string('missingfromdisk').')</span>';
$version = $versions[$plugin];
}
}
$table->add_data(array($name, $version, $delete));
}
$table->print_html();
echo $OUTPUT->footer();
-359
View File
@@ -1,359 +0,0 @@
<?php
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->dirroot . '/repository/lib.php');
require_once($CFG->libdir . '/adminlib.php');
$repository = optional_param('repos', '', PARAM_FORMAT);
$action = optional_param('action', '', PARAM_ALPHA);
$sure = optional_param('sure', '', PARAM_ALPHA);
$display = true; // fall through to normal display
$pagename = 'managerepositories';
if ($action == 'edit') {
$pagename = 'repositorysettings' . $repository;
} else if ($action == 'delete') {
$pagename = 'repositorydelete';
} else if (($action == 'newon') || ($action == 'newoff')) {
$pagename = 'repositorynew';
}
// Need to remember this for form
$formaction = $action;
// Check what visibility to show the new repository
if ($action == 'newon') {
$action = 'new';
$visible = true;
} else if ($action == 'newoff') {
$action = 'new';
$visible = false;
}
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
admin_externalpage_setup($pagename);
$sesskeyurl = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php?sesskey=' . sesskey();
$baseurl = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
$configstr = get_string('manage', 'repository');
$return = true;
/**
* Helper function that generates a moodle_url object
* relevant to the repository
*/
function repository_action_url($repository) {
global $baseurl;
return new moodle_url($baseurl, array('sesskey'=>sesskey(), 'repos'=>$repository));
}
if (($action == 'edit') || ($action == 'new')) {
$pluginname = '';
if ($action == 'edit') {
$repositorytype = repository::get_type_by_typename($repository);
$classname = 'repository_' . $repositorytype->get_typename();
$configs = call_user_func(array($classname, 'get_type_option_names'));
$plugin = $repositorytype->get_typename();
// looking for instance to edit plugin name
$instanceoptions = call_user_func(array($classname, 'get_instance_option_names'));
if (empty($instanceoptions)) {
$params = array();
$params['type'] = $plugin;
$instances = repository::get_instances($params);
if ($instance = array_pop($instances)) {
// use the one form db record
$pluginname = $instance->instance->name;
}
}
} else {
$repositorytype = null;
$plugin = $repository;
$typeid = $repository;
}
$PAGE->set_pagetype('admin-repository-' . $plugin);
// display the edit form for this instance
$mform = new repository_type_form('', array('pluginname'=>$pluginname, 'plugin' => $plugin, 'instance' => $repositorytype, 'action' => $formaction));
$fromform = $mform->get_data();
//detect if we create a new type without config (in this case if don't want to display a setting page during creation)
$nosettings = false;
if ($action == 'new') {
$adminconfignames = repository::static_function($repository, 'get_type_option_names');
$nosettings = empty($adminconfignames);
}
// end setup, begin output
if ($mform->is_cancelled()){
redirect($baseurl);
} else if (!empty($fromform) || $nosettings) {
require_sesskey();
if ($action == 'edit') {
$settings = array();
foreach($configs as $config) {
if (!empty($fromform->$config)) {
$settings[$config] = $fromform->$config;
} else {
// if the config name is not appear in $fromform
// empty this config value
$settings[$config] = '';
}
}
$instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');
if (!empty($instanceoptionnames)) {
if (array_key_exists('enablecourseinstances', $fromform)) {
$settings['enablecourseinstances'] = $fromform->enablecourseinstances;
}
else {
$settings['enablecourseinstances'] = 0;
}
if (array_key_exists('enableuserinstances', $fromform)) {
$settings['enableuserinstances'] = $fromform->enableuserinstances;
}
else {
$settings['enableuserinstances'] = 0;
}
}
$success = $repositorytype->update_options($settings);
} else {
$type = new repository_type($plugin, (array)$fromform, $visible);
$type->create();
$success = true;
$data = data_submitted();
}
if ($success) {
// configs saved
redirect($baseurl);
} else {
print_error('instancenotsaved', 'repository', $baseurl);
}
exit;
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('configplugin', 'repository_'.$plugin));
$displaysettingform = true;
if ($action == 'edit') {
$typeoptionnames = repository::static_function($repository, 'get_type_option_names');
$instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');
if (empty($typeoptionnames) && empty($instanceoptionnames)) {
$displaysettingform = false;
}
}
if ($displaysettingform){
$OUTPUT->box_start();
$mform->display();
$OUTPUT->box_end();
}
$return = false;
// Display instances list and creation form
if ($action == 'edit') {
$instanceoptionnames = repository::static_function($repository, 'get_instance_option_names');
if (!empty($instanceoptionnames)) {
repository::display_instances_list(get_context_instance(CONTEXT_SYSTEM), $repository);
}
}
}
} else if ($action == 'show') {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
$repositorytype = repository::get_type_by_typename($repository);
if (empty($repositorytype)) {
print_error('invalidplugin', 'repository', '', $repository);
}
$repositorytype->update_visibility(true);
$return = true;
} else if ($action == 'hide') {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
$repositorytype = repository::get_type_by_typename($repository);
if (empty($repositorytype)) {
print_error('invalidplugin', 'repository', '', $repository);
}
$repositorytype->update_visibility(false);
$return = true;
} else if ($action == 'delete') {
$repositorytype = repository::get_type_by_typename($repository);
if ($sure) {
$PAGE->set_pagetype('admin-repository-' . $repository);
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
if ($repositorytype->delete()) {
redirect($baseurl);
} else {
print_error('instancenotdeleted', 'repository', $baseurl);
}
exit;
} else {
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('confirmremove', 'repository', $repositorytype->get_readablename()), $sesskeyurl . '&action=delete&repos=' . $repository . '&sure=yes', $baseurl);
$return = false;
}
} else if ($action == 'moveup') {
$repositorytype = repository::get_type_by_typename($repository);
$repositorytype->move_order('up');
} else if ($action == 'movedown') {
$repositorytype = repository::get_type_by_typename($repository);
$repositorytype->move_order('down');
} else {
// If page is loaded directly
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manage', 'repository'));
// Get strings that are used
$strshow = get_string('on', 'repository');
$strhide = get_string('off', 'repository');
$strdelete = get_string('disabled', 'repository');
$actionchoicesforexisting = array(
'show' => $strshow,
'hide' => $strhide,
'delete' => $strdelete
);
$actionchoicesfornew = array(
'newon' => $strshow,
'newoff' => $strhide,
'delete' => $strdelete
);
$output = '';
$output .= $OUTPUT->box_start('generalbox');
// Set strings that are used multiple times
$settingsstr = get_string('settings');
$disablestr = get_string('disable');
// Table to list plug-ins
$table = new html_table();
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
$table->align = array('left', 'center', 'center', 'center', 'center');
$table->data = array();
// Get list of used plug-ins
$instances = repository::get_types();
if (!empty($instances)) {
// Array to store plugins being used
$alreadyplugins = array();
$totalinstances = count($instances);
$updowncount = 1;
foreach ($instances as $i) {
$settings = '';
$typename = $i->get_typename();
// Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
$typeoptionnames = repository::static_function($typename, 'get_type_option_names');
$instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
// Calculate number of instances in order to display them for the Moodle administrator
if (!empty($instanceoptionnames)) {
$params = array();
$params['context'] = array(get_system_context());
$params['onlyvisible'] = false;
$params['type'] = $typename;
$admininstancenumber = count(repository::static_function($typename, 'get_instances', $params));
// site instances
$admininstancenumbertext = get_string('instancesforsite', 'repository', $admininstancenumber);
$params['context'] = array();
$instances = repository::static_function($typename, 'get_instances', $params);
$courseinstances = array();
$userinstances = array();
foreach ($instances as $instance) {
if ($instance->context->contextlevel == CONTEXT_COURSE) {
$courseinstances[] = $instance;
} else if ($instance->context->contextlevel == CONTEXT_USER) {
$userinstances[] = $instance;
}
}
// course instances
$instancenumber = count($courseinstances);
$courseinstancenumbertext = get_string('instancesforcourses', 'repository', $instancenumber);
// user private instances
$instancenumber = count($userinstances);
$userinstancenumbertext = get_string('instancesforusers', 'repository', $instancenumber);
} else {
$admininstancenumbertext = "";
$courseinstancenumbertext = "";
$userinstancenumbertext = "";
}
$settings .= '<a href="' . $sesskeyurl . '&amp;action=edit&amp;repos=' . $typename . '">' . $settingsstr .'</a>';
$settings .= $OUTPUT->container_start('mdl-left');
$settings .= '<br/>';
$settings .= $admininstancenumbertext;
$settings .= '<br/>';
$settings .= $courseinstancenumbertext;
$settings .= '<br/>';
$settings .= $userinstancenumbertext;
$settings .= $OUTPUT->container_end();
}
// Get the current visibility
if ($i->get_visible()) {
$currentaction = 'show';
} else {
$currentaction = 'hide';
}
$select = new single_select(repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));
// Display up/down link
$updown = '';
$spacer = $OUTPUT->spacer(array('height'=>15, 'width'=>15)); // should be done with CSS instead
if ($updowncount > 1) {
$updown .= "<a href=\"$sesskeyurl&amp;action=moveup&amp;repos=".$typename."\">";
$updown .= "<img src=\"" . $OUTPUT->pix_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
}
else {
$updown .= $spacer;
}
if ($updowncount < $totalinstances) {
$updown .= "<a href=\"$sesskeyurl&amp;action=movedown&amp;repos=".$typename."\">";
$updown .= "<img src=\"" . $OUTPUT->pix_url('t/down') . "\" alt=\"down\" /></a>";
}
else {
$updown .= $spacer;
}
$updowncount++;
$table->data[] = array($i->get_readablename(), $OUTPUT->render($select), $updown, $settings);
if (!in_array($typename, $alreadyplugins)) {
$alreadyplugins[] = $typename;
}
}
}
// Get all the plugins that exist on disk
$plugins = get_plugin_list('repository');
if (!empty($plugins)) {
foreach ($plugins as $plugin => $dir) {
// Check that it has not already been listed
if (!in_array($plugin, $alreadyplugins)) {
$select = new single_select(repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '');
}
}
}
$output .= html_writer::table($table);
$output .= $OUTPUT->box_end();
print $output;
$return = false;
}
if ($return) {
redirect($baseurl);
}
echo $OUTPUT->footer();
-132
View File
@@ -1,132 +0,0 @@
<?php
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->dirroot . '/repository/lib.php');
require_once($CFG->libdir . '/adminlib.php');
// id of repository
$edit = optional_param('edit', 0, PARAM_INT);
$new = optional_param('new', '', PARAM_FORMAT);
$hide = optional_param('hide', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$sure = optional_param('sure', '', PARAM_ALPHA);
$type = optional_param('type', '', PARAM_PLUGIN);
$context = get_context_instance(CONTEXT_SYSTEM);
$pagename = 'repositorycontroller';
if ($edit){
$pagename = 'repositoryinstanceedit';
} else if ($delete) {
$pagename = 'repositorydelete';
} else if ($new) {
$pagename = 'repositoryinstancenew';
}
admin_externalpage_setup($pagename);
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/repositoryinstance.php?sesskey=" . sesskey();
$baseurl = "$CFG->wwwroot/$CFG->admin/repository.php?session=". sesskey() .'&action=edit&repos=';
if ($new) {
$baseurl .= $new;
}
else {
$baseurl .= $type;
}
$return = true;
if (!empty($edit) || !empty($new)) {
if (!empty($edit)) {
$instance = repository::get_instance($edit);
$instancetype = repository::get_type_by_id($instance->options['typeid']);
$classname = 'repository_' . $instancetype->get_typename();
$configs = $instance->get_instance_option_names();
$plugin = $instancetype->get_typename();
$typeid = $instance->options['typeid'];
} else {
$plugin = $new;
$typeid = $new;
$instance = null;
}
// display the edit form for this instance
$mform = new repository_instance_form('', array('plugin' => $plugin, 'typeid' => $typeid, 'instance' => $instance, 'contextid' => $context->id));
// end setup, begin output
if ($mform->is_cancelled()){
redirect($baseurl);
exit;
} else if ($fromform = $mform->get_data()){
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
if ($edit) {
$settings = array();
$settings['name'] = $fromform->name;
if (!$instance->readonly) {
foreach($configs as $config) {
if (isset($fromform->$config)) {
$settings[$config] = $fromform->$config;
} else {
$settings[$config] = null;
}
}
}
$success = $instance->set_option($settings);
} else {
$success = repository::static_function($plugin, 'create', $plugin, 0, get_system_context(), $fromform);
$data = data_submitted();
}
if ($success) {
redirect($baseurl);
} else {
print_error('instancenotsaved', 'repository', $baseurl);
}
exit;
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('configplugin', 'repository_'.$plugin));
echo $OUTPUT->box_start();
$mform->display();
echo $OUTPUT->box_end();
$return = false;
}
} else if (!empty($hide)) {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
$instance = repository::get_type_by_typename($hide);
$instance->hide();
$return = true;
} else if (!empty($delete)) {
$instance = repository::get_instance($delete);
//if you try to delete an instance set as readonly, display an error message
if ($instance->readonly) {
throw new repository_exception('readonlyinstance', 'repository');
}
if ($sure) {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
if ($instance->delete()) {
$deletedstr = get_string('instancedeleted', 'repository');
redirect($baseurl, $deletedstr, 3);
} else {
print_error('instancenotdeleted', 'repository', $baseurl);
}
exit;
}
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('confirmdelete', 'repository', $instance->name), "$sesskeyurl&type=$type'&delete=$delete'&sure=yes", "$CFG->wwwroot/$CFG->admin/repositoryinstance.php?session=". sesskey());
$return = false;
}
if (!empty($return)) {
redirect($baseurl);
}
echo $OUTPUT->footer();
-45
View File
@@ -1,45 +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/>.
/**
* Resets the emoticons mapping into the default value
*
* @package core
* @copyright 2010 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('resetemoticons');
$confirm = optional_param('confirm', false, PARAM_BOOL);
if (!$confirm or !confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('confirmation', 'admin'));
echo $OUTPUT->confirm(get_string('emoticonsreset', 'admin'),
new moodle_url($PAGE->url, array('confirm' => 1)),
new moodle_url('/admin/settings.php', array('section' => 'htmlsettings')));
echo $OUTPUT->footer();
die();
}
$manager = get_emoticon_manager();
set_config('emoticons', $manager->encode_stored_config($manager->default_emoticons()));
redirect(new moodle_url('/admin/settings.php', array('section' => 'htmlsettings')));
-158
View File
@@ -1,158 +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/>.
/**
* Lets you site administrators
*
* @package core
* @subpackage role
* @copyright 2010 Petr Skoda (skodak) http://skodak.org
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
$confirmadd = optional_param('confirmadd', 0, PARAM_INT);
$confirmdel = optional_param('confirmdel', 0, PARAM_INT);
$PAGE->set_url('/admin/roles/admins.php');
admin_externalpage_setup('admins');
if (!is_siteadmin()) {
die;
}
$admisselector = new admins_existing_selector();
$admisselector->set_extra_fields(array('username', 'email'));
$potentialadmisselector = new admins_potential_selector();
$potentialadmisselector->set_extra_fields(array('username', 'email'));
if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
if ($userstoadd = $potentialadmisselector->get_selected_users()) {
$user = reset($userstoadd);
$username = fullname($user) . " ($user->username, $user->email)";
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('confirmaddadmin', 'role', $username), new moodle_url('/admin/roles/admins.php', array('confirmadd'=>$user->id, 'sesskey'=>sesskey())), $PAGE->url);
echo $OUTPUT->footer();
die;
}
} else if (optional_param('remove', false, PARAM_BOOL) and confirm_sesskey()) {
if ($userstoremove = $admisselector->get_selected_users()) {
$user = reset($userstoremove);
if ($USER->id == $user->id) {
//can not remove self
} else {
$username = fullname($user) . " ($user->username, $user->email)";
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('confirmdeladmin', 'role', $username), new moodle_url('/admin/roles/admins.php', array('confirmdel'=>$user->id, 'sesskey'=>sesskey())), $PAGE->url);
echo $OUTPUT->footer();
die;
}
}
} else if (optional_param('main', false, PARAM_BOOL) and confirm_sesskey()) {
if ($newmain = $admisselector->get_selected_users()) {
$newmain = reset($newmain);
$newmain = $newmain->id;
$admins = array();
foreach(explode(',', $CFG->siteadmins) as $admin) {
$admin = (int)$admin;
if ($admin) {
$admins[$admin] = $admin;
}
}
if (isset($admins[$newmain])) {
unset($admins[$newmain]);
array_unshift($admins, $newmain);
set_config('siteadmins', implode(',', $admins));
redirect($PAGE->url);
}
}
} else if ($confirmadd and confirm_sesskey()) {
$admins = array();
foreach(explode(',', $CFG->siteadmins) as $admin) {
$admin = (int)$admin;
if ($admin) {
$admins[$admin] = $admin;
}
}
$admins[$confirmadd] = $confirmadd;
set_config('siteadmins', implode(',', $admins));
redirect($PAGE->url);
} else if ($confirmdel and confirm_sesskey() and $confirmdel != $USER->id) {
$admins = array();
foreach(explode(',', $CFG->siteadmins) as $admin) {
$admin = (int)$admin;
if ($admin) {
$admins[$admin] = $admin;
}
}
unset($admins[$confirmdel]);
set_config('siteadmins', implode(',', $admins));
redirect($PAGE->url);
}
/// Print header
echo $OUTPUT->header();
?>
<div id="addadmisform">
<h3 class="main"><?php print_string('manageadmins', 'role'); ?></h3>
<form id="assignform" method="post" action="<?php echo $PAGE->url ?>">
<div>
<input type="hidden" name="sesskey" value="<?php p(sesskey()); ?>" />
<table class="generaltable generalbox groupmanagementtable boxaligncenter" summary="">
<tr>
<td id='existingcell'>
<p>
<label for="removeselect"><?php print_string('existingadmins', 'role'); ?></label>
</p>
<?php $admisselector->display(); ?>
</td>
<td id='buttonscell'>
<p class="arrow_button">
<input name="add" id="add" type="submit" value="<?php echo $OUTPUT->larrow().'&nbsp;'.get_string('add'); ?>" title="<?php print_string('add'); ?>" /><br />
<input name="remove" id="remove" type="submit" value="<?php echo get_string('remove').'&nbsp;'.$OUTPUT->rarrow(); ?>" title="<?php print_string('remove'); ?>" />
<input name="main" id="main" type="submit" value="<?php echo get_string('mainadminset', 'role'); ?>" title="<?php print_string('mainadminset', 'role'); ?>" />
</p>
</td>
<td id='potentialcell'>
<p>
<label for="addselect"><?php print_string('users'); ?></label>
</p>
<?php $potentialadmisselector->display(); ?>
</td>
</tr>
</table>
</div>
</form>
</div>
<?php
//this must be after calling display() on the selectors so their setup JS executes first
//////$PAGE->requires->js_function_call('init_add_remove_admis_page');
echo $OUTPUT->footer();
-74
View File
@@ -1,74 +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/>.
/**
* Allow overriding of roles by other roles
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
$mode = required_param('mode', PARAM_ACTION);
$classformode = array(
'assign' => 'role_allow_assign_page',
'override' => 'role_allow_override_page',
'switch' => 'role_allow_switch_page'
);
if (!isset($classformode[$mode])) {
print_error('invalidmode', '', '', $mode);
}
$baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
admin_externalpage_setup('defineroles', '', array(), $baseurl);
$syscontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/role:manage', $syscontext);
$controller = new $classformode[$mode]();
if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
$controller->process_submission();
mark_context_dirty($syscontext->path);
add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
redirect($baseurl);
}
$controller->load_current_settings();
// Display the editing form.
echo $OUTPUT->header();
$currenttab = $mode;
require('managetabs.php');
$table = $controller->get_table();
echo $OUTPUT->box($controller->get_intro_text());
echo '<form action="' . $baseurl . '" method="post">';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
echo html_writer::table($table);
echo '<div class="buttons"><input type="submit" name="submit" value="'.get_string('savechanges').'"/>';
echo '</div></form>';
echo $OUTPUT->footer();
-312
View File
@@ -1,312 +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/>.
/**
* Lets you assign roles to users in a particular context.
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
define("MAX_USERS_TO_LIST_PER_ROLE", 10);
$contextid = required_param('contextid',PARAM_INT);
$roleid = optional_param('roleid', 0, PARAM_INT);
list($context, $course, $cm) = get_context_info_array($contextid);
$url = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
} else {
$course = $SITE;
}
}
// security
require_login($course, false, $cm);
require_capability('moodle/role:assign', $context);
$PAGE->set_url($url);
$PAGE->set_context($context);
$contextname = print_context_name($context);
$courseid = $course->id;
// These are needed early because of tabs.php
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
$overridableroles = get_overridable_roles($context, ROLENAME_BOTH);
// Make sure this user can assign this role
if ($roleid && !isset($assignableroles[$roleid])) {
$a = new stdClass;
$a->roleid = $roleid;
$a->context = $contextname;
print_error('cannotassignrolehere', '', get_context_url($context), $a);
}
// Work out an appropriate page title.
if ($roleid) {
$a = new stdClass;
$a->role = $assignableroles[$roleid];
$a->context = $contextname;
$title = get_string('assignrolenameincontext', 'role', $a);
} else {
if ($isfrontpage) {
$title = get_string('frontpageroles', 'admin');
} else {
$title = get_string('assignrolesin', 'role', $contextname);
}
}
// Process any incoming role assignments before printing the header.
if ($roleid) {
// Create the user selector objects.
$options = array('context' => $context, 'roleid' => $roleid);
$potentialuserselector = roles_get_potential_user_selector($context, 'addselect', $options);
$currentuserselector = new existing_role_holders('removeselect', $options);
// Process incoming role assignments
$errors = array();
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
$userstoassign = $potentialuserselector->get_selected_users();
if (!empty($userstoassign)) {
foreach ($userstoassign as $adduser) {
$allow = true;
if ($allow) {
role_assign($roleid, $adduser->id, $context->id);
}
}
$potentialuserselector->invalidate_selected_users();
$currentuserselector->invalidate_selected_users();
$rolename = $assignableroles[$roleid];
add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
// Counts have changed, so reload.
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
}
}
// Process incoming role unassignments
if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
$userstounassign = $currentuserselector->get_selected_users();
if (!empty($userstounassign)) {
foreach ($userstounassign as $removeuser) {
//unassign only roles that are added manually, no messing with other components!!!
role_unassign($roleid, $removeuser->id, $context->id, '');
}
$potentialuserselector->invalidate_selected_users();
$currentuserselector->invalidate_selected_users();
$rolename = $assignableroles[$roleid];
add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
// Counts have changed, so reload.
list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
}
}
}
$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
switch ($context->contextlevel) {
case CONTEXT_SYSTEM:
admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
break;
case CONTEXT_USER:
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
break;
case CONTEXT_COURSE:
if ($isfrontpage) {
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
} else {
$PAGE->set_heading($course->fullname);
}
break;
case CONTEXT_MODULE:
$PAGE->set_heading(print_context_name($context, false));
$PAGE->set_cacheable(false);
break;
case CONTEXT_BLOCK:
$PAGE->set_heading($PAGE->course->fullname);
break;
}
echo $OUTPUT->header();
// Print heading.
echo $OUTPUT->heading_with_help($title, 'assignroles', 'role');
if ($roleid) {
// Show UI for assigning a particular role to users.
// Print a warning if we are assigning system roles.
if ($context->contextlevel == CONTEXT_SYSTEM) {
echo $OUTPUT->box(get_string('globalroleswarning', 'role'));
}
// Print the form.
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
?>
<form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<table summary="" class="roleassigntable generaltable generalbox boxaligncenter" cellspacing="0">
<tr>
<td id="existingcell">
<p><label for="removeselect"><?php print_string('extusers', 'role'); ?></label></p>
<?php $currentuserselector->display() ?>
</td>
<td id="buttonscell">
<div id="addcontrols">
<input name="add" id="add" type="submit" value="<?php echo $OUTPUT->larrow().'&nbsp;'.get_string('add'); ?>" title="<?php print_string('add'); ?>" /><br />
</div>
<div id="removecontrols">
<input name="remove" id="remove" type="submit" value="<?php echo get_string('remove').'&nbsp;'.$OUTPUT->rarrow(); ?>" title="<?php print_string('remove'); ?>" />
</div>
</td>
<td id="potentialcell">
<p><label for="addselect"><?php print_string('potusers', 'role'); ?></label></p>
<?php $potentialuserselector->display() ?>
</td>
</tr>
</table>
</div></form>
<?php
$PAGE->requires->js_init_call('M.core_role.init_add_assign_page');
if (!empty($errors)) {
$msg = '<p>';
foreach ($errors as $e) {
$msg .= $e.'<br />';
}
$msg .= '</p>';
echo $OUTPUT->box_start();
echo $OUTPUT->notification($msg);
echo $OUTPUT->box_end();
}
// Print a form to swap roles, and a link back to the all roles list.
echo '<div class="backlink">';
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
$select->label = get_string('assignanotherrole', 'role');
echo $OUTPUT->render($select);
$backurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'role') . '</a></p>';
echo '</div>';
} else if (empty($assignableroles)) {
// Print a message that there are no roles that can me assigned here.
echo $OUTPUT->heading(get_string('notabletoassignroleshere', 'role'), 3);
} else {
// Show UI for choosing a role to assign.
// Print a warning if we are assigning system roles.
if ($context->contextlevel == CONTEXT_SYSTEM) {
echo $OUTPUT->box(get_string('globalroleswarning', 'role'));
}
// Print instruction
echo $OUTPUT->heading(get_string('chooseroletoassign', 'role'), 3);
// Get the names of role holders for roles with between 1 and MAX_USERS_TO_LIST_PER_ROLE users,
// and so determine whether to show the extra column.
$roleholdernames = array();
$strmorethanmax = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
$showroleholders = false;
foreach ($assignableroles as $roleid => $notused) {
$roleusers = '';
if (0 < $assigncounts[$roleid] && $assigncounts[$roleid] <= MAX_USERS_TO_LIST_PER_ROLE) {
$roleusers = get_role_users($roleid, $context, false, 'u.id, u.lastname, u.firstname');
if (!empty($roleusers)) {
$strroleusers = array();
foreach ($roleusers as $user) {
$strroleusers[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '" >' . fullname($user) . '</a>';
}
$roleholdernames[$roleid] = implode('<br />', $strroleusers);
$showroleholders = true;
}
} else if ($assigncounts[$roleid] > MAX_USERS_TO_LIST_PER_ROLE) {
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
$roleholdernames[$roleid] = '<a href="'.$assignurl.'">'.$strmorethanmax.'</a>';
} else {
$roleholdernames[$roleid] = '';
}
}
// Print overview table
$table = new html_table();
$table->tablealign = 'center';
$table->width = '60%';
$table->head = array(get_string('role'), get_string('description'), get_string('userswiththisrole', 'role'));
$table->wrap = array('nowrap', '', 'nowrap');
$table->align = array('left', 'left', 'center');
if ($showroleholders) {
$table->headspan = array(1, 1, 2);
$table->wrap[] = 'nowrap';
$table->align[] = 'left';
}
foreach ($assignableroles as $roleid => $rolename) {
$description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
$assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
$row = array('<a href="'.$assignurl.'">'.$rolename.'</a>',
$description, $assigncounts[$roleid]);
if ($showroleholders) {
$row[] = $roleholdernames[$roleid];
}
$table->data[] = $row;
}
echo html_writer::table($table);
if ($context->contextlevel > CONTEXT_USER) {
echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
echo html_writer::end_tag('div');
}
}
echo $OUTPUT->footer();
-160
View File
@@ -1,160 +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/>.
/**
* Shows the result of has_capability for every capability for a user in a context.
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
$contextid = required_param('contextid',PARAM_INT);
list($context, $course, $cm) = get_context_info_array($contextid);
$url = new moodle_url('/admin/roles/check.php', array('contextid' => $contextid));
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
} else {
$course = $SITE;
}
}
// security first
require_login($course, false, $cm);
if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $context)) {
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
}
$PAGE->set_url($url);
$PAGE->set_context($context);
$courseid = $course->id;
$contextname = print_context_name($context);
// Get the user_selector we will need.
// Teachers within a course just get to see the same list of people they can
// assign roles to. Admins (people with moodle/role:manage) can run this report for any user.
$options = array('context' => $context, 'roleid' => 0);
if (has_capability('moodle/role:manage', $context)) {
$userselector = new potential_assignees_course_and_above('reportuser', $options);
} else {
$userselector = roles_get_potential_user_selector($context, 'reportuser', $options);
}
$userselector->set_multiselect(false);
$userselector->set_rows(10);
// Work out an appropriate page title.
$title = get_string('checkpermissionsin', 'role', $contextname);
$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
switch ($context->contextlevel) {
case CONTEXT_SYSTEM:
admin_externalpage_setup('checkpermissions', '', array('contextid' => $contextid));
break;
case CONTEXT_USER:
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
break;
case CONTEXT_COURSE:
if ($isfrontpage) {
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid), $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php');
} else {
$PAGE->set_heading($course->fullname);
}
break;
case CONTEXT_MODULE:
$PAGE->set_heading(print_context_name($context, false));
$PAGE->set_cacheable(false);
break;
case CONTEXT_BLOCK:
$PAGE->set_heading($PAGE->course->fullname);
break;
}
echo $OUTPUT->header();
// These are needed early because of tabs.php
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
$overridableroles = get_overridable_roles($context, ROLENAME_BOTH);
// Print heading.
echo $OUTPUT->heading($title);
// If a user has been chosen, show all the permissions for this user.
$reportuser = $userselector->get_selected_user();
if (!is_null($reportuser)) {
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->heading(get_string('permissionsforuser', 'role', fullname($reportuser)), 3);
$table = new check_capability_table($context, $reportuser, $contextname);
$table->display();
echo $OUTPUT->box_end();
$selectheading = get_string('selectanotheruser', 'role');
} else {
$selectheading = get_string('selectauser', 'role');
}
// Show UI for choosing a user to report on.
echo $OUTPUT->box_start('generalbox boxwidthnormal boxaligncenter', 'chooseuser');
echo '<form method="get" action="' . $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php" >';
// Hidden fields.
echo '<input type="hidden" name="contextid" value="' . $context->id . '" />';
if (!empty($user->id)) {
echo '<input type="hidden" name="userid" value="' . $user->id . '" />';
}
if ($isfrontpage) {
echo '<input type="hidden" name="courseid" value="' . $courseid . '" />';
}
// User selector.
echo $OUTPUT->heading('<label for="reportuser">' . $selectheading . '</label>', 3);
$userselector->display();
// Submit button and the end of the form.
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'role') . '" /></p>';
echo '</form>';
echo $OUTPUT->box_end();
// Appropriate back link.
if ($context->contextlevel > CONTEXT_USER) {
echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
echo html_writer::end_tag('div');
}
echo $OUTPUT->footer();
-182
View File
@@ -1,182 +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/>.
/**
* Lets the user edit role definitions.
*
* Responds to actions:
* add - add a new role
* duplicate - like add, only initialise the new role by using an existing one.
* edit - edit the definition of a role
* view - view the definition of a role
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
$action = required_param('action', PARAM_ALPHA);
if (!in_array($action, array('add', 'duplicate', 'edit', 'view'))) {
throw new moodle_exception('invalidaccess');
}
if ($action != 'add') {
$roleid = required_param('roleid', PARAM_INTEGER);
} else {
$roleid = 0;
}
/// Get the base URL for this and related pages into a convenient variable.
$manageurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
if ($action == 'duplicate') {
$baseurl = $defineurl . '?action=add';
} else {
$baseurl = $defineurl . '?action=' . $action;
if ($roleid) {
$baseurl .= '&amp;roleid=' . $roleid;
}
}
/// Check access permissions.
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_login();
require_capability('moodle/role:manage', $systemcontext);
admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), $defineurl);
/// Handle the cancel button.
if (optional_param('cancel', false, PARAM_BOOL)) {
redirect($manageurl);
}
/// Handle the toggle advanced mode button.
$showadvanced = get_user_preferences('definerole_showadvanced', false);
if (optional_param('toggleadvanced', false, PARAM_BOOL)) {
$showadvanced = !$showadvanced;
set_user_preference('definerole_showadvanced', $showadvanced);
}
/// Get some basic data we are going to need.
$roles = get_all_roles();
$rolenames = role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
$rolescount = count($roles);
/// Create the table object.
if ($action == 'view') {
$definitiontable = new view_role_definition_table($systemcontext, $roleid);
} else if ($showadvanced) {
$definitiontable = new define_role_table_advanced($systemcontext, $roleid);
} else {
$definitiontable = new define_role_table_basic($systemcontext, $roleid);
}
$definitiontable->read_submitted_permissions();
if ($action == 'duplicate') {
$definitiontable->make_copy();
}
/// Process submission in necessary.
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
$definitiontable->save_changes();
add_to_log(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' .
$definitiontable->get_role_id(), $definitiontable->get_role_name(), '', $USER->id);
redirect($manageurl);
}
/// Print the page header and tabs.
echo $OUTPUT->header();
$currenttab = 'manage';
include('managetabs.php');
if ($action == 'add') {
$title = get_string('addinganewrole', 'role');
} else if ($action == 'duplicate') {
$title = get_string('addingrolebycopying', 'role', $rolenames[$roleid]->localname);
} else if ($action == 'view') {
$title = get_string('viewingdefinitionofrolex', 'role', $rolenames[$roleid]->localname);
} else if ($action == 'edit') {
$title = get_string('editingrolex', 'role', $rolenames[$roleid]->localname);
}
echo $OUTPUT->heading_with_help($title, 'roles', 'role');
/// Work out some button labels.
if ($action == 'add' || $action == 'duplicate') {
$submitlabel = get_string('createthisrole', 'role');
} else {
$submitlabel = get_string('savechanges');
}
/// On the view page, show some extra controls at the top.
if ($action == 'view') {
echo $OUTPUT->container_start('buttons');
$options = array();
$options['roleid'] = $roleid;
$options['action'] = 'edit';
echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('edit'));
$options['action'] = 'reset';
if ($definitiontable->get_archetype()) {
echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrole', 'role'));
} else {
echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrolenolegacy', 'role'));
}
$options['action'] = 'duplicate';
echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('duplicaterole', 'role'));
echo $OUTPUT->single_button(new moodle_url($manageurl), get_string('listallroles', 'role'));
echo $OUTPUT->container_end();
}
// Start the form.
echo $OUTPUT->box_start('generalbox');
if ($action == 'view') {
echo '<div class="mform">';
} else {
?>
<form id="rolesform" class="mform" action="<?php echo $baseurl; ?>" method="post"><div>
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
<div class="submit buttons">
<input type="submit" name="savechanges" value="<?php echo $submitlabel; ?>" />
<input type="submit" name="cancel" value="<?php print_string('cancel'); ?>" />
</div>
<?php
}
// Print the form controls.
$definitiontable->display();
/// Close the stuff we left open above.
if ($action == 'view') {
echo '</div>';
} else {
?>
<div class="submit buttons">
<input type="submit" name="savechanges" value="<?php echo $submitlabel; ?>" />
<input type="submit" name="cancel" value="<?php print_string('cancel'); ?>" />
</div>
</div></form>
<?php
}
echo $OUTPUT->box_end();
/// Print a link back to the all roles list.
echo '<div class="backlink">';
echo '<p><a href="' . $manageurl . '">' . get_string('backtoallroles', 'role') . '</a></p>';
echo '</div>';
echo $OUTPUT->footer();
-1618
View File
File diff suppressed because it is too large Load Diff
-268
View File
@@ -1,268 +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/>.
/**
* Lets the user define and edit roles.
*
* Responds to actions:
* [blank] - list roles.
* delete - delete a role (with are-you-sure)
* moveup - change the sort order
* movedown - change the sort order
* reset - set a role's permissions back to the default for that legacy role type.
*
* For all but the first two of those, you also need a roleid parameter, and
* possibly some other data.
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/roles/lib.php');
$action = optional_param('action', '', PARAM_ALPHA);
if ($action) {
$roleid = required_param('roleid', PARAM_INT);
}
/// Get the base URL for this and related pages into a convenient variable.
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/manage.php';
$defineurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/define.php';
/// Check access permissions.
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_login();
require_capability('moodle/role:manage', $systemcontext);
admin_externalpage_setup('defineroles');
/// Get some basic data we are going to need.
$roles = get_all_roles();
role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
$undeletableroles = array();
$undeletableroles[$CFG->notloggedinroleid] = 1;
$undeletableroles[$CFG->guestroleid] = 1;
$undeletableroles[$CFG->defaultuserroleid] = 1;
///.Process submitted data.
$confirmed = optional_param('confirm', false, PARAM_BOOL) && data_submitted() && confirm_sesskey();
switch ($action) {
case 'delete':
if (isset($undeletableroles[$roleid])) {
print_error('cannotdeletethisrole', '', $baseurl);
}
if (!$confirmed) {
// show confirmation
echo $OUTPUT->header();
$optionsyes = array('action'=>'delete', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
$a = new stdClass();
$a->id = $roleid;
$a->name = $roles[$roleid]->name;
$a->shortname = $roles[$roleid]->shortname;
$a->count = $DB->count_records('role_assignments', array('roleid'=>$roleid));
$formcontinue = new single_button(new moodle_url($baseurl, $optionsyes), get_string('yes'));
$formcancel = new single_button(new moodle_url($baseurl), get_string('no'), 'get');
echo $OUTPUT->confirm(get_string('deleterolesure', 'role', $a), $formcontinue, $formcancel);
echo $OUTPUT->footer();
die;
}
if (!delete_role($roleid)) {
// The delete failed, but mark the context dirty in case.
mark_context_dirty($systemcontext->path);
print_error('cannotdeleterolewithid', 'error', $baseurl, $roleid);
}
// Deleted a role sitewide...
mark_context_dirty($systemcontext->path);
add_to_log(SITEID, 'role', 'delete', 'admin/roles/manage.php', $roles[$roleid]->localname, '', $USER->id);
redirect($baseurl);
break;
case 'moveup':
if (confirm_sesskey()) {
$prevrole = null;
$thisrole = null;
foreach ($roles as $role) {
if ($role->id == $roleid) {
$thisrole = $role;
break;
} else {
$prevrole = $role;
}
}
if (is_null($thisrole) || is_null($prevrole)) {
print_error('cannotmoverolewithid', 'error', '', $roleid);
}
if (!switch_roles($thisrole, $prevrole)) {
print_error('cannotmoverolewithid', 'error', '', $roleid);
}
}
redirect($baseurl);
break;
case 'movedown':
if (confirm_sesskey()) {
$thisrole = null;
$nextrole = null;
foreach ($roles as $role) {
if ($role->id == $roleid) {
$thisrole = $role;
} else if (!is_null($thisrole)) {
$nextrole = $role;
break;
}
}
if (is_null($nextrole)) {
print_error('cannotmoverolewithid', 'error', '', $roleid);
}
if (!switch_roles($thisrole, $nextrole)) {
print_error('cannotmoverolewithid', 'error', '', $roleid);
}
}
redirect($baseurl);
break;
case 'reset':
if (!$confirmed) {
// show confirmation
echo $OUTPUT->header();
$optionsyes = array('action'=>'reset', 'roleid'=>$roleid, 'sesskey'=>sesskey(), 'confirm'=>1);
$optionsno = array('action'=>'view', 'roleid'=>$roleid);
$a = new stdClass();
$a->id = $roleid;
$a->name = $roles[$roleid]->name;
$a->shortname = $roles[$roleid]->shortname;
$a->legacytype = $roles[$roleid]->archetype;
if (empty($a->legacytype)) {
$warning = get_string('resetrolesurenolegacy', 'role', $a);
} else {
$warning = get_string('resetrolesure', 'role', $a);
}
$formcontinue = new single_button(new moodle_url('manage.php', $optionsyes), get_string('yes'));
$formcancel = new single_button(new moodle_url('manage.php', $optionsno), get_string('no'), 'get');
echo $OUTPUT->confirm($warning, $formcontinue, $formcancel);
echo $OUTPUT->footer();
die;
}
// Reset context levels for standard archetypes
if ($roles[$roleid]->archetype) {
set_role_contextlevels($roleid, get_default_contextlevels($roles[$roleid]->archetype));
}
//reset or delete the capabilities
reset_role_capabilities($roleid);
// Mark context dirty, log and redirect.
mark_context_dirty($systemcontext->path);
add_to_log(SITEID, 'role', 'reset', 'admin/roles/manage.php?action=reset&roleid=' . $roleid, $roles[$roleid]->localname, '', $USER->id);
redirect($defineurl . '?action=view&roleid=' . $roleid);
break;
}
/// Print the page header and tabs.
echo $OUTPUT->header();
$currenttab = 'manage';
include_once('managetabs.php');
/// Initialise table.
$table = new html_table();
$table->tablealign = 'center';
$table->align = array('left', 'left', 'left', 'left');
$table->wrap = array('nowrap', '', 'nowrap','nowrap');
$table->width = '90%';
$table->head = array(
get_string('role') . ' ' . $OUTPUT->help_icon('roles', 'role'),
get_string('description'),
get_string('roleshortname', 'role'),
get_string('edit')
);
/// Get some strings outside the loop.
$stredit = get_string('edit');
$strduplicate = get_string('duplicate');
$strdelete = get_string('delete');
$strmoveup = get_string('moveup');
$strmovedown = get_string('movedown');
/// Print a list of roles with edit/copy/delete/reorder icons.
$table->data = array();
$firstrole = reset($roles);
$lastrole = end($roles);
foreach ($roles as $role) {
/// Basic data.
$row = array(
'<a href="' . $defineurl . '?action=view&amp;roleid=' . $role->id . '">' . $role->localname . '</a>',
format_text($role->description, FORMAT_HTML),
s($role->shortname),
'',
);
/// Icons:
// move up
if ($role->sortorder != $firstrole->sortorder) {
$row[3] .= get_action_icon($baseurl . '?action=moveup&amp;roleid=' . $role->id . '&amp;sesskey=' . sesskey(), 'up', $strmoveup, $strmoveup);
} else {
$row[3] .= get_spacer();
}
// move down
if ($role->sortorder != $lastrole->sortorder) {
$row[3] .= get_action_icon($baseurl . '?action=movedown&amp;roleid=' . $role->id . '&amp;sesskey=' . sesskey(), 'down', $strmovedown, $strmovedown);
} else {
$row[3] .= get_spacer();
}
// edit
$row[3] .= get_action_icon($defineurl . '?action=edit&amp;roleid=' . $role->id,
'edit', $stredit, get_string('editxrole', 'role', $role->localname));
// duplicate
$row[3] .= get_action_icon($defineurl . '?action=duplicate&amp;roleid=' . $role->id,
'copy', $strduplicate, get_string('createrolebycopying', 'role', $role->localname));
// delete
if (isset($undeletableroles[$role->id])) {
$row[3] .= get_spacer();
} else {
$row[3] .= get_action_icon($baseurl . '?action=delete&amp;roleid=' . $role->id,
'delete', $strdelete, get_string('deletexrole', 'role', $role->localname));
}
$table->data[] = $row;
}
echo html_writer::table($table);
echo $OUTPUT->container_start('buttons');
echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'role'), 'get');
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
die;
function get_action_icon($url, $icon, $alt, $tooltip) {
global $OUTPUT;
return '<a title="' . $tooltip . '" href="'. $url . '">' .
'<img src="' . $OUTPUT->pix_url('t/' . $icon) . '" class="iconsmall" alt="' . $alt . '" /></a> ';
}
function get_spacer() {
global $OUTPUT;
return '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" /> ';
}
-39
View File
@@ -1,39 +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/>.
/**
* Defines the tab bar used on the manage/allow assign/allow overrides pages.
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
}
$toprow = array();
$toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), get_string('manageroles', 'role'));
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'role'));
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'role'));
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'role'));
$tabs = array($toprow);
print_tabs($tabs, $currenttab);
-182
View File
@@ -1,182 +0,0 @@
/**
* This class filters the rows of a table like the one on the define or
* override roles pages. It adds a search box just above the table, and if
* content is typed into that box, it hides any rows in the table where the
* capability name does not contain that text.
*/
/**
* Role namespace
*/
M.core_role = {};
/**
* @param {YUI} Y
* @param {string} tableid
* @param {int} contextid
*/
M.core_role.init_cap_table_filter = function(Y, tableid, contextid) {
var CapTableFilter = function(tableid) {
this.tableid = tableid;
this.context = contextid;
this.initializer();
};
CapTableFilter.prototype = {
tableid : null, // ID of the cap table
context : null, // Context ID associated with what ever we are looking at
delayhandle : -1,
searchdelay : 100, // milliseconds
table : null,
div : null,
input : null,
label : null,
button : null,
/**
* Initialises the CapTableFilter object.
* This is called initializer so that a move to convert this to a proper
* YUI module will be easier.
*/
initializer : function() {
// Get any existing filter value
var filtervalue = this.getFilterCookieValue();
// Find the form controls.
this.table = Y.one('#'+this.tableid);
// Create a div to hold the search UI.
this.div = Y.Node.create('<div class="capabilitysearchui"></div>').setStyles({
width : this.table.get('offsetWidth'),
marginLeft : 'auto',
marginRight : 'auto'
});
// Create the capability search input.
this.input = Y.Node.create('<input type="text" id="'+this.table.get('id')+'capabilitysearch" value="'+filtervalue+'" />');
// Create a label for the search input.
this.label = Y.Node.create('<label for="'+this.input.get('id')+'">'+M.str.moodle.filter+' </label>');
// Create a clear button to clear the input.
this.button = Y.Node.create('<input type="button" value="'+M.str.moodle.clear+'" />').set('disabled', filtervalue=='');
// Tie it all together
this.div.append(this.label).append(this.input).append(this.button);
// Insert it into the div
this.table.ancestor().insert(this.div, this.table);
// Wire the events so it actually does something
this.input.on('keyup', this.change, this);
this.button.on('click', this.clear, this);
if (filtervalue != '') {
this.filter();
}
},
/**
* Sets a cookie that describes the filter value.
* The cookie stores the context, and the time it was created and upon
* retrieval is checked to ensure that the cookie is for the correct
* context and is no more than an hour old.
*/
setFilterCookieValue : function(value) {
var cookie = {
fltcontext : this.context,
flttime : new Date().getTime(),
fltvalue : value
}
Y.Cookie.setSubs("captblflt", cookie);
},
/**
* Gets the existing filter value if there is one.
* The cookie stores the context, and the time it was created and upon
* retrieval is checked to ensure that the cookie is for the correct
* context and is no more than an hour old.
*/
getFilterCookieValue : function() {
var cookie = Y.Cookie.getSubs('captblflt');
if (cookie!=null && cookie.fltcontext && cookie.fltcontext == this.context && parseInt(cookie.flttime) > new Date().getTime()-(60*60*1000)) {
return cookie.fltvalue;
}
return '';
},
/**
* Clears the filter value.
*/
clear : function() {
this.input.set('value', '');
if (this.delayhandle != -1) {
clearTimeout(this.delayhandle);
this.delayhandle = -1;
}
this.filter();
},
/**
* Event callback for when the filter value changes
*/
change : function() {
var self = this;
var handle = setTimeout(function(){self.filter();}, this.searchdelay);
if (this.delayhandle != -1) {
clearTimeout(this.delayhandle);
}
this.delayhandle = handle;
},
/**
* Marks a row as visible or hidden
*/
setVisible : function(row, visible) {
if (visible) {
row.removeClass('hiddenrow');
} else {
row.addClass('hiddenrow');
}
},
/**
* Filters the capability table
*/
filter : function() {
var filtertext = this.input.get('value').toLowerCase(),
lastheading = null;
this.setFilterCookieValue(filtertext);
this.button.set('disabled', (filtertext == ''));
this.table.all('tr').each(function(row){
if (row.hasClass('rolecapheading')) {
this.setVisible(row, false);
lastheading = row;
}
if (row.hasClass('rolecap')) {
var capname = row.one('.cap-name').get('text') + '|' + row.one('.cap-desc a').get('text').toLowerCase();
if (capname.indexOf(filtertext) >= 0) {
this.setVisible(row, true);
if (lastheading) {
this.setVisible(lastheading, true);
lastheading = null;
}
} else {
this.setVisible(row, false);
}
}
}, this);
}
}
new CapTableFilter(tableid);
};
M.core_role.init_add_assign_page = function(Y) {
var add = Y.one('#add');
var addselect = M.core_user.get_user_selector('addselect');
add.set('disabled', addselect.is_selection_empty());
addselect.on('user_selector:selectionchanged', function(isempty) {
add.set('disabled', isempty);
});
var remove = Y.one('#remove');
var removeselect = M.core_user.get_user_selector('removeselect');
remove.set('disabled', removeselect.is_selection_empty());
removeselect.on('user_selector:selectionchanged', function(isempty) {
remove.set('disabled', isempty);
});
};
-171
View File
@@ -1,171 +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/>.
/**
* Lets you override role definitions in contexts.
*
* @package core
* @subpackage role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
$contextid = required_param('contextid', PARAM_INT); // context id
$roleid = required_param('roleid', PARAM_INT); // requested role id
list($context, $course, $cm) = get_context_info_array($contextid);
$url = new moodle_url('/admin/roles/override.php', array('contextid' => $contextid, 'roleid' => $roleid));
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
} else {
$course = $SITE;
}
}
// security first
require_login($course, false, $cm);
if (!has_capability('moodle/role:override', $context)) {
require_capability('moodle/role:safeoverride', $context);
}
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_pagelayout('admin');
$courseid = $course->id;
$returnurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $context->id));
// Handle the cancel button.
if (optional_param('cancel', false, PARAM_BOOL)) {
redirect($returnurl);
}
$role = $DB->get_record('role', array('id'=>$roleid), '*', MUST_EXIST);
// These are needed early
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
// Work out an appropriate page title.
$contextname = print_context_name($context);
$straction = get_string('overrideroles', 'role'); // Used by tabs.php
$a = (object)array('context' => $contextname, 'role' => $overridableroles[$roleid]);
$title = get_string('overridepermissionsforrole', 'role', $a);
$currenttab = 'permissions';
$PAGE->set_title($title);
$PAGE->navbar->add($straction);
switch ($context->contextlevel) {
case CONTEXT_SYSTEM:
print_error('cannotoverridebaserole', 'error');
break;
case CONTEXT_USER:
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
break;
case CONTEXT_COURSE:
if ($isfrontpage) {
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
} else {
$PAGE->set_heading($course->fullname);
}
break;
case CONTEXT_MODULE:
$PAGE->set_heading(print_context_name($context, false));
$PAGE->set_cacheable(false);
break;
case CONTEXT_BLOCK:
$PAGE->set_heading($PAGE->course->fullname);
break;
}
// Make sure this user can override that role
if (empty($overridableroles[$roleid])) {
$a = new stdClass;
$a->roleid = $roleid;
$a->context = $contextname;
print_error('cannotoverriderolehere', '', get_context_url($context), $a);
}
// If we are actually overriding a role, create the table object, and save changes if appropriate.
$overridestable = new override_permissions_table_advanced($context, $roleid, false);
$overridestable->read_submitted_permissions();
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
$overridestable->save_changes();
$rolename = $overridableroles[$roleid];
add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
redirect($returnurl);
}
// Finally start page output
echo $OUTPUT->header();
echo $OUTPUT->heading_with_help($title, 'overridepermissions', 'role');
// Show UI for overriding roles.
if (!empty($capabilities)) {
echo $OUTPUT->box(get_string('nocapabilitiesincontext', 'role'), 'generalbox boxaligncenter');
} else {
// Print the capabilities overrideable in this context
echo $OUTPUT->box_start('generalbox capbox');
echo html_writer::start_tag('form', array('id'=>'overrideform', 'action'=>$PAGE->url->out(), 'method'=>'post'));
echo html_writer::start_tag('div');
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'roleid', 'value'=>$roleid));
echo html_writer::tag('p', get_string('highlightedcellsshowinherit', 'role'), array('class'=>'overridenotice'));
$overridestable->display();
if ($overridestable->has_locked_capabilities()) {
echo '<p class="overridenotice">' . get_string('safeoverridenotice', 'role') . "</p>\n";
}
echo html_writer::start_tag('div', array('class'=>'submit_buttons'));
echo html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savechanges', 'value'=>get_string('savechanges')));
echo html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'cancel', 'value'=>get_string('cancel')));
echo html_writer::end_tag('div');
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
echo $OUTPUT->box_end();
}
// Print a form to swap roles, and a link back to the all roles list.
echo html_writer::start_tag('div', array('class'=>'backlink'));
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
$select->label = get_string('overrideanotherrole', 'role');
echo $OUTPUT->render($select);
echo html_writer::tag('p', html_writer::tag('a', get_string('backtoallroles', 'role'), array('href'=>$returnurl)));
echo html_writer::end_tag('div');
echo $OUTPUT->footer();
-211
View File
@@ -1,211 +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/>.
/**
* This script serves draft files of current user
*
* @package core
* @subpackage role
* @copyright 2009 Petr Skoda (skodak) info@skodak.org
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once("$CFG->dirroot/$CFG->admin/roles/lib.php");
require_once("permissions_forms.php");
$contextid = required_param('contextid',PARAM_INT);
$roleid = optional_param('roleid', 0, PARAM_INT);
$capability = optional_param('capability', false, PARAM_CAPABILITY);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$prevent = optional_param('prevent', 0, PARAM_BOOL);
$allow = optional_param('allow', 0, PARAM_BOOL);
$unprohibit = optional_param('unprohibit', 0, PARAM_BOOL);
$prohibit = optional_param('prohibit', 0, PARAM_BOOL);
list($context, $course, $cm) = get_context_info_array($contextid);
$url = new moodle_url('/admin/roles/permissions.php', array('contextid' => $contextid));
if ($course) {
$isfrontpage = ($course->id == SITEID);
} else {
$isfrontpage = false;
if ($context->contextlevel == CONTEXT_USER) {
$course = $DB->get_record('course', array('id'=>optional_param('courseid', SITEID, PARAM_INT)), '*', MUST_EXIST);
$user = $DB->get_record('user', array('id'=>$context->instanceid), '*', MUST_EXIST);
$url->param('courseid', $course->id);
$url->param('userid', $user->id);
} else {
$course = $SITE;
}
}
// security first
require_login($course, false, $cm);
require_capability('moodle/role:review', $context);
$PAGE->set_url($url);
$PAGE->set_context($context);
$courseid = $course->id;
// These are needed early because of tabs.php
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, ROLENAME_BOTH, true);
if ($capability) {
$capability = $DB->get_record('capabilities', array('name'=>$capability), '*', MUST_EXIST);
}
$allowoverrides = has_capability('moodle/role:override', $context);
$allowsafeoverrides = has_capability('moodle/role:safeoverride', $context);
$contextname = print_context_name($context);
$title = get_string('permissionsincontext', 'role', $contextname);
$straction = get_string('permissions', 'role'); // Used by tabs.php
$currenttab = 'permissions';
$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
switch ($context->contextlevel) {
case CONTEXT_SYSTEM:
print_error('cannotoverridebaserole', 'error');
break;
case CONTEXT_USER:
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
$PAGE->set_heading($fullname);
$showroles = 1;
break;
case CONTEXT_COURSECAT:
$PAGE->set_heading("$SITE->fullname: ".get_string("categories"));
break;
case CONTEXT_COURSE:
if ($isfrontpage) {
admin_externalpage_setup('frontpageroles', '', array(), $PAGE->url);
} else {
$PAGE->set_heading($course->fullname);
}
break;
case CONTEXT_MODULE:
$PAGE->set_heading(print_context_name($context, false));
$PAGE->set_cacheable(false);
break;
case CONTEXT_BLOCK:
$PAGE->set_heading($PAGE->course->fullname);
break;
}
// handle confirmations and actions
// We have a capability and overrides are allowed or safe overrides are allowed and this is safe
if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capability($capability)))) {
// If we already know the the role ID, it is overrideable, and we are setting prevent or unprohibit
if (isset($overridableroles[$roleid]) && ($prevent || $unprohibit)) {
// We are preventing
if ($prevent) {
if ($confirm && data_submitted() && confirm_sesskey()) {
role_change_permission($roleid, $context, $capability->name, CAP_PREVENT);
redirect($PAGE->url);
} else {
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'role'=>$overridableroles[$roleid], 'context'=>$contextname);
$message = get_string('confirmroleprevent', 'role', $a);
$continueurl = new moodle_url($PAGE->url, array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'prevent'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
}
}
// We are unprohibiting
if ($unprohibit) {
if ($confirm && data_submitted() && confirm_sesskey()) {
role_change_permission($roleid, $context, $capability->name, CAP_INHERIT);
redirect($PAGE->url);
} else {
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'role'=>$overridableroles[$roleid], 'context'=>$contextname);
$message = get_string('confirmroleunprohibit', 'role', $a);
$continueurl = new moodle_url($PAGE->url, array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability->name, 'unprohibit'=>1, 'sesskey'=>sesskey(), 'confirm'=>1));
}
}
// Display and print
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
echo $OUTPUT->confirm($message, $continueurl, $PAGE->url);
echo $OUTPUT->footer();
die;
}
if ($allow || $prohibit) {
if ($allow) {
$mform = new role_allow_form(null, array($context, $capability, $overridableroles));
if ($mform->is_cancelled()) {
redirect($PAGE->url);
} else if ($data = $mform->get_data() and !empty($data->roleid)) {
$roleid = $data->roleid;
if (isset($overridableroles[$roleid])) {
role_change_permission($roleid, $context, $capability->name, CAP_ALLOW);
}
redirect($PAGE->url);
} else {
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'context'=>$contextname);
$message = get_string('roleallowinfo', 'role', $a);
}
}
if ($prohibit) {
$mform = new role_prohibit_form(null, array($context, $capability, $overridableroles));
if ($mform->is_cancelled()) {
redirect($PAGE->url);
} else if ($data = $mform->get_data() and !empty($data->roleid)) {
$roleid = $data->roleid;
if (isset($overridableroles[$roleid])) {
role_change_permission($roleid, $context, $capability->name, CAP_PROHIBIT);
}
redirect($PAGE->url);
} else {
$a = (object)array('cap'=>get_capability_docs_link($capability)." ($capability->name)", 'context'=>$contextname);
$message = get_string('roleprohibitinfo', 'role', $a);
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
echo $OUTPUT->box($message);
$mform->display();
echo $OUTPUT->footer();
die;
}
}
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
$table = new permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
echo $OUTPUT->box_start('generalbox capbox');
// print link to advanced override page
if ($overridableroles) {
$overrideurl = new moodle_url('/admin/roles/override.php', array('contextid' => $context->id));
$select = new single_select($overrideurl, 'roleid', $nameswithcounts);
$select->label = get_string('advancedoverride', 'role');
echo html_writer::tag('div', $OUTPUT->render($select), array('class'=>'advancedoverride'));
}
$table->display();
echo $OUTPUT->box_end();
if ($context->contextlevel > CONTEXT_USER) {
echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context)));
echo html_writer::end_tag('div');
}
echo $OUTPUT->footer($course);
-101
View File
@@ -1,101 +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/>.
/**
* This script serves draft files of current user
*
* @package core
* @subpackage role
* @copyright 2009 Petr Skoda (skodak) info@skodak.org
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("$CFG->libdir/formslib.php");
class role_allow_form extends moodleform {
// Define the form
function definition() {
global $CFG;
$mform = $this->_form;
list($context, $capability, $overridableroles) = $this->_customdata;
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
foreach($needed as $id=>$unused) {
unset($overridableroles[$id]);
}
foreach($forbidden as $id=>$unused) {
unset($overridableroles[$id]);
}
$mform->addElement('header', 'allowheader', get_string('roleallowheader', 'role'));
$mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
$mform->addElement('hidden','capability');
$mform->setType('capability', PARAM_CAPABILITY);
$mform->setDefault('capability', $capability->name);
$mform->addElement('hidden','contextid');
$mform->setType('contextid', PARAM_INT);
$mform->setDefault('contextid', $context->id);
$mform->addElement('hidden','allow');
$mform->setType('allow', PARAM_INT);
$mform->setDefault('allow', 1);
$this->add_action_buttons(true, get_string('allow', 'role'));
}
}
class role_prohibit_form extends moodleform {
// Define the form
function definition() {
global $CFG;
$mform = $this->_form;
list($context, $capability, $overridableroles) = $this->_customdata;
list($needed, $forbidden) = get_roles_with_cap_in_context($context, $capability->name);
foreach($forbidden as $id=>$unused) {
unset($overridableroles[$id]);
}
$mform->addElement('header', 'ptohibitheader', get_string('roleprohibitheader', 'role'));
$mform->addElement('select', 'roleid', get_string('roleselect', 'role'), $overridableroles);
$mform->addElement('hidden','capability');
$mform->setType('capability', PARAM_CAPABILITY);
$mform->setDefault('capability', $capability->name);
$mform->addElement('hidden','contextid');
$mform->setType('contextid', PARAM_INT);
$mform->setDefault('contextid', $context->id);
$mform->addElement('hidden','prohibit');
$mform->setType('prohibit', PARAM_INT);
$mform->setDefault('prohibit', 1);
$this->add_action_buttons(true, get_string('prohibit', 'role'));
}
}
-212
View File
@@ -1,212 +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/>.
/**
* User roles report list all the users who have been assigned a particular
* role in all contexts.
*
* @package core
* @subpackage role
* @copyright &copy; 2007 The Open University and others
* @author t.j.hunt@open.ac.uk and others
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
// Get params.
$userid = required_param('userid', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
// Validate them and get the corresponding objects.
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$baseurl = new moodle_url('/admin/roles/usersroles.php', array('userid'=>$userid, 'courseid'=>$courseid));
$PAGE->set_url($baseurl);
$PAGE->set_context($coursecontext);
$PAGE->set_pagelayout('admin');
/// Check login and permissions.
require_login($course);
$canview = has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
'moodle/role:override', 'moodle/role:manage'), $usercontext);
if (!$canview) {
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
}
/// Now get the role assignments for this user.
$sql = "SELECT
ra.id, ra.userid, ra.contextid, ra.roleid, ra.component, ra.itemid,
c.path,
r.name AS rolename,
COALESCE(rn.name, r.name) AS localname
FROM
{role_assignments} ra
JOIN {context} c ON ra.contextid = c.id
JOIN {role} r ON ra.roleid = r.id
LEFT JOIN {role_names} rn ON rn.roleid = ra.roleid AND rn.contextid = ra.contextid
WHERE
ra.userid = ?
"./*AND ra.active = 1*/"
ORDER BY
contextlevel DESC, contextid ASC, r.sortorder ASC";
$roleassignments = $DB->get_records_sql($sql, array($user->id));
/// In order to display a nice tree of contexts, we need to get all the
/// ancestors of all the contexts in the query we just did.
$requiredcontexts = array();
foreach ($roleassignments as $ra) {
$requiredcontexts = array_merge($requiredcontexts, explode('/', trim($ra->path, '/')));
}
$requiredcontexts = array_unique($requiredcontexts);
/// Now load those contexts.
if ($requiredcontexts) {
list($sqlcontexttest, $contextparams) = $DB->get_in_or_equal($requiredcontexts);
$contexts = get_sorted_contexts('ctx.id ' . $sqlcontexttest, $contextparams);
} else {
$contexts = array();
}
/// Prepare some empty arrays to hold the data we are about to compute.
foreach ($contexts as $conid => $con) {
$contexts[$conid]->children = array();
$contexts[$conid]->roleassignments = array();
}
/// Put the contexts into a tree structure.
foreach ($contexts as $conid => $con) {
$context = context::instance_by_id($conid);
$parentcontextid = get_parent_contextid($context);
if ($parentcontextid) {
$contexts[$parentcontextid]->children[] = $conid;
}
}
/// Put the role capabilities into the context tree.
foreach ($roleassignments as $ra) {
$contexts[$ra->contextid]->roleassignments[$ra->roleid] = $ra;
}
$assignableroles = get_assignable_roles($usercontext, ROLENAME_BOTH);
$overridableroles = get_overridable_roles($usercontext, ROLENAME_BOTH);
/// Print the header
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $coursecontext));
$straction = get_string('thisusersroles', 'role');
$title = get_string('xroleassignments', 'role', $fullname);
/// Course header
$PAGE->set_title($title);
if ($courseid != SITEID) {
$PAGE->set_heading($fullname);
if (has_capability('moodle/course:viewparticipants', $coursecontext)) {
$PAGE->navbar->add(get_string('participants'),new moodle_url('/user/index.php', array('id'=>$courseid)));
}
} else {
$PAGE->set_heading($course->fullname);
}
$PAGE->navbar->add($fullname, new moodle_url("$CFG->wwwroot/user/view.php", array('id'=>$userid,'course'=>$courseid)));
$PAGE->navbar->add($straction);
echo $OUTPUT->header();
echo $OUTPUT->heading($title, 3);
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
// Display them.
if (!$roleassignments) {
echo '<p>', get_string('noroleassignments', 'role'), '</p>';
} else {
print_report_tree($systemcontext->id, $contexts, $systemcontext, $fullname);
}
/// End of page.
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
global $CFG, $OUTPUT;
// Only compute lang strings, etc once.
static $stredit = null, $strcheckpermissions, $globalroleassigner, $assignurl, $checkurl;
if (is_null($stredit)) {
$stredit = get_string('edit');
$strcheckpermissions = get_string('checkpermissions', 'role');
$globalroleassigner = has_capability('moodle/role:assign', $systemcontext);
$assignurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php';
$checkurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php';
}
// Pull the current context into an array for convinience.
$context = context::instance_by_id($contextid);
// Print the context name.
echo $OUTPUT->heading($context->get_context_name(), 4, 'contextname');
// If there are any role assignments here, print them.
foreach ($contexts[$contextid]->roleassignments as $ra) {
$value = $ra->contextid . ',' . $ra->roleid;
$inputid = 'unassign' . $value;
echo '<p>';
if ($ra->rolename == $ra->localname) {
echo strip_tags(format_string($ra->localname));
} else {
echo strip_tags(format_string($ra->localname . ' (' . $ra->rolename . ')'));
}
if (has_capability('moodle/role:assign', $context)) {
$raurl = $assignurl . '?contextid=' . $ra->contextid . '&amp;roleid=' .
$ra->roleid . '&amp;removeselect[]=' . $ra->userid;
$churl = $checkurl . '?contextid=' . $ra->contextid . '&amp;reportuser=' . $ra->userid;
if ($context->contextlevel == CONTEXT_USER) {
$raurl .= '&amp;userid=' . $context->instanceid;
$churl .= '&amp;userid=' . $context->instanceid;
}
$a = new stdClass;
$a->fullname = $fullname;
$a->contextlevel = get_contextlevel_name($context->contextlevel);
if ($context->contextlevel == CONTEXT_SYSTEM) {
$strgoto = get_string('gotoassignsystemroles', 'role');
$strcheck = get_string('checksystempermissionsfor', 'role', $a);
} else {
$strgoto = get_string('gotoassignroles', 'role', $a);
$strcheck = get_string('checkuserspermissionshere', 'role', $a);
}
echo ' <a title="' . $strgoto . '" href="' . $raurl . '"><img class="iconsmall" src="' .
$OUTPUT->pix_url('t/edit') . '" alt="' . $stredit . '" /></a> ';
echo ' <a title="' . $strcheck . '" href="' . $churl . '"><img class="iconsmall" src="' .
$OUTPUT->pix_url('t/preview') . '" alt="' . $strcheckpermissions . '" /></a> ';
echo "</p>\n";
}
}
// If there are any child contexts, print them recursively.
if (!empty($contexts[$contextid]->children)) {
echo '<ul>';
foreach ($contexts[$contextid]->children as $childcontextid) {
echo '<li>';
print_report_tree($childcontextid, $contexts, $systemcontext, $fullname);
echo '</li>';
}
echo '</ul>';
}
}
-64
View File
@@ -1,64 +0,0 @@
<?php
// searches for admin settings
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
$adminroot = admin_get_root(); // need all settings here
$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
$statusmsg = '';
$errormsg = '';
$focus = '';
// now we'll deal with the case that the admin has submitted the form with changed settings
if ($data = data_submitted() and confirm_sesskey()) {
if (admin_write_settings($data)) {
$statusmsg = get_string('changessaved');
}
$adminroot = admin_get_root(true); //reload tree
if (!empty($adminroot->errors)) {
$errormsg = get_string('errorwithsettings', 'admin');
$firsterror = reset($adminroot->errors);
$focus = $firsterror->id;
}
}
// and finally, if we get here, then there are matching settings and we have to print a form
// to modify them
echo $OUTPUT->header($focus);
if ($errormsg !== '') {
echo $OUTPUT->notification($errormsg);
} else if ($statusmsg !== '') {
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
}
$resultshtml = admin_search_settings_html($query); // case insensitive search only
echo '<form action="search.php" method="post" id="adminsettings">';
echo '<div>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="query" value="'.s($query).'" />';
echo '</div>';
echo '<fieldset>';
echo '<div class="clearer"><!-- --></div>';
if ($resultshtml != '') {
echo $resultshtml;
} else {
echo get_string('noresults','admin');
}
echo '</fieldset>';
echo '</form>';
echo $OUTPUT->footer();
-138
View File
@@ -1,138 +0,0 @@
<?php
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
$section = required_param('section', PARAM_SAFEDIR);
$return = optional_param('return','', PARAM_ALPHA);
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
/// no guest autologin
require_login(0, false);
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_url('/admin/settings.php', array('section' => $section));
$PAGE->set_pagetype('admin-setting-' . $section);
$PAGE->set_pagelayout('admin');
$PAGE->navigation->clear_cache();
$adminroot = admin_get_root(); // need all settings
$settingspage = $adminroot->locate($section, true);
if (empty($settingspage) or !($settingspage instanceof admin_settingpage)) {
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
die;
}
if (!($settingspage->check_access())) {
print_error('accessdenied', 'admin');
die;
}
/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
$statusmsg = '';
$errormsg = '';
$focus = '';
if ($data = data_submitted() and confirm_sesskey()) {
if (admin_write_settings($data)) {
$statusmsg = get_string('changessaved');
}
if (empty($adminroot->errors)) {
switch ($return) {
case 'site': redirect("$CFG->wwwroot/");
case 'admin': redirect("$CFG->wwwroot/$CFG->admin/");
}
} else {
$errormsg = get_string('errorwithsettings', 'admin');
$firsterror = reset($adminroot->errors);
$focus = $firsterror->id;
}
$adminroot = admin_get_root(true); //reload tree
$settingspage = $adminroot->locate($section, true);
}
if ($PAGE->user_allowed_editing() && $adminediting != -1) {
$USER->editing = $adminediting;
}
/// print header stuff ------------------------------------------------------------
if (empty($SITE->fullname)) {
$PAGE->set_title($settingspage->visiblename);
$PAGE->set_heading($settingspage->visiblename);
echo $OUTPUT->header();
echo $OUTPUT->box(get_string('configintrosite', 'admin'));
if ($errormsg !== '') {
echo $OUTPUT->notification($errormsg);
} else if ($statusmsg !== '') {
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
}
// ---------------------------------------------------------------------------------------------------------------
echo '<form action="settings.php" method="post" id="adminsettings">';
echo '<div class="settingsform clearfix">';
echo html_writer::input_hidden_params($PAGE->url);
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="return" value="'.$return.'" />';
echo $settingspage->output_html();
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
echo '</div>';
echo '</form>';
} else {
if ($PAGE->user_allowed_editing()) {
$url = clone($PAGE->url);
if ($PAGE->user_is_editing()) {
$caption = get_string('blockseditoff');
$url->param('adminedit', 'off');
} else {
$caption = get_string('blocksediton');
$url->param('adminedit', 'on');
}
$buttons = $OUTPUT->single_button($url, $caption, 'get');
$PAGE->set_button($buttons);
}
$visiblepathtosection = array_reverse($settingspage->visiblepath);
$PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection));
$PAGE->set_heading($SITE->fullname);
echo $OUTPUT->header();
if ($errormsg !== '') {
echo $OUTPUT->notification($errormsg);
} else if ($statusmsg !== '') {
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
}
// ---------------------------------------------------------------------------------------------------------------
echo '<form action="settings.php" method="post" id="adminsettings">';
echo '<div class="settingsform clearfix">';
echo html_writer::input_hidden_params($PAGE->url);
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="return" value="'.$return.'" />';
echo $OUTPUT->heading($settingspage->visiblename);
echo $settingspage->output_html();
if ($settingspage->show_save()) {
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
}
echo '</div>';
echo '</form>';
}
echo $OUTPUT->footer();
-158
View File
@@ -1,158 +0,0 @@
<?php
// This file defines settingpages and externalpages under the "appearance" category
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$ADMIN->add('appearance', new admin_category('themes', get_string('themes')));
// "themesettings" settingpage
$temp = new admin_settingpage('themesettings', get_string('themesettings', 'admin'));
$temp->add(new admin_setting_configtext('themelist', get_string('themelist', 'admin'), get_string('configthemelist','admin'), '', PARAM_NOTAGS));
$setting = new admin_setting_configcheckbox('themedesignermode', get_string('themedesignermode', 'admin'), get_string('configthemedesignermode', 'admin'), 0);
$setting->set_updatedcallback('theme_reset_all_caches');
$temp->add($setting);
$temp->add(new admin_setting_configcheckbox('allowuserthemes', get_string('allowuserthemes', 'admin'), get_string('configallowuserthemes', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('allowcoursethemes', get_string('allowcoursethemes', 'admin'), get_string('configallowcoursethemes', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('allowcategorythemes', get_string('allowcategorythemes', 'admin'), get_string('configallowcategorythemes', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', get_string('allowthemechangeonurl', 'admin'), get_string('configallowthemechangeonurl', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('allowblockstodock', get_string('allowblockstodock', 'admin'), get_string('configallowblockstodock', 'admin'), 1));
$temp->add(new admin_setting_configtextarea('custommenuitems', get_string('custommenuitems', 'admin'), get_string('configcustommenuitems', 'admin'), '', PARAM_TEXT, '50', '10'));
$temp->add(new admin_setting_configcheckbox('enabledevicedetection', get_string('enabledevicedetection', 'admin'), get_string('configenabledevicedetection', 'admin'), 1));
$temp->add(new admin_setting_devicedetectregex('devicedetectregex', get_string('devicedetectregex', 'admin'), get_string('devicedetectregex_desc', 'admin'), ''));
$ADMIN->add('themes', $temp);
$ADMIN->add('themes', new admin_externalpage('themeselector', get_string('themeselector','admin'), $CFG->wwwroot . '/theme/index.php'));
// settings for each theme
foreach (get_plugin_list('theme') as $theme => $themedir) {
$settings_path = "$themedir/settings.php";
if (file_exists($settings_path)) {
$settings = new admin_settingpage('themesetting'.$theme, get_string('pluginname', 'theme_'.$theme));
include($settings_path);
if ($settings) {
$ADMIN->add('themes', $settings);
}
}
}
// calendar
$temp = new admin_settingpage('calendar', get_string('calendarsettings','admin'));
$temp->add(new admin_setting_special_adminseesall());
//this is hacky because we do not want to include the stuff from calendar/lib.php
$temp->add(new admin_setting_configselect('calendar_site_timeformat', get_string('pref_timeformat', 'calendar'),
get_string('explain_site_timeformat', 'calendar'), '0',
array('0' => get_string('default', 'calendar'),
'%I:%M %p' => get_string('timeformat_12', 'calendar'),
'%H:%M' => get_string('timeformat_24', 'calendar'))));
$temp->add(new admin_setting_configselect('calendar_startwday', get_string('configstartwday', 'admin'), get_string('helpstartofweek', 'admin'), 0,
array(
0 => get_string('sunday', 'calendar'),
1 => get_string('monday', 'calendar'),
2 => get_string('tuesday', 'calendar'),
3 => get_string('wednesday', 'calendar'),
4 => get_string('thursday', 'calendar'),
5 => get_string('friday', 'calendar'),
6 => get_string('saturday', 'calendar')
)));
$temp->add(new admin_setting_special_calendar_weekend());
$options = array();
for ($i=1; $i<=99; $i++) {
$options[$i] = $i;
}
$temp->add(new admin_setting_configselect('calendar_lookahead',get_string('configlookahead','admin'),get_string('helpupcominglookahead', 'admin'),21,$options));
$options = array();
for ($i=1; $i<=20; $i++) {
$options[$i] = $i;
}
$temp->add(new admin_setting_configselect('calendar_maxevents',get_string('configmaxevents','admin'),get_string('helpupcomingmaxevents', 'admin'),10,$options));
$temp->add(new admin_setting_configcheckbox('enablecalendarexport', get_string('enablecalendarexport', 'admin'), get_string('configenablecalendarexport','admin'), 1));
$temp->add(new admin_setting_configtext('calendar_exportsalt', get_string('calendarexportsalt','admin'), get_string('configcalendarexportsalt', 'admin'), random_string(60)));
$ADMIN->add('appearance', $temp);
// blog
$temp = new admin_settingpage('blog', get_string('blog','blog'));
$temp->add(new admin_setting_configcheckbox('useblogassociations', get_string('useblogassociations', 'blog'), get_string('configuseblogassociations','blog'), 1));
$temp->add(new admin_setting_bloglevel('bloglevel', get_string('bloglevel', 'admin'), get_string('configbloglevel', 'admin'), 4, array(BLOG_GLOBAL_LEVEL => get_string('worldblogs','blog'),
BLOG_SITE_LEVEL => get_string('siteblogs','blog'),
BLOG_USER_LEVEL => get_string('personalblogs','blog'),
0 => get_string('disableblogs','blog'))));
$temp->add(new admin_setting_configcheckbox('useexternalblogs', get_string('useexternalblogs', 'blog'), get_string('configuseexternalblogs','blog'), 1));
$temp->add(new admin_setting_configselect('externalblogcrontime', get_string('externalblogcrontime', 'blog'), get_string('configexternalblogcrontime', 'blog'), 86400,
array(43200 => get_string('numhours', '', 12),
86400 => get_string('numhours', '', 24),
172800 => get_string('numdays', '', 2),
604800 => get_string('numdays', '', 7))));
$temp->add(new admin_setting_configtext('maxexternalblogsperuser', get_string('maxexternalblogsperuser','blog'), get_string('configmaxexternalblogsperuser', 'blog'), 1));
$temp->add(new admin_setting_configcheckbox('blogusecomments', get_string('enablecomments', 'admin'), get_string('configenablecomments', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('blogshowcommentscount', get_string('showcommentscount', 'admin'), get_string('configshowcommentscount', 'admin'), 1));
$ADMIN->add('appearance', $temp);
// Navigation settings
$temp = new admin_settingpage('navigation', get_string('navigation'));
$choices = array(
HOMEPAGE_SITE => get_string('site'),
HOMEPAGE_MY => get_string('mymoodle', 'admin'),
HOMEPAGE_USER => get_string('userpreference', 'admin')
);
$temp->add(new admin_setting_configselect('defaulthomepage', get_string('defaulthomepage', 'admin'), get_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices));
$temp->add(new admin_setting_configcheckbox('navshowcategories', get_string('navshowcategories', 'admin'), get_string('confignavshowcategories', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('navshowallcourses', get_string('navshowallcourses', 'admin'), get_string('confignavshowallcourses', 'admin'), 0));
$temp->add(new admin_setting_configtext('navcourselimit',get_string('navcourselimit','admin'),get_string('confignavcourselimit', 'admin'),20,PARAM_INT));
$temp->add(new admin_setting_configcheckbox('navlinkcoursesections', get_string('navlinkcoursesections', 'admin'), get_string('navlinkcoursesections_help', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('usesitenameforsitepages', get_string('usesitenameforsitepages', 'admin'), get_string('configusesitenameforsitepages', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('navadduserpostslinks', get_string('navadduserpostslinks', 'admin'), get_string('navadduserpostslinks_help', 'admin'), 1));
$ADMIN->add('appearance', $temp);
// "htmlsettings" settingpage
$temp = new admin_settingpage('htmlsettings', get_string('htmlsettings', 'admin'));
$temp->add(new admin_setting_configcheckbox('formatstringstriptags', get_string('stripalltitletags', 'admin'), get_string('configstripalltitletags', 'admin'), 1));
$temp->add(new admin_setting_emoticons());
$ADMIN->add('appearance', $temp);
$ADMIN->add('appearance', new admin_externalpage('resetemoticons', get_string('emoticonsreset', 'admin'),
new moodle_url('/admin/resetemoticons.php'), 'moodle/site:config', true));
// "documentation" settingpage
$temp = new admin_settingpage('documentation', get_string('moodledocs'));
$temp->add(new admin_setting_configtext('docroot', get_string('docroot', 'admin'), get_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL));
$temp->add(new admin_setting_configcheckbox('doctonewwindow', get_string('doctonewwindow', 'admin'), get_string('configdoctonewwindow', 'admin'), 0));
$ADMIN->add('appearance', $temp);
$temp = new admin_externalpage('mypage', get_string('mypage', 'admin'), $CFG->wwwroot . '/my/indexsys.php');
$ADMIN->add('appearance', $temp);
$temp = new admin_externalpage('profilepage', get_string('myprofile', 'admin'), $CFG->wwwroot . '/user/profilesys.php');
$ADMIN->add('appearance', $temp);
// coursecontact is the person responsible for course - usually manages enrolments, receives notification, etc.
$temp = new admin_settingpage('coursecontact', get_string('courses'));
$temp->add(new admin_setting_special_coursecontact());
$temp->add(new admin_setting_configcheckbox('courselistshortnames',
get_string('courselistshortnames', 'admin'),
get_string('courselistshortnames_desc', 'admin'), 0));
$ADMIN->add('appearance', $temp);
$temp = new admin_settingpage('ajax', get_string('ajaxuse'));
$temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('useexternalyui', get_string('useexternalyui', 'admin'), get_string('configuseexternalyui', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('yuicomboloading', get_string('yuicomboloading', 'admin'), get_string('configyuicomboloading', 'admin'), 1));
$setting = new admin_setting_configcheckbox('cachejs', get_string('cachejs', 'admin'), get_string('cachejs_help', 'admin'), 1);
$setting->set_updatedcallback('js_reset_all_caches');
$temp->add($setting);
$temp->add(new admin_setting_configcheckbox('enablecourseajax', get_string('enablecourseajax', 'admin'),
get_string('enablecourseajax_desc', 'admin'), 1));
$ADMIN->add('appearance', $temp);
// link to tag management interface
$ADMIN->add('appearance', new admin_externalpage('managetags', get_string('managetags', 'tag'), "$CFG->wwwroot/tag/manage.php"));
$temp = new admin_settingpage('additionalhtml', get_string('additionalhtml', 'admin'));
$temp->add(new admin_setting_heading('additionalhtml_heading', get_string('additionalhtml_heading', 'admin'), get_string('additionalhtml_desc', 'admin')));
$temp->add(new admin_setting_configtextarea('additionalhtmlhead', get_string('additionalhtmlhead', 'admin'), get_string('additionalhtmlhead_desc', 'admin'), '', PARAM_RAW));
$temp->add(new admin_setting_configtextarea('additionalhtmltopofbody', get_string('additionalhtmltopofbody', 'admin'), get_string('additionalhtmltopofbody_desc', 'admin'), '', PARAM_RAW));
$temp->add(new admin_setting_configtextarea('additionalhtmlfooter', get_string('additionalhtmlfooter', 'admin'), get_string('additionalhtmlfooter_desc', 'admin'), '', PARAM_RAW));
$ADMIN->add('appearance', $temp);
} // end of speedup
-160
View File
@@ -1,160 +0,0 @@
<?php
// This file defines settingpages and externalpages under the "courses" category
if ($hassiteconfig
or has_capability('moodle/backup:backupcourse', $systemcontext)
or has_capability('moodle/category:manage', $systemcontext)
or has_capability('moodle/course:create', $systemcontext)
or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
$ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on',
array('moodle/category:manage', 'moodle/course:create')));
/// Course Default Settings Page
/// NOTE: these settings must be applied after all other settings because they depend on them
///main course settings
$temp = new admin_settingpage('coursesettings', get_string('coursesettings'));
$courseformats = get_plugin_list('format');
$formcourseformats = array();
foreach ($courseformats as $courseformat => $courseformatdir) {
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
}
$temp->add(new admin_setting_configselect('moodlecourse/format', get_string('format'), get_string('coursehelpformat'), 'weeks',$formcourseformats));
$temp->add(new admin_setting_configtext('moodlecourse/maxsections', get_string('maxnumberweeks'), get_string('maxnumberweeks_desc'), 52));
$temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', get_string('numberweeks'), get_string('coursehelpnumberweeks'), 10));
$choices = array();
$choices['0'] = get_string('hiddensectionscollapsed');
$choices['1'] = get_string('hiddensectionsinvisible');
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', get_string('hiddensections'), get_string('coursehelphiddensections'), 0,$choices));
$options = range(0, 10);
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', get_string('newsitemsnumber'), get_string('coursehelpnewsitemsnumber'), 5,$options));
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', get_string('showgrades'), get_string('coursehelpshowgrades'), 1,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/showreports', get_string('showreports'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
if (isset($CFG->maxbytes)) {
$choices = get_max_upload_sizes($CFG->maxbytes);
} else {
$choices = get_max_upload_sizes();
}
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', get_string('maximumupload'), get_string('coursehelpmaximumupload'), key($choices), $choices));
if (!empty($CFG->legacyfilesinnewcourses)) {
$choices = array('0'=>get_string('no'), '2'=>get_string('yes'));
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', get_string('courselegacyfiles'), get_string('courselegacyfiles_help'), key($choices), $choices));
}
$temp->add(new admin_setting_heading('groups', get_string('groups', 'group'), ''));
$choices = array();
$choices[NOGROUPS] = get_string('groupsnone', 'group');
$choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
$choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
$temp->add(new admin_setting_configselect('moodlecourse/groupmode', get_string('groupmode'), '', key($choices),$choices));
$temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', get_string('force'), get_string('coursehelpforce'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_heading('availability', get_string('availability'), ''));
$choices = array();
$choices['0'] = get_string('courseavailablenot');
$choices['1'] = get_string('courseavailable');
$temp->add(new admin_setting_configselect('moodlecourse/visible', get_string('visible'), '', 1,$choices));
$temp->add(new admin_setting_heading('language', get_string('language'), ''));
$languages=array();
$languages[''] = get_string('forceno');
$languages += get_string_manager()->get_list_of_translations();
$temp->add(new admin_setting_configselect('moodlecourse/lang', get_string('forcelanguage'), '',key($languages),$languages));
$temp->add(new admin_setting_heading('progress', get_string('progress','completion'), ''));
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', get_string('completion','completion'), '',
0, array(0 => get_string('completiondisabled','completion'), 1 => get_string('completionenabled','completion'))));
$temp->add(new admin_setting_configcheckbox('moodlecourse/completionstartonenrol', get_string('completionstartonenrol','completion'), get_string('completionstartonenrolhelp', 'completion'), 0));
$ADMIN->add('courses', $temp);
/// "courserequests" settingpage
$temp = new admin_settingpage('courserequest', get_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0));
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1));
$temp->add(new admin_setting_users_with_capability('courserequestnotify', get_string('courserequestnotify', 'admin'), get_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
$ADMIN->add('courses', $temp);
/// Pending course requests.
if (!empty($CFG->enablecourserequests)) {
$ADMIN->add('courses', new admin_externalpage('coursespending', get_string('pendingrequests'),
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
}
// Add a category for backups
$ADMIN->add('courses', new admin_category('backups', get_string('backups','admin')));
// Create a page for general backup defaults
$temp = new admin_settingpage('backupgeneralsettings', get_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse');
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_users', get_string('generalusers','backup'), get_string('configgeneralusers','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_anonymize', get_string('generalanonymize','backup'), get_string('configgeneralanonymize','backup'), array('value'=>0, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_role_assignments', get_string('generalroleassignments','backup'), get_string('configgeneralroleassignments','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_activities', get_string('generalactivities','backup'), get_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', get_string('generalblocks','backup'), get_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', get_string('generalfilters','backup'), get_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_comments', get_string('generalcomments','backup'), get_string('configgeneralcomments','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_userscompletion', get_string('generaluserscompletion','backup'), get_string('configgeneraluserscompletion','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', get_string('generallogs','backup'), get_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', get_string('generalhistories','backup'), get_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
$ADMIN->add('backups', $temp);
/// "backups" settingpage
$temp = new admin_settingpage('automated', get_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
$temp->add(new admin_setting_configselect('backup/backup_auto_active', get_string('active'), get_string('autoactivedescription', 'backup'), 0, array(
0 => get_string('autoactivedisabled', 'backup'),
1 => get_string('autoactiveenabled', 'backup'),
2 => get_string('autoactivemanual', 'backup')
)));
$temp->add(new admin_setting_special_backupdays());
$temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', get_string('executeat'),
get_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
$storageoptions = array(
0 => get_string('storagecourseonly', 'backup'),
1 => get_string('storageexternalonly', 'backup'),
2 => get_string('storagecourseandexternal', 'backup')
);
$temp->add(new admin_setting_configselect('backup/backup_auto_storage', get_string('automatedstorage', 'backup'), get_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
$temp->add(new admin_setting_configdirectory('backup/backup_auto_destination', get_string('saveto'), get_string('backupsavetohelp'), ''));
$keepoptoins = array(
0 => get_string('all'), 1 => '1',
2 => '2',
5 => '5',
10 => '10',
20 => '20',
30 => '30',
40 => '40',
50 => '50',
100 => '100',
200 => '200',
300 => '300',
400 => '400',
500 => '500');
$temp->add(new admin_setting_configselect('backup/backup_auto_keep', get_string('keep'), get_string('backupkeephelp'), 1, $keepoptoins));
$temp->add(new admin_setting_heading('automatedsettings', get_string('automatedsettings','backup'), ''));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', get_string('generalusers', 'backup'), get_string('configgeneralusers', 'backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', get_string('generalroleassignments','backup'), get_string('configgeneralroleassignments','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', get_string('generalactivities','backup'), get_string('configgeneralactivities','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', get_string('generalblocks','backup'), get_string('configgeneralblocks','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', get_string('generalfilters','backup'), get_string('configgeneralfilters','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', get_string('generalcomments','backup'), get_string('configgeneralcomments','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', get_string('generaluserscompletion','backup'), get_string('configgeneraluserscompletion','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', get_string('generallogs', 'backup'), get_string('configgenerallogs', 'backup'), 0));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', get_string('generalhistories','backup'), get_string('configgeneralhistories','backup'), 0));
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0));
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0));
$ADMIN->add('backups', $temp);
} // end of speedup
-78
View File
@@ -1,78 +0,0 @@
<?php
// * Miscellaneous settings
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
// Experimental settings page
$ADMIN->add('development', new admin_category('experimental', get_string('experimental','admin')));
$temp = new admin_settingpage('experimentalsettings', get_string('experimentalsettings', 'admin'));
//TODO: Re-enable cc-import once re-implemented in 2.0.x
//$temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0));
$temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('enablegroupmembersonly', get_string('enablegroupmembersonly', 'admin'), get_string('configenablegroupmembersonly', 'admin'), 0));
$ADMIN->add('experimental', $temp);
// "debugging" settingpage
$temp = new admin_settingpage('debugging', get_string('debugging', 'admin'));
$temp->add(new admin_setting_special_debug());
$temp->add(new admin_setting_configcheckbox('debugdisplay', get_string('debugdisplay', 'admin'), get_string('configdebugdisplay', 'admin'), ini_get_bool('display_errors')));
$temp->add(new admin_setting_configcheckbox('xmlstrictheaders', get_string('xmlstrictheaders', 'admin'), get_string('configxmlstrictheaders', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugsmtp', get_string('debugsmtp', 'admin'), get_string('configdebugsmtp', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('perfdebug', get_string('perfdebug', 'admin'), get_string('configperfdebug', 'admin'), '7', '15', '7'));
$temp->add(new admin_setting_configcheckbox('debugstringids', get_string('debugstringids', 'admin'), get_string('debugstringids_desc', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugvalidators', get_string('debugvalidators', 'admin'), get_string('configdebugvalidators', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugpageinfo', get_string('debugpageinfo', 'admin'), get_string('configdebugpageinfo', 'admin'), 0));
$ADMIN->add('development', $temp);
// "profiling" settingpage (conditionally if the 'xhprof' extension is available only)
if (extension_loaded('xhprof') && function_exists('xhprof_enable')) {
$temp = new admin_settingpage('profiling', get_string('profiling', 'admin'));
// Main profiling switch
$temp->add(new admin_setting_configcheckbox('profilingenabled', get_string('profilingenabled', 'admin'), get_string('profilingenabled_help', 'admin'), false));
// List of URLs that will be automatically profiled
$temp->add(new admin_setting_configtextarea('profilingincluded', get_string('profilingincluded', 'admin'), get_string('profilingincluded_help', 'admin'), ''));
// List of URLs that won't be profiled ever
$temp->add(new admin_setting_configtextarea('profilingexcluded', get_string('profilingexcluded', 'admin'), get_string('profilingexcluded_help', 'admin'), ''));
// Allow random profiling each XX requests
$temp->add(new admin_setting_configtext('profilingautofrec', get_string('profilingautofrec', 'admin'), get_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
// Allow PROFILEME/DONTPROFILEME GPC
$temp->add(new admin_setting_configcheckbox('profilingallowme', get_string('profilingallowme', 'admin'), get_string('profilingallowme_help', 'admin'), false));
// Allow PROFILEALL/PROFILEALLSTOP GPC
$temp->add(new admin_setting_configcheckbox('profilingallowall', get_string('profilingallowall', 'admin'), get_string('profilingallowall_help', 'admin'), false));
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
// TODO: Allow to skip call_user functions (ignored_functions array)
// Specify the life time (in minutes) of profiling runs
$temp->add(new admin_setting_configselect('profilinglifetime', get_string('profilinglifetime', 'admin'), get_string('profilinglifetime_help', 'admin'), 24*60, array(
0 => get_string('neverdeleteruns', 'admin'),
30*24*60 => get_string('numdays', '', 30),
15*24*60 => get_string('numdays', '', 15),
7*24*60 => get_string('numdays', '', 7),
4*24*60 => get_string('numdays', '', 4),
2*24*60 => get_string('numdays', '', 2),
24*60 => get_string('numhours', '', 24),
16*80 => get_string('numhours', '', 16),
8*60 => get_string('numhours', '', 8),
4*60 => get_string('numhours', '', 4),
2*60 => get_string('numhours', '', 2),
60 => get_string('numminutes', '', 60),
30 => get_string('numminutes', '', 30),
15 => get_string('numminutes', '', 15))));
// Add the 'profiling' page to admin block
$ADMIN->add('development', $temp);
}
// Web service test clients DO NOT COMMIT : THE EXTERNAL WEB PAGE IS NOT AN ADMIN PAGE !!!!!
$ADMIN->add('development', new admin_externalpage('testclient', get_string('testclient', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/testclient.php"));
if ($CFG->mnet_dispatcher_mode !== 'off') {
$ADMIN->add('development', new admin_externalpage('mnettestclient', get_string('testclient', 'mnet'), "$CFG->wwwroot/$CFG->admin/mnet/testclient.php"));
}
$ADMIN->add('development', new admin_externalpage('purgecaches', get_string('purgecaches','admin'), "$CFG->wwwroot/$CFG->admin/purgecaches.php"));
} // end of speedup

Some files were not shown because too many files have changed in this diff Show More