コード例 #1
0
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 *
 * @usecase add
 * @usecase delete
 * @usecase save
 * @usecase import
 * @usecase doimport
 */
/* @var $OUTPUT core_renderer */
if (!defined('MOODLE_INTERNAL')) {
    die("Illegal direct access to this screen");
}
/* * ****************************** Delete a set of records **************************** */
if ($action == 'delete') {
    if (!isset($items)) {
        $items = required_param_array('items', PARAM_INT);
    }
    foreach ($items as $item) {
        $card = $DB->get_record('flashcard_deckdata', array('id' => $item));
        flashcard_delete_attached_files($cm, $flashcard, $card);
        if (!$DB->delete_records('flashcard_deckdata', array('id' => $item))) {
            print_error('errordeletecard', 'flashcard');
        }
        if (!$DB->delete_records('flashcard_card', array('entryid' => $item))) {
            print_error('errordeletecard', 'flashcard');
        }
    }
}
/* * ****************************** Prepare import **************************** */
if ($action == 'import') {
    include 'import_form.php';
コード例 #2
0
    function test_required_param_array() {
        global $CFG;

        $_POST['username'] = array('a'=>'post_user');
        $_GET['username'] = array('a'=>'get_user');
        $this->assertSame(required_param_array('username', PARAM_RAW), $_POST['username']);

        unset($_POST['username']);
        $this->assertSame(required_param_array('username', PARAM_RAW), $_GET['username']);

        // make sure exception is triggered when some params are missing, hide error notices here - new in 2.2
        $_POST['username'] = array('a'=>'post_user');
        try {
            required_param_array('username', null);
            $this->fail('coding_exception expected');
        } catch (coding_exception $ex) {
            $this->assertTrue(true);
        }
        try {
            @required_param_array('username');
            $this->fail('coding_exception expected');
        } catch (coding_exception $ex) {
            $this->assertTrue(true);
        }
        try {
            required_param_array('', PARAM_RAW);
            $this->fail('coding_exception expected');
        } catch (coding_exception $ex) {
            $this->assertTrue(true);
        }

        // do not allow nested arrays
        try {
            $_POST['username'] = array('a'=>array('b'=>'post_user'));
            required_param_array('username', PARAM_RAW);
            $this->fail('coding_exception expected');
        } catch (coding_exception $ex) {
            $this->assertTrue(true);
        }

        // do not allow non-arrays
        try {
            $_POST['username'] = '******';
            required_param_array('username', PARAM_RAW);
            $this->fail('moodle_exception expected');
        } catch (moodle_exception $ex) {
            $this->assertTrue(true);
        }

        // do not allow non-arrays
        $debugging = isset($CFG->debug) ? $CFG->debug : null;
        $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null;
        $CFG->debug = DEBUG_DEVELOPER;
        $CFG->debugdisplay = true;

        // make sure array keys are sanitised
        ob_start();
        $_POST['username'] = array('abc123_;-/*-+ '=>'arrggh', 'a1_-'=>'post_user');
        $this->assertSame(required_param_array('username', PARAM_RAW), array('a1_-'=>'post_user'));
        $d = ob_end_clean();
        $this->assertTrue($d !== '');

        if ($debugging !== null) {
            $CFG->debug = $debugging;
        } else {
            unset($CFG->debug);
        }
        if ($debugdisplay !== null) {
            $CFG->debugdisplay = $debugdisplay;
        } else {
            unset($CFG->debugdisplay);
        }
    }
コード例 #3
0
 /**
  * view import-tab
  */
 public function view_import()
 {
     global $PAGE, $OUTPUT;
     require_capability('mod/grouptool:register_students', $this->context);
     $id = $this->cm->id;
     $form = new \mod_grouptool\import_form(null, array('id' => $id));
     if (optional_param('confirm', 0, PARAM_BOOL)) {
         $group = required_param_array('group', PARAM_INT);
         $data = required_param('data', PARAM_RAW);
         $includedeleted = optional_param('includedeleted', 0, PARAM_BOOL);
         $forceregistration = optional_param('forceregistration', 0, PARAM_BOOL);
         if (!empty($data)) {
             $data = unserialize($data);
         }
         list($error, $message) = $this->import($group, $data, $forceregistration, $includedeleted);
         if (!empty($error)) {
             $message = $OUTPUT->notification(get_string('ignored_not_found_users', 'grouptool'), 'notifyproblem') . html_writer::empty_tag('br') . $message;
         }
         echo html_writer::tag('div', $message, array('class' => 'centered'));
     }
     if ($fromform = $form->get_data()) {
         // Display confirm message - so we "try" only!
         list($error, $confirmmessage) = $this->import($fromform->group, $fromform->data, $fromform->forceregistration, $fromform->includedeleted, true);
         $attr = array('confirm' => '1', 'data' => serialize($fromform->data), 'forceregistration' => $fromform->forceregistration, 'includedeleted' => $fromform->includedeleted);
         foreach ($fromform->group as $group) {
             $attr['group[' . $group . ']'] = $group;
         }
         $continue = new moodle_url($PAGE->url, $attr);
         $cancel = new moodle_url($PAGE->url);
         if ($error) {
             $confirmmessage = $OUTPUT->notification(get_string('ignoring_not_found_users', 'grouptool'), 'notifyproblem') . html_writer::empty_tag('br') . $confirmmessage;
         }
         echo $OUTPUT->heading(get_string('preview', 'grouptool'), 2, 'centered') . $confirmmessage . $this->confirm('', $continue, $cancel);
     } else {
         $form->display();
     }
 }
コード例 #4
0
ファイル: preferences.php プロジェクト: anilch/Personel
        $params = array_merge($att->pageparams->get_significant_params(), array('confirm' => 1));
        echo $OUTPUT->header();
        echo $OUTPUT->heading(get_string('attendanceforthecourse', 'local_attendance').' :: ' .$course->fullname);
        echo $OUTPUT->confirm($message, $att->url_preferences($params), $att->url_preferences());
        echo $OUTPUT->footer();
        exit;
    case local_att_preferences_page_params::ACTION_HIDE:
        $att->update_status($att->pageparams->statusid, null, null, null, 0);
        break;
    case local_att_preferences_page_params::ACTION_SHOW:
        $att->update_status($att->pageparams->statusid, null, null, null, 1);
        break;
    case local_att_preferences_page_params::ACTION_SAVE:
        $acronym        = required_param_array('acronym', PARAM_MULTILANG);
        $description    = required_param_array('description', PARAM_MULTILANG);
        $grade          = required_param_array('grade', PARAM_INT);

        foreach ($acronym as $id => $v) {
            $att->update_status($id, $acronym[$id], $description[$id], $grade[$id], null);
        }
        if ($att->grade > 0) {
            local_att_update_all_users_grades($att->id, $att->semesterinfo, $att->context, $att->classinfo, $att);
        }
        break;
}

$output = $PAGE->get_renderer('local_attendance');
$tabs = new local_attendance_tabs($att, local_attendance_tabs::TAB_PREFERENCES);
$prefdata = new local_attendance_preferences_data($att);

// Output starts here.
コード例 #5
0
ファイル: moodlelib.php プロジェクト: lucaboesch/moodle
/**
 * Returns a particular value for the named variable, taken from
 * POST or GET.  If the parameter doesn't exist then an error is
 * thrown because we require this variable.
 *
 * This function should be used to initialise all required values
 * in a script that are based on parameters.  Usually it will be
 * used like this:
 *    $id = required_param('id', PARAM_INT);
 *
 * Please note the $type parameter is now required and the value can not be array.
 *
 * @param string $parname the name of the page parameter we want
 * @param string $type expected type of parameter
 * @return mixed
 * @throws coding_exception
 */
function required_param($parname, $type)
{
    if (func_num_args() != 2 or empty($parname) or empty($type)) {
        throw new coding_exception('required_param() requires $parname and $type to be specified (parameter: ' . $parname . ')');
    }
    // POST has precedence.
    if (isset($_POST[$parname])) {
        $param = $_POST[$parname];
    } else {
        if (isset($_GET[$parname])) {
            $param = $_GET[$parname];
        } else {
            print_error('missingparam', '', '', $parname);
        }
    }
    if (is_array($param)) {
        debugging('Invalid array parameter detected in required_param(): ' . $parname);
        // TODO: switch to fatal error in Moodle 2.3.
        return required_param_array($parname, $type);
    }
    return clean_param($param, $type);
}
コード例 #6
0
                        echo $OUTPUT->footer($course);
                        exit;
                    }
                }
                if (!$exist_flag) {
                    if (empty($classids)) {
                        $classids = required_param_array('classids', PARAM_INTEGER);
                    }
                    if (empty($classnames)) {
                        $classnames = required_param_array('classnames', PARAM_TEXT);
                    }
                    if (empty($classdels)) {
                        $classdels = optional_param_array('classdels', array(), PARAM_INTEGER);
                    }
                    autoattend_update_session_classes($classids, $classnames, $classdels);
                }
            } else {
                if (isset($formdata->submit_delete) and $confirm) {
                    $classids = required_param_array('classids', PARAM_INTEGER);
                    $classnames = required_param_array('classnames', PARAM_TEXT);
                    $classdels = optional_param_array('classdels', array(), PARAM_INTEGER);
                    autoattend_update_session_classes($classids, $classnames, $classdels);
                }
            }
        }
    }
    //
    $classes = autoattend_get_session_classes($course->id);
    include 'html/class_settings.html';
}
echo $OUTPUT->footer($course);
コード例 #7
0
     if (!$overwrite) {
         $scannedpage = offlinequiz_check_scanned_page($offlinequiz, $scanner, $scannedpage, $USER->id, $coursecontext);
         if ($scannedpage->status == 'error' && $scannedpage->error == 'resultexists') {
             // Already process the answers but don't submit them.
             $scannedpage = offlinequiz_process_scanned_page($offlinequiz, $scanner, $scannedpage, $USER->id, $questionsperpage, $coursecontext, false);
             // Compare the old and the new result wrt. the choices.
             $scannedpage = offlinequiz_check_different_result($scannedpage);
         }
     }
     $userkey = $scannedpage->userkey;
     $usernumber = substr($userkey, strlen($offlinequizconfig->ID_prefix), $offlinequizconfig->ID_digits);
     $groupnumber = intval($scannedpage->groupnumber);
     $pagenumber = intval($scannedpage->pagenumber);
     $DB->update_record('offlinequiz_scanned_pages', $scannedpage);
     // The updated item information (crosses), will be processed later.
     $rawitemdata = required_param_array('item', PARAM_RAW);
     // O=============================================.
     // O Action rotate.
     // O=============================================.
 } else {
     if ($action == 'rotate') {
         if (!confirm_sesskey()) {
             print_error('invalidsesskey');
             echo "<input class=\"imagebutton\" type=\"submit\" value=\"" . get_string('cancel') . "\" name=\"submitbutton4\"\nonClick=\"self.close(); return false;\"><br />";
             die;
         }
         if ($newfile = $scanner->rotate_180()) {
             // Maybe old errors have been fixed.
             $scannedpage->status = 'ok';
             $scannedpage->error = '';
             $scannedpage->userkey = null;
コード例 #8
0
     if ($DB->get_field('grouptool_agrps', 'active', array('groupid' => $groupid, 'grouptoolid' => $cm->instance)) == 1) {
         $result->error = "Couldn't deactivate group " . $groupid . " in grouptool " . $cm->instance . "!";
     } else {
         $result->message = "Deactivated group " . $groupid . " in grouptool " . $cm->instance . "!";
     }
     if ($filter == mod_grouptool::FILTER_ACTIVE && !$DB->count_records('grouptool_agrps', array('grouptoolid' => $cm->instance, 'active' => 1))) {
         $url = new moodle_url($PAGE->url, array('id' => $cm->instance, 'tab' => 'group_admin', 'filter' => mod_grouptool::FILTER_ALL));
         $message = get_string('nogroupsactive', 'grouptool') . ' ' . html_writer::link($url, get_string('nogroupschoose', 'grouptool'));
         $result->noentriesmessage = $OUTPUT->box($coreoutput->notification($message, 'notifymessage'), 'generalbox', 'nogroupsinfo');
     } else {
         $result->noentriesmessage = '';
     }
     break;
 case 'reorder':
     // Reorder groups...
     $data = required_param_array('order', PARAM_INT);
     $failed = array();
     $missing = array();
     foreach ($data as $groupid => $order) {
         if (!$DB->record_exists('grouptool_agrps', array('groupid' => $groupid, 'grouptoolid' => $cm->instance))) {
             // Insert missing record!
             $newrecord = new stdClass();
             $newrecord->groupid = $groupid;
             $newrecord->grouptoolid = $cm->instance;
             $newrecord->active = 0;
             $newrecord->sort_order = $order;
             $DB->insert_record('grouptool_agrps', $newrecord);
             $missing[] = "groupid " . $groupid;
         } else {
             $DB->set_field('grouptool_agrps', 'sort_order', $order, array('groupid' => $groupid, 'grouptoolid' => $cm->instance));
             if (!$DB->record_exists('grouptool_agrps', array('groupid' => $groupid, 'grouptoolid' => $cm->instance, 'sort_order' => $order))) {
コード例 #9
0
ファイル: save.php プロジェクト: alanaipe2015/moodle
<?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/>.
/**
 * Save course order in course_overview block
 *
 * @package    block_course_overview
 * @copyright  2012 Adam Olley <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('AJAX_SCRIPT', true);
require_once dirname(__FILE__) . '/../../config.php';
require_once dirname(__FILE__) . '/locallib.php';
require_sesskey();
require_login();
$sortorder = required_param_array('sortorder', PARAM_INT);
block_course_overview_update_myorder($sortorder);
コード例 #10
0
     echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attendance') . ' :: ' . $course->fullname);
     echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage());
     echo $OUTPUT->footer();
     exit;
 case att_sessions_page_params::ACTION_DELETE_SELECTED:
     $confirm = optional_param('confirm', null, PARAM_INT);
     if (isset($confirm) && confirm_sesskey()) {
         $sessionsids = required_param('sessionsids', PARAM_ALPHANUMEXT);
         $sessionsids = explode('_', $sessionsids);
         $att->delete_sessions($sessionsids);
         if ($att->grade > 0) {
             att_update_all_users_grades($att->id, $att->course, $att->context, $cm);
         }
         redirect($att->url_manage(), get_string('sessiondeleted', 'attendance'));
     }
     $sessid = required_param_array('sessid', PARAM_SEQUENCE);
     $sessionsinfo = $att->get_sessions_info($sessid);
     $message = get_string('deletecheckfull', '', get_string('session', 'attendance'));
     $message .= html_writer::empty_tag('br');
     foreach ($sessionsinfo as $sessinfo) {
         $message .= html_writer::empty_tag('br');
         $message .= userdate($sessinfo->sessdate, get_string('strftimedmyhm', 'attendance'));
         $message .= html_writer::empty_tag('br');
         $message .= $sessinfo->description;
     }
     $sessionsids = implode('_', $sessid);
     $params = array('action' => $att->pageparams->action, 'sessionsids' => $sessionsids, 'confirm' => 1, 'sesskey' => sesskey());
     echo $OUTPUT->header();
     echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attendance') . ' :: ' . $course->fullname);
     echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage());
     echo $OUTPUT->footer();
コード例 #11
0
ファイル: report.php プロジェクト: kevin-bruton/marsupial
$book = $DB->get_record('rcommon_books', array('id' => $rcontent->bookid));
if ($book) {
    $bookname = $book->name;
} else {
    $bookname = $rcontent->bookid;
}
$baseurl = $CFG->wwwroot . "/mod/rcontent/report.php?id={$id}";
if (!empty($user)) {
    $userdata = rcontent_get_user_data($user);
    $navurl = "{$baseurl}&user={$user}&attempt={$attempt}";
    $PAGE->navbar->add(fullname($userdata), new moodle_url($navurl), null, navigation_node::TYPE_CUSTOM, null);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($rcontent->name) . ' (' . $bookname . ')');
if ($candeleteresponses && $action == 'delete') {
    $attemptids = required_param_array('attemptid', PARAM_RAW);
    // Get array of responses to delete.
    if (rcontent_delete_responses($attemptids, $rcontent->id)) {
        // Delete responses.
        echo $OUTPUT->notification(get_string('responsedeleted', 'rcontent'), 'notifysuccess');
    }
}
// In case that the user is a student in course context load from db just his registries
$userrol = array_values(get_user_roles($contextmodule));
if (empty($user)) {
    // Filter by status, get parameter with the filterby
    $filterby = optional_param('filterby', '', PARAM_RAW);
    $optionsparam = !empty($filterby) ? $filterby : "";
    $menu = array();
    $menu[''] = get_string('all');
    $menu['NO_INICIADO'] = get_string('NO_INICIADO', 'rcontent');
コード例 #12
0
     $urx = $upperright->x;
     $ury = $upperright->y;
     $llx = $lowerleft->x;
     $lly = $lowerleft->y;
     $lrx = $lowerright->x;
     $lry = $lowerright->y;
     // Initialise a new page scanner.
     $scanner = new offlinequiz_participants_scanner($offlinequiz, $context->id, 0, 0);
     $sheetloaded = $scanner->load_stored_image($scannedpage->filename, array($upperleft, $upperright, $lowerleft, $lowerright));
     // The following calibrates the scanner.
     $scanner->get_list();
     $OUTPUT->heading(get_string('participantslist', 'offlinequiz'));
     $listid = required_param('listid', PARAM_INT);
     // Get the values chosen by the user.
     $newparticipants = required_param_array('participants', PARAM_RAW);
     $userid = required_param_array('userid', PARAM_RAW);
     // Maybe old errors have been fixed.
     $scannedpage->status = 'ok';
     $scannedpage->error = '';
     if ($list = $DB->get_record('offlinequiz_p_lists', array('id' => $listid))) {
         $scannedpage->listnumber = intval($list->number);
     }
     // -------------------------------------------------------------
     //       Action setlist
     // -------------------------------------------------------------
 } else {
     if ($action == 'setlist') {
         $upperleft = new oq_point(required_param('c-0-x', PARAM_INT) + 8, required_param('c-0-y', PARAM_INT) + 8);
         $upperright = new oq_point(required_param('c-1-x', PARAM_INT) + 8, required_param('c-1-y', PARAM_INT) + 8);
         $lowerleft = new oq_point(required_param('c-2-x', PARAM_INT) + 8, required_param('c-2-y', PARAM_INT) + 8);
         $lowerright = new oq_point(required_param('c-3-x', PARAM_INT) + 8, required_param('c-3-y', PARAM_INT) + 8);
コード例 #13
0
$numcolumns = required_param('numcolumns', PARAM_INT);
$url1 = "labels.php?a={$blended->id}";
//Comprobación de que el numero de filas y columnas no supera los valores máximos
if ($numrows > 30 || $numrows < 1 || $numcolumns < 1 || $numcolumns > 10) {
    notice('Los tamaños elegidos no son valores permitidos', $url1);
} else {
    list($studentids, $nonstudentids, $activeids, $users) = blended_get_users_by_type($context_course);
    switch ($whatstudents) {
        case 'active':
            $userids = $activeids;
            break;
        case 'all':
            $userids = $studentids;
            break;
        case 'list':
            $userListcode = required_param_array('users', PARAM_RAW);
            // compose a page with this users
            $total = $numcolumns * $numrows;
            $num = count($userListcode);
            $numpages = ceil($num / $total);
            $repeat = $numpages * $total / $num;
            $userids = array();
            foreach ($userListcode as $uid) {
                for ($i = 0; $i < $repeat; $i++) {
                    $userids[] = $uid;
                    if (count($userids) == $total) {
                        break;
                    }
                }
            }
            break;
コード例 #14
0
ファイル: publish.php プロジェクト: jorgecabane93/eMarkingWeb
 * @package mod
 * @subpackage emarking
 * @copyright 2012 Jorge Villalon <*****@*****.**>
 * @copyright 2014 Nicolas Perez <*****@*****.**>
 * @copyright 2014 Carlos Villarroel <*****@*****.**>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('NO_OUTPUT_BUFFERING', true);
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once "{$CFG->dirroot}/lib/weblib.php";
require_once $CFG->dirroot . '/repository/lib.php';
require_once $CFG->dirroot . '/mod/emarking/locallib.php';
//cambiar
global $DB, $CFG, $USER;
$cmid = required_param('id', PARAM_INT);
$submissions = required_param_array('publish', PARAM_INTEGER);
// Validate course module
if (!($cm = get_coursemodule_from_id('emarking', $cmid))) {
    print_error(get_string('invalidcoursemodule', 'mod_emarking'));
}
// Validate emarking activity
if (!($emarking = $DB->get_record('emarking', array('id' => $cm->instance)))) {
    print_error(get_string('invalidemarkingid', 'mod_emarking') . ':' . $emarkingid);
}
// Validate course
if (!($course = $DB->get_record('course', array('id' => $emarking->course)))) {
    print_error(get_string('invalidcourseid', 'mod_emarking') . ': ' . $emarking->course);
}
// Get context for module
$context = context_module::instance($cm->id);
// Validate user is logged in and is not guest
コード例 #15
0
ファイル: lib.php プロジェクト: jamesmcq/elis
 /**
  * Responds to a request to modify the bulklist.
  *
  * Required $_REQUEST parameters:
  *     string $sesskey The CSRF-protection 'sesskey' variable.
  *     string $modify  Either "add" or "remove" - determines what to do with the $ids input.
  *     array  $ids     An array of IDs to add or remove.
  *
  * Outputs XSSI-safe-JSON containing 'result', 'page_results', and 'total_results', outlined below:
  *     string  result              'success' to indicate we successfully completed the request.
  *     array   page_results_ids    An array of IDs for the current page of results in the same order as page_results_values.
  *     array   page_results_values An array of labels for the current page of results, in the same order as page_results_ids.
  *     int     total_results       The total number of results in the dataset.
  */
 protected function respond_bulklist_modify()
 {
     require_sesskey();
     $mode = required_param('modify', PARAM_CLEAN);
     if ($mode !== 'add' && $mode != 'remove') {
         throw new Exception('Did not understand request');
     }
     $ids = required_param_array('ids', PARAM_CLEAN);
     if ($mode === 'add') {
         $this->bulklist_modify($ids);
     } else {
         if ($mode === 'remove') {
             $this->bulklist_modify(array(), $ids);
         }
     }
     list($pageresults, $totalresults) = $this->bulklist_get_display(1);
     echo safe_json_encode(array('result' => 'success', 'page_results_ids' => array_keys($pageresults), 'page_results_values' => array_values($pageresults), 'total_results' => $totalresults));
 }
コード例 #16
0
/**
 * grantextension.php
 *
 * @package       mod_publication
 * @author        Andreas Hruska (andreas.hruska@tuwien.ac.at)
 * @author        Katarzyna Potocka (katarzyna.potocka@tuwien.ac.at)
 * @author        Andreas Windbichler
 * @copyright     2014 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
 * @license       http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/mod/publication/locallib.php';
require_once $CFG->dirroot . '/mod/publication/mod_publication_grantextension_form.php';
$id = optional_param('id', 0, PARAM_INT);
// Course Module ID.
$userids = required_param_array('userids', PARAM_INT);
// User id.
$url = new moodle_url('/mod/publication/grantextension.php', array('id' => $id));
if (!($cm = get_coursemodule_from_id('publication', $id, 0, false, MUST_EXIST))) {
    print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST))) {
    print_error('coursemisconf');
}
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/publication:grantextension', $context);
$publication = new publication($context, $cm, $course);
$url = new moodle_url('/mod/publication/grantextension.php', array('cmid' => $cm->id));
if (!empty($id)) {
    $url->param('id', $id);
コード例 #17
0
require_login();
require_capability('local/rcommon:managecredentials', context_system::instance());
require_once $CFG->libdir . '/adminlib.php';
$action = required_param('action', PARAM_ACTION);
$referer = $_SERVER["HTTP_REFERER"];
switch ($action) {
    case 'unassign':
        $ids = required_param_array('ids', PARAM_INT);
        if (credentials::bulk_unassign($ids)) {
            redirect($referer, get_string('keymanager_unassing_ok', 'local_rcommon'), 2);
        } else {
            redirect($referer, get_string('keymanager_unassing_ko', 'local_rcommon'), 5);
        }
        break;
    case 'delete':
        $ids = required_param_array('ids', PARAM_INT);
        if (credentials::bulk_delete($ids)) {
            redirect($referer, get_string('keymanager_delete_ok', 'local_rcommon'), 2);
        } else {
            redirect($referer, get_string('keymanager_delete_ko', 'local_rcommon'), 5);
        }
        break;
}
if ($action != 'assign') {
    print_error('Unknown action ' . $action);
}
$id = required_param('id', PARAM_INT);
$book = $DB->get_record('rcommon_books', array('id' => $id));
admin_externalpage_setup('marsupialcontent' . $book->publisherid);
echo $OUTPUT->header();
//key synchronization
コード例 #18
0
 * Bulk user enrolment processing.
 *
 * @package    core
 * @subpackage enrol
 * @copyright  2011 Sam Hemelryk
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require '../config.php';
require_once "{$CFG->dirroot}/enrol/locallib.php";
require_once "{$CFG->dirroot}/enrol/users_forms.php";
require_once "{$CFG->dirroot}/enrol/renderer.php";
require_once "{$CFG->dirroot}/group/lib.php";
$id = required_param('id', PARAM_INT);
// course id
$bulkuserop = required_param('bulkuserop', PARAM_ALPHANUMEXT);
$userids = required_param_array('bulkuser', PARAM_INT);
$action = optional_param('action', '', PARAM_ACTION);
$filter = optional_param('ifilter', 0, PARAM_INT);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
if ($course->id == SITEID) {
    redirect(new moodle_url('/'));
}
require_login($course);
require_capability('moodle/course:enrolreview', $context);
$PAGE->set_pagelayout('admin');
$manager = new course_enrolment_manager($PAGE, $course, $filter);
$table = new course_enrolment_users_table($manager, $PAGE);
$returnurl = new moodle_url('/enrol/users.php', $table->get_combined_url_params());
$actionurl = new moodle_url('/enrol/bulkchange.php', $table->get_combined_url_params() + array('bulkuserop' => $bulkuserop));
$PAGE->set_url($actionurl);
コード例 #19
0
        echo $OUTPUT->footer();
        exit;
    case att_preferences_page_params::ACTION_HIDE:
        $statuses = $att->get_statuses(false);
        $status = $statuses[$att->pageparams->statusid];
        $att->update_status($status, null, null, null, 0);
        break;
    case att_preferences_page_params::ACTION_SHOW:
        $statuses = $att->get_statuses(false);
        $status = $statuses[$att->pageparams->statusid];
        $att->update_status($status, null, null, null, 1);
        break;
    case att_preferences_page_params::ACTION_SAVE:
        $acronym = required_param_array('acronym', PARAM_TEXT);
        $description = required_param_array('description', PARAM_TEXT);
        $grade = required_param_array('grade', PARAM_RAW);
        foreach ($grade as &$val) {
            $val = unformat_float($val);
        }
        $statuses = $att->get_statuses(false);
        foreach ($acronym as $id => $v) {
            $status = $statuses[$id];
            $errors[$id] = $att->update_status($status, $acronym[$id], $description[$id], $grade[$id], null);
        }
        if ($att->grade > 0) {
            att_update_all_users_grades($att->id, $att->course, $att->context, $cm);
        }
        break;
}
$output = $PAGE->get_renderer('mod_attendance');
$tabs = new attendance_tabs($att, attendance_tabs::TAB_PREFERENCES);
コード例 #20
0
 public function test_required_param_array()
 {
     global $CFG;
     $_POST['username'] = array('a' => 'post_user');
     $_GET['username'] = array('a' => 'get_user');
     $this->assertSame($_POST['username'], required_param_array('username', PARAM_RAW));
     unset($_POST['username']);
     $this->assertSame($_GET['username'], required_param_array('username', PARAM_RAW));
     // Make sure exception is triggered when some params are missing, hide error notices here - new in 2.2.
     $_POST['username'] = array('a' => 'post_user');
     try {
         required_param_array('username', null);
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         @required_param_array('username');
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         required_param_array('', PARAM_RAW);
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     // Do not allow nested arrays.
     try {
         $_POST['username'] = array('a' => array('b' => 'post_user'));
         required_param_array('username', PARAM_RAW);
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     // Do not allow non-arrays.
     try {
         $_POST['username'] = '******';
         required_param_array('username', PARAM_RAW);
         $this->fail('moodle_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('moodle_exception', $ex);
     }
     // Make sure array keys are sanitised.
     $_POST['username'] = array('abc123_;-/*-+ ' => 'arrggh', 'a1_-' => 'post_user');
     $this->assertSame(array('a1_-' => 'post_user'), required_param_array('username', PARAM_RAW));
     $this->assertDebuggingCalled();
 }
コード例 #21
0
ファイル: page.class.php プロジェクト: jamesmcq/elis
 /**
  * Get required page parameters as an array
  *
  *  Note: arrays of arrays are not supported, only alphanumeric keys with _ and - are supported
  *
  * @param string $parname the name of the page parameter we want
  * @param string $type expected type of parameter
  * @return array
  */
 public function required_param_array($name, $type = PARAM_CLEAN)
 {
     if ($this->params !== null) {
         if (isset($this->params[$name])) {
             $result = array();
             foreach ($this->params[$name] as $key => $value) {
                 if (!preg_match('/^[a-z0-9_-]+$/i', $key)) {
                     debugging('Invalid key name in required_param_array() detected: ' . $key . ', parameter: ' . $parname);
                     continue;
                 }
                 $result[$key] = clean_param($value, $type);
             }
             return $result;
         } else {
             print_error('missingparam', '', '', $name);
         }
     } else {
         return required_param_array($name, $type);
     }
 }