[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Page external API 19 * 20 * @package mod_page 21 * @category external 22 * @copyright 2015 Juan Leyva <juan@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 * @since Moodle 3.0 25 */ 26 27 defined('MOODLE_INTERNAL') || die; 28 29 require_once("$CFG->libdir/externallib.php"); 30 31 /** 32 * Page external functions 33 * 34 * @package mod_page 35 * @category external 36 * @copyright 2015 Juan Leyva <juan@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 * @since Moodle 3.0 39 */ 40 class mod_page_external extends external_api { 41 42 /** 43 * Returns description of method parameters 44 * 45 * @return external_function_parameters 46 * @since Moodle 3.0 47 */ 48 public static function view_page_parameters() { 49 return new external_function_parameters( 50 array( 51 'pageid' => new external_value(PARAM_INT, 'page instance id') 52 ) 53 ); 54 } 55 56 /** 57 * Simulate the page/view.php web interface page: trigger events, completion, etc... 58 * 59 * @param int $pageid the page instance id 60 * @return array of warnings and status result 61 * @since Moodle 3.0 62 * @throws moodle_exception 63 */ 64 public static function view_page($pageid) { 65 global $DB, $CFG; 66 require_once($CFG->dirroot . "/mod/page/lib.php"); 67 68 $params = self::validate_parameters(self::view_page_parameters(), 69 array( 70 'pageid' => $pageid 71 )); 72 $warnings = array(); 73 74 // Request and permission validation. 75 $page = $DB->get_record('page', array('id' => $params['pageid']), '*', MUST_EXIST); 76 list($course, $cm) = get_course_and_cm_from_instance($page, 'page'); 77 78 $context = context_module::instance($cm->id); 79 self::validate_context($context); 80 81 require_capability('mod/page:view', $context); 82 83 // Call the page/lib API. 84 page_view($page, $course, $cm, $context); 85 86 $result = array(); 87 $result['status'] = true; 88 $result['warnings'] = $warnings; 89 return $result; 90 } 91 92 /** 93 * Returns description of method result value 94 * 95 * @return external_description 96 * @since Moodle 3.0 97 */ 98 public static function view_page_returns() { 99 return new external_single_structure( 100 array( 101 'status' => new external_value(PARAM_BOOL, 'status: true if success'), 102 'warnings' => new external_warnings() 103 ) 104 ); 105 } 106 107 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |