当前位置: 首页>>代码示例>>PHP>>正文


PHP required_param函数代码示例

本文整理汇总了PHP中required_param函数的典型用法代码示例。如果您正苦于以下问题:PHP required_param函数的具体用法?PHP required_param怎么用?PHP required_param使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了required_param函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AppendSudokuB

function AppendSudokuB()
{
    global $DB;
    $level1 = required_param('level1', PARAM_NUMBER);
    // action
    $level2 = required_param('level2', PARAM_NUMBER);
    // action
    $count = required_param('count', PARAM_NUMBER);
    // action
    $level = $level1;
    for ($i = 1; $i <= $count; $i++) {
        //set_time_limit( 30);
        Create($si, $sp, $level);
        $newrec->data = PackSudoku($si, $sp);
        if (strlen($newrec->data) != 81) {
            return 0;
        }
        $newrec->level = $level;
        $newrec->opened = GetOpened($si);
        $DB->insert_record('game_sudoku_database', $newrec, true);
        $level++;
        if ($level > $level2) {
            $level = $level1;
        }
        echo get_string('sudoku_creating', 'game', $i) . "<br>\r\n";
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:27,代码来源:create.php

示例2: definition

 function definition()
 {
     $mform =& $this->_form;
     if ($this->number >= 0) {
         $title = get_string('variation', VPL, "{$this->number}");
     } else {
         $title = get_string('add');
     }
     $mform->addElement('header', 'variation' . ($this->number + 100), $title);
     $mform->addElement('hidden', 'id', required_param('id', PARAM_INT));
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'varid', $this->varid);
     $mform->setType('varid', PARAM_INT);
     $mform->addElement('text', 'identification', get_string('varidentification', VPL), array('size' => '20'));
     $mform->setDefault('identification', '');
     $mform->setType('identification', PARAM_RAW);
     $mform->addElement('textarea', 'description', get_string('description', VPL), array('cols' => 45, 'rows' => 5));
     $mform->setType('description', PARAM_CLEANHTML);
     $mform->setDefault('description', '');
     $buttongroup = array();
     $buttongroup[] = $mform->createElement('submit', 'save', get_string('save', VPL));
     $buttongroup[] = $mform->createElement('submit', 'cancel', get_string('cancel'));
     if ($this->number >= 0) {
         $menssage = addslashes(get_string('delete'));
         $onclick = 'onclick="return confirm(\'' . $menssage . '\')"';
         $buttongroup[] = $mform->createElement('submit', 'delete', get_string('delete'), $onclick);
     }
     $mform->addGroup($buttongroup);
 }
开发者ID:go38,项目名称:moodle-mod_vpl,代码行数:29,代码来源:variations.php

示例3: _respond_to_js

 /**
  * Responds to a javascript request.
  *
  * Processes incoming information and updates the relevant user's information, including learning objectives.
  * Also responds to a request for enrolment data, used when editing a single user.
  *
  * @param array $elements An array of elements to perform the action on. Although the values will differ, the indexes
  *                        will always be element IDs.
  * @param bool $bulkaction Whether this is a bulk-action or not.
  * @return array A response array, consisting of result and msg.
  */
 protected function _respond_to_js(array $elements, $bulkaction)
 {
     $classid = required_param('id', PARAM_INT);
     $mode = optional_param('mode', 'complete', PARAM_ALPHA);
     if ($mode == 'getinfo') {
         foreach ($elements as $userid => $label) {
             return array('result' => 'success', 'msg' => 'Success', 'enroldata' => $this->get_enrol_data($userid, $classid));
         }
     } else {
         set_time_limit(0);
         // Enrolment data.
         $enroldata = required_param('enroldata', PARAM_CLEAN);
         $enroldata = $this->process_enrolment_data($classid, @json_decode($enroldata));
         if (empty($enroldata)) {
             throw new Exception('Did not receive valid enrolment data.');
         }
         // Learning objectives.
         $learningobjectives = optional_param('learnobjdata', '', PARAM_CLEAN);
         $learningobjectives = !empty($learningobjectives) ? $this->process_learning_objectives_data($learningobjectives) : array();
         foreach ($elements as $userid => $label) {
             $this->do_update($userid, $classid, $enroldata, $learningobjectives);
         }
         $formattedenroldata = $this->format_enroldata_for_display($enroldata);
     }
     return array('result' => 'success', 'msg' => 'Success', 'enroldata' => $enroldata, 'displaydata' => $formattedenroldata);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:37,代码来源:enroledit.action.php

示例4: invoke

 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     $this->does_generate = ACTION_NONE;
     //$this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $dirpath;
     /// Get the correct dirs
     if (!empty($XMLDB->dbdirs)) {
         $dbdir =& $XMLDB->dbdirs[$dirpath];
     } else {
         return false;
     }
     if (!empty($XMLDB->editeddirs)) {
         $editeddir =& $XMLDB->editeddirs[$dirpath];
         $structure =& $editeddir->xml_file->getStructure();
     }
     /// ADD YOUR CODE HERE
     /// Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:36,代码来源:template.class.php

示例5: definition

 function definition()
 {
     global $CFG, $DB;
     $mform =& $this->_form;
     // this hack is needed for different settings of each subtype
     if (!empty($this->_instance)) {
         if ($res = $DB->get_record('resource', array('id' => $this->_instance))) {
             $type = $res->type;
         } else {
             print_error('invalidassignment', 'resource');
         }
     } else {
         $type = required_param('type', PARAM_ALPHA);
     }
     $mform->addElement('hidden', 'type', $type);
     $mform->setDefault('type', $type);
     require $CFG->dirroot . '/mod/resource/type/' . $type . '/resource.class.php';
     $resclass = 'resource_' . $type;
     $this->_resinstance = new $resclass();
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '48'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEAN);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $this->add_intro_editor(false);
     $mform->addElement('header', 'typedesc', resource_get_name($type));
     $this->_resinstance->setup_elements($mform);
     $this->standard_coursemodule_elements();
     $this->add_action_buttons();
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:34,代码来源:mod_form.php

示例6: emarking_get_cm_course_instance

/**
 * Obtains course module ($cm), course, emarking and context
 * objects from cm id in the URL
 *
 * @return multitype:stdClass context_module unknown mixed
 */
function emarking_get_cm_course_instance()
{
    global $DB;
    // Course module id.
    $cmid = required_param('id', PARAM_INT);
    return emarking_get_cm_course_instance_by_id($cmid);
}
开发者ID:sikeze,项目名称:emarking,代码行数:13,代码来源:locallib.php

示例7: definition

 function definition()
 {
     global $DB, $PAGE, $OUTPUT;
     $id = required_param('id', PARAM_INT);
     // course module
     if (!($cm = get_coursemodule_from_id('blended', $id))) {
         error("Course Module ID was incorrect");
     }
     if (!($course = get_course($cm->course))) {
         error("Course is misconfigured");
     }
     if (!($blended = $DB->get_record('blended', array('id' => $cm->instance)))) {
         error("Course module is incorrect");
     }
     $form =& $this->_form;
     $calificables = new grade_tree($course->id);
     $items = $calificables->items;
     $ins = array();
     $assignmentname = array();
     // Obtenemos las referencias a toda la informaci�n sobre los modulos dentro del curso
     $modinfo = get_fast_modinfo($course->id);
     foreach ($modinfo->instances as $abc) {
         foreach ($abc as $cmd) {
             foreach ($items as $r => $ite) {
                 $ins[$r] = $ite->iteminstance;
                 if ($cmd->instance == $ins[$r]) {
                     $assignmentname[$r] = $cmd->name;
                 }
             }
         }
     }
     $form->addElement('select', 'activities', 'Selecciona la Tarea', $assignmentname);
 }
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:33,代码来源:select_activity_form.php

示例8: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $add = optional_param('add', 0, PARAM_ALPHA);
     $return = optional_param('return', 0, PARAM_BOOL);
     //return to course/view.php if false or mod/modname/view.php if true
     $type = optional_param('type', '', PARAM_ALPHANUM);
     $section = required_param('section', PARAM_INT);
     $course = required_param('course', PARAM_INT);
     $mform->addElement('header', 'searchheader', get_string('searchheader', 'taoresource'));
     $plugins = taoresource_get_plugins();
     // let the plugins see the form definition
     foreach ($plugins as $plugin) {
         $rc = $plugin->search_definition($mform);
         if (!$rc) {
             break;
         }
     }
     $this->add_action_buttons(true, get_string('searchtaoresource', 'taoresource'));
     if (!($course = get_record("course", "id", $course))) {
         error("This course doesn't exist");
     }
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     if (has_capability('moodle/course:manageactivities', $context)) {
         $mform->addElement('header', 'addheader', get_string('addheader', 'taoresource'));
         $addbutton = $mform->addElement('submit', 'addtaoresource', get_string('addtaoresource', 'taoresource'));
         $buttonattributes = array('title' => get_string('addtaoresource', 'taoresource'), 'onclick' => "location.href = '" . $CFG->wwwroot . "/mod/taoresource/edit.php?course={$course->id}&section={$section}&type={$type}&add={$add}&return={$return}&mode=add'; return false;");
         $addbutton->updateAttributes($buttonattributes);
     }
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:search_form.php

示例9: blocks_skills_group_verify_access

/**
 * This function checks for a user's access to a particular form/page.  The main check
 * is requiring a user to be logged into a particular course.  Optionally, it will check
 * for a capability and check the user's sesskey.
 *
 * @param string $capability Verify the user has this capability.
 * @param bool $checksesskey T/F indicating whether sesskey should be checked.
 * @return bool T/F indicating if access is permitted.
 *
 */
function blocks_skills_group_verify_access($capability = null, $checksesskey = false)
{
    $courseid = required_param('courseid', PARAM_INT);
    try {
        require_login($courseid, false);
    } catch (Exception $e) {
        echo get_string('nologin', BLOCK_SG_LANG_TABLE);
        return false;
    }
    if ($capability != null) {
        if (!has_capability($capability, context_course::instance($courseid))) {
            echo get_string('noaccess', BLOCK_SG_LANG_TABLE);
            return false;
        }
    }
    try {
        if ($checksesskey != false) {
            if (!confirm_sesskey()) {
                echo get_string('badsesskey', BLOCK_SG_LANG_TABLE);
                return false;
            }
        }
    } catch (Exception $e) {
        echo get_string('badsesskey', BLOCK_SG_LANG_TABLE);
        return false;
    }
    return true;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:38,代码来源:locallib.php

示例10: praxe_view_headm

 function praxe_view_headm()
 {
     global $USER, $cm, $tab, $tab_modes, $CFG, $context;
     //$praxeaction = optional_param('praxeaction', null, PARAM_ALPHAEXT);
     //$school = optional_param('school', null, PARAM_INT);
     switch ($tab) {
         case PRAXE_TAB_HEADM_HOME:
             //$schoolid = optional_param('schoolid', 0, PARAM_INT);
             if ($schools = praxe_get_schools($USER->id)) {
                 $this->content .= self::show_schools($schools, array('mode' => $tab_modes['headm'][PRAXE_TAB_HEADM_EDITSCHOOL]));
             } else {
                 $this->content .= get_string('noschoolsavailable', 'praxe');
             }
             break;
         case PRAXE_TAB_HEADM_ADDSCHOOL:
             self::addschool_form();
             break;
         case PRAXE_TAB_HEADM_TEACHERS:
             $schoolid = optional_param('schoolid', 0, PARAM_INT);
             if ($schoolid > 0) {
                 $this->content .= self::school_teachers_by_schools($USER->id, $schoolid);
             } else {
                 $this->content .= self::school_teachers_by_schools($USER->id);
             }
             break;
         case PRAXE_TAB_HEADM_LOCATIONS:
             $schoolid = optional_param('schoolid', 0, PARAM_INT);
             if ($schoolid > 0) {
                 $this->content .= self::show_locations($schoolid);
             } else {
                 $this->content .= self::show_locations(null, $USER->id);
                 $this->content .= "<p>" . get_string('to_create_location_choose_school', 'praxe') . "</p>";
             }
             break;
         case PRAXE_TAB_HEADM_EDITSCHOOL:
             $schoolid = required_param('schoolid', PARAM_INT);
             $school = praxe_get_school($schoolid);
             if (!praxe_has_capability('editownschool') || !is_object($school) || !$school->headmaster == $USER->id) {
                 print_error('notallowedaction', 'praxe');
             }
             self::addschool_form();
             $this->form->set_form_to_edit($school);
             break;
         case PRAXE_TAB_HEADM_ASSIGNTEACHERS:
             require_capability('mod/praxe:assignteachertoownschool', $context, $USER->id);
             $schoolid = required_param('schoolid', PARAM_INT);
             require_once $CFG->dirroot . '/mod/praxe/c_assignteachers.php';
             $this->form = new praxe_assignteachers($schoolid);
             break;
         case PRAXE_TAB_HEADM_ADDLOCATION:
             require_capability('mod/praxe:createownlocation', $context, $USER->id);
             $schoolid = required_param('schoolid', PARAM_INT);
             require_once $CFG->dirroot . '/mod/praxe/c_addlocation.php';
             $this->form = new praxe_addlocation($schoolid);
             break;
         default:
             redirect($CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id);
             break;
     }
 }
开发者ID:jerab,项目名称:moodle-mod-praxe,代码行数:60,代码来源:view_headm.php

示例11: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     // this hack is needed for different settings of each subtype
     if (!empty($this->_instance)) {
         if ($res = get_record('resource', 'id', (int) $this->_instance)) {
             $type = $res->type;
         } else {
             error('incorrect assignment');
         }
     } else {
         $type = required_param('type', PARAM_ALPHA);
     }
     $mform->addElement('hidden', 'type', $type);
     $mform->setDefault('type', $type);
     require $CFG->dirroot . '/mod/resource/type/' . $type . '/resource.class.php';
     $resclass = 'resource_' . $type;
     $this->_resinstance = new $resclass();
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     //        $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
     $mform->addElement('text', 'name', get_string('name'), array('size' => '48'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addElement('htmleditor', 'summary', get_string('summary'));
     $mform->setType('summary', PARAM_RAW);
     $mform->setHelpButton('summary', array('summary', get_string('summary'), 'resource'));
     // summary should be optional again MDL-9485
     //$mform->addRule('summary', get_string('required'), 'required', null, 'client');
     $mform->addElement('header', 'typedesc', get_string('resourcetype' . $type, 'resource'));
     $this->_resinstance->setup_elements($mform);
     $this->standard_coursemodule_elements(array('groups' => false, 'groupmembersonly' => true, 'gradecat' => false));
     $this->add_action_buttons();
 }
开发者ID:r007,项目名称:PMoodle,代码行数:35,代码来源:mod_form.php

示例12: action_default

 function action_default()
 {
     global $USER, $CURMAN;
     $id = required_param('id', PARAM_INT);
     $contexts = clone trackpage::get_contexts('block/curr_admin:track:enrol');
     //look up student's cluster assignments with necessary capability
     $cluster_contexts = cm_context_set::for_user_with_capability('cluster', 'block/curr_admin:track:enrol_cluster_user', $USER->id);
     //calculate our filter condition based on cluster accessibility
     $cluster_filter = $cluster_contexts->sql_filter_for_context_level('clst.id', 'cluster');
     //query for getting tracks based on clusters
     $sql = "SELECT trk.id\n                FROM {$CURMAN->db->prefix_table(CLSTTABLE)} clst\n                JOIN {$CURMAN->db->prefix_table(CLSTTRKTABLE)} clsttrk\n                ON clst.id = clsttrk.clusterid\n                JOIN {$CURMAN->db->prefix_table(TRACKTABLE)} trk\n                ON clsttrk.trackid = trk.id\n                WHERE {$cluster_filter}";
     //assign the appropriate track ids
     $recordset = get_recordset_sql($sql);
     if ($recordset && $recordset->RecordCount() > 0) {
         if (!isset($contexts->contexts['track'])) {
             $contexts->contexts['track'] = array();
         }
         $new_tracks = array();
         while ($record = rs_fetch_next_record($recordset)) {
             $new_tracks[] = $record->id;
         }
         $contexts->contexts['track'] = array_merge($contexts->contexts['track'], $new_tracks);
     }
     $columns = array('idnumber' => get_string('track_idnumber', 'block_curr_admin'), 'name' => get_string('track_name', 'block_curr_admin'), 'description' => get_string('track_description', 'block_curr_admin'), 'numclasses' => get_string('num_classes', 'block_curr_admin'), 'manage' => '');
     $items = usertrack::get_tracks($id);
     $formatters = $this->create_link_formatters(array('idnumber', 'name'), 'trackpage', 'trackid');
     $this->print_list_view($items, $columns, $formatters, 'tracks');
     //get the listing specifically for this user
     $this->print_dropdown(track_get_listing('name', 'ASC', 0, 0, '', '', 0, 0, $contexts, $id), $items, 'userid', 'trackid', 'savenew', 'idnumber');
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:30,代码来源:usertrackpage.class.php

示例13: invoke

 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     $this->does_generate = ACTION_GENERATE_XML;
     /// These are always here
     global $CFG, $XMLDB;
     /// Do the job, setting result as needed
     /// Get the file parameter
     $file = required_param('file', PARAM_PATH);
     $file = $CFG->dirroot . $file;
     /// File must be under $CFG->wwwroot and
     ///  under one db directory (simple protection)
     if (substr($file, 0, strlen($CFG->dirroot)) == $CFG->dirroot && substr(dirname($file), -2, 2) == 'db') {
         /// Everything is ok. Load the file to memory
         $this->output = file_get_contents($file);
     } else {
         /// Switch to HTML and error
         $this->does_generate = ACTION_GENERATE_HTML;
         $this->errormsg = 'File not viewable (' . $file . ')';
         $result = false;
     }
     /// Return ok if arrived here
     return $result;
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:31,代码来源:view_xml.class.php

示例14: process_form

 function process_form()
 {
     if (optional_param('index', '', PARAM_TEXT)) {
         return lightboxgallery_index_thumbnail($this->gallery->course, $this->gallery, $this->image);
     } else {
         if (optional_param('reset', '', PARAM_TEXT)) {
             $offsetx = 0;
             $offsety = 0;
         } else {
             $move = required_param('move', PARAM_INT);
             $offset = optional_param('offset', 20, PARAM_INT);
             switch ($move) {
                 case 1:
                     $offsetx = 0;
                     $offsety = -$offset;
                     break;
                 case 2:
                     $offsetx = 0;
                     $offsety = $offset;
                     break;
                 case 3:
                     $offsetx = -$offset;
                     $offsety = 0;
                     break;
                 case 4:
                     $offsetx = $offset;
                     $offsety = 0;
                     break;
             }
         }
     }
     $this->imageobj->create_thumbnail($offsetx, $offsety);
 }
开发者ID:itziko,项目名称:Moodle-jQuery-Lightbox-Gallery,代码行数:33,代码来源:thumbnail.class.php

示例15: invoke

 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     // Set own core attributes
     $this->does_generate = ACTION_NONE;
     //$this->does_generate = ACTION_GENERATE_HTML;
     // These are always here
     global $CFG, $XMLDB;
     // Do the job, setting result as needed
     // Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . $dirpath;
     // Get the correct dirs
     if (!empty($XMLDB->dbdirs)) {
         $dbdir =& $XMLDB->dbdirs[$dirpath];
     } else {
         return false;
     }
     if (!empty($XMLDB->editeddirs)) {
         $editeddir =& $XMLDB->editeddirs[$dirpath];
         $structure =& $editeddir->xml_file->getStructure();
     }
     // If the changeme table exists, just get it and continue
     $changeme_exists = false;
     if ($tables =& $structure->getTables()) {
         if ($table =& $structure->getTable('changeme')) {
             $changeme_exists = true;
         }
     }
     if (!$changeme_exists) {
         // Lets create the table
         $field = new xmldb_field('id');
         $field->setType(XMLDB_TYPE_INTEGER);
         $field->setLength(10);
         $field->setNotNull(true);
         $field->setUnsigned(true);
         $field->setSequence(true);
         $field->setLoaded(true);
         $field->setChanged(true);
         $key = new xmldb_key('primary');
         $key->setType(XMLDB_KEY_PRIMARY);
         $key->setFields(array('id'));
         $key->setLoaded(true);
         $key->setChanged(true);
         $table = new xmldb_table('changeme');
         $table->setComment('Default comment for the table, please edit me');
         $table->addField($field);
         $table->addKey($key);
         // Finally, add the whole retrofitted table to the structure
         // in the place specified
         $structure->addTable($table);
     }
     // Launch postaction if exists (leave this here!)
     if ($this->getPostAction() && $result) {
         return $this->launch($this->getPostAction());
     }
     // Return ok if arrived here
     return $result;
 }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:65,代码来源:new_table.class.php


注:本文中的required_param函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。