• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP optional_param_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: no_submit_button_pressed

 /**
  * Checks if button pressed is not for submitting the form
  *
  *   This overrides moodleform, and is a hack to fix the issue where recurring element buttons
  *     will be stored as an array, rather than a single item, in the url which causes a warning and causes our tests to fail
  *
  *   Most of the code was copied from moodleform, with the addition of the in_array check 
  *
  *
  * @staticvar bool $nosubmit keeps track of no submit button
  * @return bool
  */
 function no_submit_button_pressed()
 {
     static $nosubmit = null;
     // one check is enough
     if (!is_null($nosubmit)) {
         return $nosubmit;
     }
     $mform =& $this->_form;
     $nosubmit = false;
     if (!$this->is_submitted()) {
         return false;
     }
     foreach ($mform->_noSubmitButtons as $nosubmitbutton) {
         // Need to handle this specially, since will be an array
         if (in_array($nosubmitbutton, $this->_recurring_nosubmit_buttons)) {
             if (optional_param_array($nosubmitbutton, 0, PARAM_RAW)) {
                 $nosubmit = true;
                 break;
             }
         } else {
             if (optional_param($nosubmitbutton, 0, PARAM_RAW)) {
                 $nosubmit = true;
                 break;
             }
         }
     }
     return $nosubmit;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:40,代码来源:metadata_form.php


示例2: data_preprocessing

 public function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     $dragids = array();
     // drag no -> dragid
     if (!empty($question->options)) {
         $question->shuffleanswers = $question->options->shuffleanswers;
         $question->drags = array();
         foreach ($question->options->drags as $drag) {
             $dragindex = $drag->no - 1;
             $question->drags[$dragindex] = array();
             $question->drags[$dragindex]['draglabel'] = $drag->label;
             $question->drags[$dragindex]['infinite'] = $drag->infinite;
             $question->drags[$dragindex]['draggroup'] = $drag->draggroup;
             $dragids[$dragindex] = $drag->id;
         }
         $question->drops = array();
         foreach ($question->options->drops as $drop) {
             $question->drops[$drop->no - 1] = array();
             $question->drops[$drop->no - 1]['choice'] = $drop->choice;
             $question->drops[$drop->no - 1]['droplabel'] = $drop->label;
             $question->drops[$drop->no - 1]['xleft'] = $drop->xleft;
             $question->drops[$drop->no - 1]['ytop'] = $drop->ytop;
         }
     }
     //initialise file picker for bgimage
     $draftitemid = file_get_submitted_draft_itemid('bgimage');
     file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimageortext', 'bgimage', !empty($question->id) ? (int) $question->id : null, self::file_picker_options());
     $question->bgimage = $draftitemid;
     //initialise file picker for dragimages
     list(, $imagerepeats) = $this->get_drag_item_repeats();
     $draftitemids = optional_param_array('dragitem', array(), PARAM_INT);
     for ($imageindex = 0; $imageindex < $imagerepeats; $imageindex++) {
         $draftitemid = isset($draftitemids[$imageindex]) ? $draftitemids[$imageindex] : 0;
         //numbers not allowed in filearea name
         $itemid = isset($dragids[$imageindex]) ? $dragids[$imageindex] : null;
         file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimageortext', 'dragimage', $itemid, self::file_picker_options());
         $question->dragitem[$imageindex] = $draftitemid;
     }
     if (!empty($question->options)) {
         foreach ($question->options->drags as $drag) {
             $dragindex = $drag->no - 1;
             if (!isset($question->dragitem[$dragindex])) {
                 $fileexists = false;
             } else {
                 $fileexists = self::file_uploaded($question->dragitem[$dragindex]);
             }
             $labelexists = trim($question->drags[$dragindex]['draglabel']) != '';
             if ($labelexists && !$fileexists) {
                 $question->dragitemtype[$dragindex] = 'word';
             } else {
                 $question->dragitemtype[$dragindex] = 'image';
             }
         }
     }
     $this->js_call();
     return $question;
 }
开发者ID:ndunand,项目名称:moodle-qtype_ddimageortext,代码行数:60,代码来源:edit_ddimageortext_form.php


示例3: __construct

 /**
  * Constructor
  *
  * @param \mod_grouptool\output\sortlist $sortlist Sortlist to be used without
  */
 public function __construct(sortlist &$sortlist)
 {
     global $SESSION;
     $this->sortlist = $sortlist;
     $classes = optional_param_array('classes', array(0), \PARAM_INT);
     $action = optional_param('class_action', 0, \PARAM_ALPHA);
     $gobutton = optional_param('do_class_action', 0, \PARAM_BOOL);
     if (!empty($gobutton) && $classes != null && count($classes) != 0 && !empty($action)) {
         $keys = array();
         $groups = array();
         foreach ($classes as $groupingid) {
             $groups = array_merge($groups, groups_get_all_groups($this->sortlist->cm->course, 0, $groupingid));
         }
         foreach ($groups as $current) {
             switch ($action) {
                 case 'select':
                     $this->sortlist->selected[$current->id] = 1;
                     break;
                 case 'deselect':
                     $this->sortlist->selected[$current->id] = 0;
                     break;
                 case 'toggle':
                     $next = empty($this->sortlist->selected[$current->id]) ? 1 : 0;
                     $this->sortlist->selected[$current->id] = $next;
                     break;
             }
         }
         // Update SESSION!
         $SESSION->sortlist->selected = $this->sortlist->selected;
     }
 }
开发者ID:rimacher,项目名称:moodle-mod_grouptool,代码行数:36,代码来源:sortlist_controller.php


示例4: preferences_update

 /**
  * Save as CSV value
  */
 public function preferences_update($data)
 {
     $raw = optional_param_array($this->name, '', PARAM_RAW);
     if (!empty($raw) and !empty($data->{$this->name})) {
         $data->{$this->name} = implode(',', $data->{$this->name});
     } else {
         $data->{$this->name} = '';
     }
     return parent::preferences_update($data);
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:13,代码来源:selectmulti.php


示例5: upload

 /**
  * Process uploaded file
  * @return array|bool
  */
 public function upload($saveas_filename, $maxbytes)
 {
     global $CFG;
     $types = optional_param_array('accepted_types', '*', PARAM_RAW);
     $savepath = optional_param('savepath', '/', PARAM_PATH);
     $itemid = optional_param('itemid', 0, PARAM_INT);
     $license = optional_param('license', $CFG->sitedefaultlicense, PARAM_TEXT);
     $author = optional_param('author', '', PARAM_TEXT);
     return $this->process_upload($saveas_filename, $maxbytes, $types, $savepath, $itemid, $license, $author);
 }
开发者ID:nmicha,项目名称:moodle,代码行数:14,代码来源:lib.php


示例6: upload

 /**
  * Process uploaded file
  * @return array|bool
  */
 public function upload($saveas_filename, $maxbytes)
 {
     global $CFG;
     $types = optional_param_array('accepted_types', '*', PARAM_RAW);
     $savepath = optional_param('savepath', '/', PARAM_PATH);
     $itemid = optional_param('itemid', 0, PARAM_INT);
     $license = optional_param('license', $CFG->sitedefaultlicense, PARAM_TEXT);
     $author = optional_param('author', '', PARAM_TEXT);
     $areamaxbytes = optional_param('areamaxbytes', FILE_AREA_MAX_BYTES_UNLIMITED, PARAM_INT);
     $overwriteexisting = optional_param('overwrite', false, PARAM_BOOL);
     return $this->process_upload($saveas_filename, $maxbytes, $types, $savepath, $itemid, $license, $author, $overwriteexisting, $areamaxbytes);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:lib.php


示例7: process_form

 public function process_form()
 {
     $tag = optional_param('tag', '', PARAM_TAG);
     $fs = get_file_storage();
     $storedfile = $fs->get_file($this->context->id, 'mod_lightboxgallery', 'gallery_images', '0', '/', $this->image);
     $image = new lightboxgallery_image($storedfile, $this->gallery, $this->cm);
     if ($tag) {
         $image->add_tag($tag);
     } else {
         if (optional_param('delete', 0, PARAM_INT)) {
             if ($deletes = optional_param_array('deletetags', array(), PARAM_RAW)) {
                 foreach ($deletes as $delete) {
                     $image->delete_tag(clean_param($delete, PARAM_INT));
                 }
             }
         }
     }
 }
开发者ID:POETGroup,项目名称:moodle-mod_lightboxgallery,代码行数:18,代码来源:tag.class.php


示例8: filter_input

 /**
  * Filter and load input parameters
  *
  * @throws \coding_exception
  */
 protected function filter_input()
 {
     // Type specifc
     $this->content_id = optional_param('content_id', 0, PARAM_INT);
     // Used to handle pagination
     $this->offset = optional_param('offset', 0, PARAM_INT);
     // Max number of items to display on one page
     $this->limit = optional_param('limit', 20, PARAM_INT);
     if ($this->limit > 100) {
         // Avoid wrong usage
         throw new \coding_exception('limit to high');
     }
     // Field to order by
     $this->orderBy = optional_param('sortBy', 0, PARAM_INT);
     // Direction to order in
     $this->orderDir = optional_param('sortDir', 0, PARAM_INT);
     // List of fields to filter results on
     $this->filters = optional_param_array('filters', array(), PARAM_RAW_TRIMMED);
 }
开发者ID:nadavkav,项目名称:h5p-moodle-plugin,代码行数:24,代码来源:results.php


示例9: execute

    function execute($finalelements, $data) {
        global $CFG;


        if ($this->report->type != 'sql')
            return $finalelements;

        if ($CFG->version < 2011120100) {
            $filter_starttime = optional_param('filter_starttime', 0, PARAM_RAW);
            $filter_endtime = optional_param('filter_endtime', 0, PARAM_RAW);
        } else {
            $filter_starttime = optional_param_array('filter_starttime', 0, PARAM_RAW);
            $filter_endtime = optional_param_array('filter_endtime', 0, PARAM_RAW);
        }
        if (!$filter_starttime || !$filter_endtime)
            return $finalelements;

        $filter_starttime = make_timestamp($filter_starttime['year'], $filter_starttime['month'], $filter_starttime['day'], $filter_starttime['hour'], $filter_starttime['minute']);
        $filter_endtime = make_timestamp($filter_endtime['year'], $filter_endtime['month'], $filter_endtime['day'], $filter_endtime['hour'], $filter_endtime['minute']);

        $operators = array('<', '>', '<=', '>=');

        if (preg_match("/%%FILTER_STARTTIME:([^%]+)%%/i", $finalelements, $output)) {
            list($field, $operator) = preg_split('/:/', $output[1]);
            if (!in_array($operator, $operators))
                print_error('nosuchoperator');
            $replace = ' AND ' . $field . ' ' . $operator . ' ' . $filter_starttime;
            $finalelements = str_replace('%%FILTER_STARTTIME:' . $output[1] . '%%', $replace, $finalelements);
        }

        if (preg_match("/%%FILTER_ENDTIME:([^%]+)%%/i", $finalelements, $output)) {
            list($field, $operator) = preg_split('/:/', $output[1]);
            if (!in_array($operator, $operators))
                print_error('nosuchoperator');
            $replace = ' AND ' . $field . ' ' . $operator . ' ' . $filter_endtime;
            $finalelements = str_replace('%%FILTER_ENDTIME:' . $output[1] . '%%', $replace, $finalelements);
        }

        $finalelements = str_replace('%STARTTIME%%', $filter_starttime, $finalelements);
        $finalelements = str_replace('%ENDTIME%%', $filter_endtime, $finalelements);

        return $finalelements;
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:43,代码来源:plugin.class.php


示例10: __construct

 public function __construct()
 {
     global $PAGE;
     global $CFG;
     if ($CFG->debug) {
         $PAGE->requires->yui_module('moodle-local_searchbytags-allowmultiple', 'M.local_searchbytags.allowmultiple.init');
     }
     $this->tags = optional_param_array('tags', array(), PARAM_TEXT);
     if (!empty($this->tags) && $this->tags[0] == null) {
         array_shift($this->tags);
     }
     $this->nottags = optional_param_array('nottags', array(), PARAM_TEXT);
     if (!empty($this->nottags) && $this->nottags[0] == null) {
         array_shift($this->nottags);
     }
     if (!empty($this->tags) || !empty($this->nottags)) {
         $this->init();
     }
 }
开发者ID:advancingdesign,项目名称:moodle_local_searchbytags,代码行数:19,代码来源:lib.php


示例11: __construct

 public function __construct($submiturl, $question, $category, $contexts, $formeditable = true)
 {
     $this->regenerate = true;
     $this->question = $question;
     $this->qtypeobj = question_bank::get_qtype($this->question->qtype);
     // Get the dataset definitions for this question.
     // Coming here everytime even when using a NoSubmitButton.
     // This will only set the values to the actual question database content
     // which is not what we want, so this should be removed from here.
     // Get priority to paramdatasets.
     $this->reload = optional_param('reload', false, PARAM_BOOL);
     if (!$this->reload) {
         // Use database data as this is first pass
         // Question->id == 0 so no stored datasets.
         if (!empty($question->id)) {
             $this->datasetdefs = $this->qtypeobj->get_dataset_definitions($question->id, array());
             if (!empty($this->datasetdefs)) {
                 foreach ($this->datasetdefs as $defid => $datasetdef) {
                     // First get the items in case their number does not correspond to itemcount.
                     if (isset($datasetdef->id)) {
                         $this->datasetdefs[$defid]->items = $this->qtypeobj->get_database_dataset_items($datasetdef->id);
                         if ($this->datasetdefs[$defid]->items != '') {
                             $datasetdef->itemcount = count($this->datasetdefs[$defid]->items);
                         } else {
                             $datasetdef->itemcount = 0;
                         }
                     }
                     // Get maxnumber.
                     if ($this->maxnumber == -1 || $datasetdef->itemcount < $this->maxnumber) {
                         $this->maxnumber = $datasetdef->itemcount;
                     }
                 }
             }
             $i = 0;
             foreach ($this->question->options->answers as $answer) {
                 $this->answer[$i] = $answer;
                 $i++;
             }
             $this->nonemptyanswer = $this->answer;
         }
         $datasettoremove = false;
         $newdatasetvalues = false;
         $newdataset = false;
     } else {
         // Handle reload to get values from the form-elements
         // answers, datasetdefs and data_items. In any case the validation
         // step will warn the user of any error in settings the values.
         // Verification for the specific dataset values as the other parameters
         // units, feeedback etc are handled elsewhere.
         // Handle request buttons :
         //    'analyzequestion' (Identify the wild cards {x..} present in answers).
         //    'addbutton' (create new set of datatitems).
         //    'updatedatasets' is handled automatically on each reload.
         // The analyzequestion is done every time on reload
         // to detect any new wild cards so that the current display reflects
         // the mandatory (i.e. in answers) datasets.
         // To implement : don't do any changes if the question is used in a quiz.
         // If new datadef, new properties should erase items.
         // most of the data.
         $datasettoremove = false;
         $newdatasetvalues = false;
         $newdataset = false;
         $dummyform = new stdClass();
         $mandatorydatasets = array();
         // Should not test on adding a new answer.
         // Should test if there are already olddatasets or if the 'analyzequestion'.
         // submit button has been clicked.
         if (optional_param_array('datasetdef', false, PARAM_BOOL) || optional_param('analyzequestion', false, PARAM_BOOL)) {
             if ($dummyform->answer = optional_param_array('answer', '', PARAM_NOTAGS)) {
                 // There is always at least one answer...
                 $fraction = optional_param_array('fraction', '', PARAM_FLOAT);
                 $tolerance = optional_param_array('tolerance', '', PARAM_FLOAT);
                 $tolerancetype = optional_param_array('tolerancetype', '', PARAM_FLOAT);
                 $correctanswerlength = optional_param_array('correctanswerlength', '', PARAM_INT);
                 $correctanswerformat = optional_param_array('correctanswerformat', '', PARAM_INT);
                 foreach ($dummyform->answer as $key => $answer) {
                     if (trim($answer) != '') {
                         // Just look for non-empty.
                         $this->answer[$key] = new stdClass();
                         $this->answer[$key]->answer = $answer;
                         $this->answer[$key]->fraction = $fraction[$key];
                         $this->answer[$key]->tolerance = $tolerance[$key];
                         $this->answer[$key]->tolerancetype = $tolerancetype[$key];
                         $this->answer[$key]->correctanswerlength = $correctanswerlength[$key];
                         $this->answer[$key]->correctanswerformat = $correctanswerformat[$key];
                         $this->nonemptyanswer[] = $this->answer[$key];
                         $mandatorydatasets += $this->qtypeobj->find_dataset_names($answer);
                     }
                 }
             }
             $this->datasetdefs = array();
             // Rebuild datasetdefs from old values.
             if ($olddef = optional_param_array('datasetdef', '', PARAM_RAW)) {
                 $calcmin = optional_param_array('calcmin', '', PARAM_FLOAT);
                 $calclength = optional_param_array('calclength', '', PARAM_INT);
                 $calcmax = optional_param_array('calcmax', '', PARAM_FLOAT);
                 $oldoptions = optional_param_array('defoptions', '', PARAM_RAW);
                 $newdatasetvalues = false;
                 $sizeofolddef = count($olddef);
                 for ($key = 1; $key <= $sizeofolddef; $key++) {
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:edit_calculatedsimple_form.php


示例12: array

    $course = $DB->get_record('course', array('id' => $hotpot->course), '*', MUST_EXIST);
    $cm = get_coursemodule_from_instance('hotpot', $hotpot->id, $course->id, false, MUST_EXIST);
}
// check login
require_login($course, true, $cm);
if (!has_capability('mod/hotpot:reviewallattempts', $PAGE->context)) {
    require_capability('mod/hotpot:reviewmyattempts', $PAGE->context);
}
add_to_log($course->id, 'hotpot', 'report', 'report.php?id=' . $cm->id, $hotpot->id, $cm->id);
// Create an object to represent the current HotPot activity
$hotpot = hotpot::create($hotpot, $cm, $course, $PAGE->context);
// delete attempts, if requested
$action = optional_param('action', '', PARAM_ALPHA);
$confirmed = optional_param('confirmed', 0, PARAM_INT);
if (function_exists('optional_param_array')) {
    $selected = optional_param_array('selected', 0, PARAM_INT);
} else {
    $selected = optional_param('selected', 0, PARAM_INT);
}
if ($action == 'deleteselected') {
    require_sesskey();
    if ($confirmed) {
        $hotpot->delete_attempts($selected, false);
    } else {
        // show a confirm button ?
    }
}
$PAGE->set_url('/mod/hotpot/report.php', array('id' => $course->id, 'mode' => $mode));
$PAGE->set_title($hotpot->name);
$PAGE->set_heading($course->shortname);
$PAGE->navbar->add(get_string('report', 'quiz'));
开发者ID:hapaxapah,项目名称:moodle-mod_hotpot,代码行数:31,代码来源:report.php


示例13: filter

 /**
  * Filter file listing to display specific types
  *
  * @param array $value
  * @return bool
  */
 public function filter(&$value)
 {
     $accepted_types = optional_param_array('accepted_types', '', PARAM_RAW);
     if (isset($value['children'])) {
         if (!empty($value['children'])) {
             $value['children'] = array_filter($value['children'], array($this, 'filter'));
         }
         return true;
         // always return directories
     } else {
         if ($accepted_types == '*' or empty($accepted_types) or is_array($accepted_types) and in_array('*', $accepted_types)) {
             return true;
         } else {
             foreach ($accepted_types as $ext) {
                 if (preg_match('#' . $ext . '$#i', $value['title'])) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:isuruAb,项目名称:moodle,代码行数:28,代码来源:lib.php


示例14: test_optional_param_array

 public function test_optional_param_array()
 {
     global $CFG;
     $_POST['username'] = array('a' => 'post_user');
     $_GET['username'] = array('a' => 'get_user');
     $this->assertSame($_POST['username'], optional_param_array('username', array('a' => 'default_user'), PARAM_RAW));
     unset($_POST['username']);
     $this->assertSame($_GET['username'], optional_param_array('username', array('a' => 'default_user'), PARAM_RAW));
     unset($_GET['username']);
     $this->assertSame(array('a' => 'default_user'), optional_param_array('username', array('a' => 'default_user'), 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 {
         optional_param_array('username', array('a' => 'default_user'), null);
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         @optional_param_array('username', array('a' => 'default_user'));
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         @optional_param_array('username');
         $this->fail('coding_exception expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         optional_param_array('', array('a' => 'default_user'), 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'));
         optional_param_array('username', array('a' => 'default_user'), PARAM_RAW);
         $this->fail('coding_exception expected');
     } catch (coding_exception $ex) {
         $this->assertTrue(true);
     }
     // Do not allow non-arrays.
     $_POST['username'] = 'post_user';
     $this->assertSame(array('a' => 'default_user'), optional_param_array('username', array('a' => 'default_user'), PARAM_RAW));
     $this->assertDebuggingCalled();
     // Make sure array keys are sanitised.
     $_POST['username'] = array('abc123_;-/*-+ ' => 'arrggh', 'a1_-' => 'post_user');
     $this->assertSame(array('a1_-' => 'post_user'), optional_param_array('username', array(), PARAM_RAW));
     $this->assertDebuggingCalled();
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:53,代码来源:moodlelib_test.php


示例15: ChatForm

        $id = $aux[0];
    }
}
$mform = new ChatForm($linkForm, $valoresDefault);
$usuarios = $chatDao->findUser();
if (!$id || $id && $grupo) {
    if ($data = $mform->get_data()) {
        $grupoChat = new stdClass();
        $grupoChat->nome = $data->nome;
        $grupoChat->data_registro = time();
        if (!$id) {
            $id = $DB->insert_record('chatwebgd_grupo', $grupoChat);
            $chatDao->inserirUsuarioGrupo($id, $USER->id);
        }
        if ($id) {
            $usuarios = optional_param_array('usuarios_grupo', array(), PARAM_TEXT);
            if (count($usuarios)) {
                foreach ($usuarios as $usuario) {
                    if ($chatDao->verificaUsuarioInativo($id, $usuario)) {
                        $chatDao->ativarUsuario($id, $usuario);
                    } else {
                        $chatDao->inserirUsuarioGrupo($id, $usuario);
                    }
                }
            }
            echo '<meta http-equiv="refresh" content="0; url=' . $CFG->wwwroot . '">';
        }
    } else {
        $mform->display();
    }
} else {
开发者ID:MoobiEgc,项目名称:chat_webgd,代码行数:31,代码来源:index.php


示例16: optional_param

    $url->param('author', $author);
}
$cloneid = optional_param('clone', 0, PARAM_INT);
if ($cloneid) {
    // clone is used to mark shared forums
    $url->param('clone', $cloneid);
}
$asmoderator = optional_param('asmoderator', 0, PARAM_INT);
$url->param('asmoderator', $asmoderator);
$datefrom = optional_param_array('datefrom', 0, PARAM_INT);
if (!empty($datefrom)) {
    foreach ($datefrom as $key => $value) {
        $url->param('datefrom[' . $key . ']', $value);
    }
}
$dateto = optional_param_array('dateto', 0, PARAM_INT);
if (!empty($dateto)) {
    foreach ($dateto as $key => $value) {
        $url->param('dateto[' . $key . ']', $value);
    }
}
// The below are necessary to fool the form into thinking it was submitted again
// when further requests are made for multiple pages / changing group. This is
// kind of a horrible way to make the page but it means we can use get_data
// instead of manually interpreting date dropdowns (incorrectly).
$submitbutton = optional_param('submitbutton', '', PARAM_RAW);
if ($submitbutton) {
    $url->param('submitbutton', $submitbutton);
}
$sesskey = optional_param('sesskey', '', PARAM_RAW);
if ($sesskey) {
开发者ID:ULCC-QMUL,项目名称:moodle-mod_forumng,代码行数:31,代码来源:advancedsearch.php


示例17: time

    }
}
$PAGE->set_title($choice->name);
$PAGE->set_heading($course->fullname);
/// Submit any new data if there is any
if (data_submitted() && is_enrolled($context, NULL, 'mod/choice:choose') && confirm_sesskey()) {
    $timenow = time();
    if (has_capability('mod/choice:deleteresponses', $context) && $action == 'delete') {
        //some responses need to be deleted
        choice_delete_responses($attemptids, $choice, $cm, $course);
        //delete responses.
        redirect("view.php?id={$cm->id}");
    }
    // Redirection after all POSTs breaks block editing, we need to be more specific!
    if ($choice->allowmultiple) {
        $answer = optional_param_array('answer', array(), PARAM_INT);
    } else {
        $answer = optional_param('answer', '', PARAM_INT);
    }
    if (!$choiceavailable) {
        $reason = current(array_keys($warnings));
        throw new moodle_exception($reason, 'choice', '', $warnings[$reason]);
    }
    if ($answer) {
        choice_user_submit_response($answer, $choice, $USER->id, $course, $cm);
        redirect(new moodle_url('/mod/choice/view.php', array('id' => $cm->id, 'notify' => 'choicesaved', 'sesskey' => sesskey())));
    } else {
        if (empty($answer) and $action === 'makechoice') {
            // We cannot use the 'makechoice' alone because there might be some legacy renderers without it,
            // outdated renderers will not get the 'mustchoose' message - bad luck.
            redirect(new moodle_url('/mod/choice/view.php', array('id' => $cm->id, 'notify' => 'mustchooseone', 'sesskey' => sesskey())));
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:view.php


示例18: required_param

/**
 * This file allows you to add a note for a user
 *
 * @copyright 1999 Martin Dougiamas  http://dougiamas.com
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @package core_user
 */
require_once "../config.php";
require_once $CFG->dirroot . '/notes/lib.php';
$id = required_param('id', PARAM_INT);
// Course id.
$users = optional_param_array('userid', array(), PARAM_INT);
// Array of user id.
$contents = optional_param_array('contents', array(), PARAM_RAW);
// Array of user notes.
$states = optional_param_array('states', array(), PARAM_ALPHA);
// Array of notes states.
$PAGE->set_url('/user/addnote.php', array('id' => $id));
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('invalidcourseid');
}
$context = context_course::instance($id);
require_login($course);
// To create notes the current user needs a capability.
require_capability('moodle/notes:manage', $context);
if (empty($CFG->enablenotes)) {
    print_error('notesdisabled', 'notes');
}
if (!empty($users) && confirm_sesskey()) {
    if (count($users) != count($contents) || count($users) != count($states)) {
        print_error('invalidformdata', '', $CFG->wwwroot . '/user/index.php?id=' . $id);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:addnote.php


示例19: parse_search_field

 function parse_search_field()
 {
     $selected = optional_param_array('f_' . $this->field->id, array(), PARAM_NOTAGS);
     $allrequired = optional_param('f_' . $this->field->id . '_allreq', 0, PARAM_BOOL);
     if (empty($selected)) {
         // no searching
         return '';
     }
     return array('checked' => $selected, 'allrequired' => $allrequired);
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:10,代码来源:field.class.php


示例20: optional_param

/**
 * Returns a particular value for the named variable, taken from
 * POST or GET, otherwise returning a given default.
 *
 * This function should be used to initialise all optional values
 * in a script that are based on parameters.  Usually it will be
 * used like this:
 *    $name = optional_param('name', 'Fred', PARAM_TEXT);
 *
 * 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 mixed  $default the default value to return if nothing is found
 * @param string $type expected type of parameter
 * @return mixed
 * @throws coding_exception
 */
function optional_param($parname, $default, $type)
{
    if (func_num_args() != 3 or empty($parname) or empty($type)) {
        throw new coding_exception('optional_param requires $parname, $default + $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 {
            return $default;
        }
    }
    if (is_array($param)) {
        debugging('Invalid array parameter detected in required_param(): ' . $parname);
        // TODO: switch to $default in Moodle 2.3.
        return optional_param_array($parname, $default, $type);
    }
    return clean_param($param, $type);
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:39,代码来源:moodlelib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP optionlist函数代码示例发布时间:2022-05-15
下一篇:
PHP optional_param函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap