Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/wiki/files.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
00016 
00026 require_once('../../config.php');
00027 require_once($CFG->dirroot . '/mod/wiki/lib.php');
00028 require_once($CFG->dirroot . '/mod/wiki/locallib.php');
00029 
00030 $pageid       = required_param('pageid', PARAM_INT); // Page ID
00031 $wid          = optional_param('wid', 0, PARAM_INT); // Wiki ID
00032 $currentgroup = optional_param('group', 0, PARAM_INT); // Group ID
00033 $userid       = optional_param('uid', 0, PARAM_INT); // User ID
00034 $groupanduser = optional_param('groupanduser', null, PARAM_TEXT);
00035 
00036 if (!$page = wiki_get_page($pageid)) {
00037     print_error('incorrectpageid', 'wiki');
00038 }
00039 
00040 if ($groupanduser) {
00041     list($currentgroup, $userid) = explode('-', $groupanduser);
00042     $currentgroup = clean_param($currentgroup, PARAM_INT);
00043     $userid       = clean_param($userid, PARAM_INT);
00044 }
00045 
00046 if ($wid) {
00047     // in group mode
00048     if (!$wiki = wiki_get_wiki($wid)) {
00049         print_error('incorrectwikiid', 'wiki');
00050     }
00051     if (!$subwiki = wiki_get_subwiki_by_group($wiki->id, $currentgroup, $userid)) {
00052         // create subwiki if doesn't exist
00053         $subwikiid = wiki_add_subwiki($wiki->id, $currentgroup, $userid);
00054         $subwiki = wiki_get_subwiki($subwikiid);
00055     }
00056 } else {
00057     // no group
00058     if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
00059         print_error('incorrectsubwikiid', 'wiki');
00060     }
00061 
00062     // Checking wiki instance of that subwiki
00063     if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
00064         print_error('incorrectwikiid', 'wiki');
00065     }
00066 }
00067 
00068 // Checking course module instance
00069 if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
00070     print_error('invalidcoursemodule');
00071 }
00072 
00073 // Checking course instance
00074 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
00075 
00076 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00077 
00078 
00079 $PAGE->set_url('/mod/wiki/files.php', array('pageid'=>$pageid));
00080 require_login($course, true, $cm);
00081 $PAGE->set_context($context);
00082 $PAGE->set_title(get_string('wikifiles', 'wiki'));
00083 $PAGE->set_heading(get_string('wikifiles', 'wiki'));
00084 $PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki')));
00085 echo $OUTPUT->header();
00086 
00087 $renderer = $PAGE->get_renderer('mod_wiki');
00088 
00089 $tabitems = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments', 'history' => 'history', 'map' => 'map', 'files' => 'files');
00090 
00091 $options = array('activetab'=>'files');
00092 echo $renderer->tabs($page, $tabitems, $options);
00093 
00094 
00095 echo $OUTPUT->box_start('generalbox');
00096 if (has_capability('mod/wiki:viewpage', $context)) {
00097     echo $renderer->wiki_print_subwiki_selector($PAGE->activityrecord, $subwiki, $page, 'files');
00098     echo $renderer->wiki_files_tree($context, $subwiki);
00099 } else {
00100     echo $OUTPUT->notification(get_string('cannotviewfiles', 'wiki'));
00101 }
00102 echo $OUTPUT->box_end();
00103 
00104 if (has_capability('mod/wiki:managefiles', $context)) {
00105     echo $OUTPUT->single_button(new moodle_url('/mod/wiki/filesedit.php', array('subwiki'=>$subwiki->id, 'pageid'=>$pageid)), get_string('editfiles', 'wiki'), 'get');
00106 }
00107 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations