本文整理汇总了PHP中get_user_max_upload_file_size函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_max_upload_file_size函数的具体用法?PHP get_user_max_upload_file_size怎么用?PHP get_user_max_upload_file_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_user_max_upload_file_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: editor_options
/**
* Returns the options array to use in forum text editor
*
* @return array
*/
public static function editor_options()
{
global $COURSE, $PAGE, $CFG;
// TODO: add max files and max size support
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes);
return array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes, 'trusttext' => true);
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:12,代码来源:mod_form.php
示例2: editor_options
/**
* Returns the options array to use in twf text editor
*
* @param context_module $context
* @param int $postid post id, use null when adding new post
* @return array
*/
public static function editor_options(context_module $context, $postid)
{
global $COURSE, $PAGE, $CFG;
// TODO: add max files and max size support
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes);
return array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes, 'trusttext' => true, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL, 'subdirs' => file_area_contains_subdirs($context, 'mod_twf', 'post', $postid));
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:14,代码来源:post_form.php
示例3: MoodleQuickForm_filepicker
/**
* Constructor
*
* @param string $elementName (optional) name of the filepicker
* @param string $elementLabel (optional) filepicker label
* @param array $attributes (optional) Either a typical HTML attribute string
* or an associative array
* @param array $options set of options to initalize filepicker
*/
function MoodleQuickForm_filepicker($elementName = null, $elementLabel = null, $attributes = null, $options = null)
{
global $CFG, $PAGE;
$options = (array) $options;
foreach ($options as $name => $value) {
if (array_key_exists($name, $this->_options)) {
$this->_options[$name] = $value;
}
}
if (empty($options['return_types'])) {
$this->_options['return_types'] = FILE_INTERNAL;
}
$fpmaxbytes = 0;
if (!empty($options['maxbytes'])) {
$fpmaxbytes = $options['maxbytes'];
}
$coursemaxbytes = 0;
if (!empty($PAGE->course->maxbytes)) {
$coursemaxbytes = $PAGE->course->maxbytes;
}
$this->_options['maxbytes'] = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $coursemaxbytes, $fpmaxbytes);
$this->_type = 'filepicker';
parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:33,代码来源:filepicker.php
示例4: __construct
/**
* Constructor
*
* @param stdClass $options options for filemanager
* default options are:
* maxbytes=>-1,
* maxfiles=>-1,
* itemid=>0,
* subdirs=>false,
* client_id=>uniqid(),
* acepted_types=>'*',
* return_types=>FILE_INTERNAL,
* context=>$PAGE->context,
* author=>fullname($USER),
* licenses=>array build from $CFG->licenses,
* defaultlicense=>$CFG->sitedefaultlicense
*/
public function __construct(stdClass $options)
{
global $CFG, $USER, $PAGE;
require_once $CFG->dirroot . '/repository/lib.php';
$defaults = array('maxbytes' => -1, 'maxfiles' => -1, 'itemid' => 0, 'subdirs' => 0, 'client_id' => uniqid(), 'accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'context' => $PAGE->context, 'author' => fullname($USER), 'licenses' => array());
if (!empty($CFG->licenses)) {
$array = explode(',', $CFG->licenses);
foreach ($array as $license) {
$l = new stdClass();
$l->shortname = $license;
$l->fullname = get_string($license, 'license');
$defaults['licenses'][] = $l;
}
}
if (!empty($CFG->sitedefaultlicense)) {
$defaults['defaultlicense'] = $CFG->sitedefaultlicense;
}
foreach ($defaults as $key => $value) {
if (empty($options->{$key})) {
$options->{$key} = $value;
}
}
$fs = get_file_storage();
// initilise options, getting files in root path
$this->options = file_get_drafarea_files($options->itemid, '/');
// calculate file count
$usercontext = context_user::instance($USER->id);
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id', false);
$filecount = count($files);
$this->options->filecount = $filecount;
// copying other options
foreach ($options as $name => $value) {
$this->options->{$name} = $value;
}
// calculate the maximum file size as minimum from what is specified in filepicker options,
// course options, global configuration and php settings
$coursebytes = $maxbytes = 0;
list($context, $course, $cm) = get_context_info_array($this->options->context->id);
if (is_object($course)) {
$coursebytes = $course->maxbytes;
}
if (!empty($this->options->maxbytes) && $this->options->maxbytes > 0) {
$maxbytes = $this->options->maxbytes;
}
$this->options->maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes, $coursebytes, $maxbytes);
// building file picker options
$params = new stdClass();
$params->accepted_types = $options->accepted_types;
$params->return_types = $options->return_types;
$params->context = $options->context;
$params->env = 'filemanager';
$params->disable_types = !empty($options->disable_types) ? $options->disable_types : array();
$filepicker_options = initialise_filepicker($params);
$this->options->filepicker = $filepicker_options;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:72,代码来源:filemanager.php
示例5: get_site_info
/**
* Return user information including profile picture + basic site information
* Note:
* - no capability checking because we return only known information about logged user
*
* @param array $serviceshortnames - DEPRECATED PARAMETER - values will be ignored -
* it was an original design error, we keep for backward compatibility.
* @return array site info
* @since Moodle 2.2
*/
public static function get_site_info($serviceshortnames = array())
{
global $USER, $SITE, $CFG, $DB;
$params = self::validate_parameters(self::get_site_info_parameters(), array('serviceshortnames' => $serviceshortnames));
$context = context_user::instance($USER->id);
$profileimageurl = moodle_url::make_pluginfile_url($context->id, 'user', 'icon', null, '/', 'f1');
// Site information.
$siteinfo = array('sitename' => $SITE->fullname, 'siteurl' => $CFG->wwwroot, 'username' => $USER->username, 'firstname' => $USER->firstname, 'lastname' => $USER->lastname, 'fullname' => fullname($USER), 'lang' => current_language(), 'userid' => $USER->id, 'userpictureurl' => $profileimageurl->out(false));
// Retrieve the service and functions from the web service linked to the token
// If you call this function directly from external (not a web service call),
// then it will still return site info without information about a service
// Note: wsusername/wspassword ws authentication is not supported.
$functions = array();
if ($CFG->enablewebservices) {
// No need to check token if web service are disabled and not a ws call.
$token = optional_param('wstoken', '', PARAM_ALPHANUM);
if (!empty($token)) {
// No need to run if not a ws call.
// Retrieve service shortname.
$servicesql = 'SELECT s.*
FROM {external_services} s, {external_tokens} t
WHERE t.externalserviceid = s.id AND token = ? AND t.userid = ? AND s.enabled = 1';
$service = $DB->get_record_sql($servicesql, array($token, $USER->id));
$siteinfo['downloadfiles'] = $service->downloadfiles;
$siteinfo['uploadfiles'] = $service->uploadfiles;
if (!empty($service)) {
// Return the release and version number for web service users only.
$siteinfo['release'] = $CFG->release;
$siteinfo['version'] = $CFG->version;
// Retrieve the functions.
$functionssql = "SELECT f.*\n FROM {external_functions} f, {external_services_functions} sf\n WHERE f.name = sf.functionname AND sf.externalserviceid = ?";
$functions = $DB->get_records_sql($functionssql, array($service->id));
} else {
throw new coding_exception('No service found in get_site_info: something is buggy, \\
it should have fail at the ws server authentication layer.');
}
}
}
// Build up the returned values of the list of functions.
$componentversions = array();
$availablefunctions = array();
foreach ($functions as $function) {
$functioninfo = array();
$functioninfo['name'] = $function->name;
if ($function->component == 'moodle' || $function->component == 'core') {
$version = $CFG->version;
// Moodle version.
} else {
$versionpath = core_component::get_component_directory($function->component) . '/version.php';
if (is_readable($versionpath)) {
// We store the component version once retrieved (so we don't load twice the version.php).
if (!isset($componentversions[$function->component])) {
$plugin = new stdClass();
include $versionpath;
$componentversions[$function->component] = $plugin->version;
$version = $plugin->version;
} else {
$version = $componentversions[$function->component];
}
} else {
// Function component should always have a version.php,
// otherwise the function should have been described with component => 'moodle'.
throw new moodle_exception('missingversionfile', 'webservice', '', $function->component);
}
}
$functioninfo['version'] = $version;
$availablefunctions[] = $functioninfo;
}
$siteinfo['functions'] = $availablefunctions;
// Mobile CSS theme and alternative login url.
$siteinfo['mobilecssurl'] = $CFG->mobilecssurl;
// Retrieve some advanced features. Only enable/disable ones (bool).
$advancedfeatures = array("usecomments", "usetags", "enablenotes", "messaging", "enableblogs", "enablecompletion", "enablebadges");
foreach ($advancedfeatures as $feature) {
if (isset($CFG->{$feature})) {
$siteinfo['advancedfeatures'][] = array('name' => $feature, 'value' => (int) $CFG->{$feature});
}
}
// Special case mnet_dispatcher_mode.
$siteinfo['advancedfeatures'][] = array('name' => 'mnet_dispatcher_mode', 'value' => $CFG->mnet_dispatcher_mode == 'strict' ? 1 : 0);
// User can manage own files.
$siteinfo['usercanmanageownfiles'] = has_capability('moodle/user:manageownfiles', $context);
// User quota. 0 means user can ignore the quota.
$siteinfo['userquota'] = 0;
if (!has_capability('moodle/user:ignoreuserquota', $context)) {
$siteinfo['userquota'] = $CFG->userquota;
}
// User max upload file size. -1 means the user can ignore the upload file size.
$siteinfo['usermaxuploadfilesize'] = get_user_max_upload_file_size($context, $CFG->maxbytes);
return $siteinfo;
//.........这里部分代码省略.........
开发者ID:educakanchay,项目名称:campus,代码行数:101,代码来源:externallib.php
示例6: date
$filename = date("Y-m-d_H_i_s", time()) . "_" . rand(100000, 900000) . ".jpg";
//open a stream on the posted data,
//this is better than $GLOBALS["HTTP_RAW_POST_DATA"], php.ini settings dont affect
$input = fopen("php://input", "r");
file_put_contents($CFG->dataroot . '/temp/download/' . $filename, $input);
//we should really check the filesize here but I don't know how
//HERE: check file size
//tell our widget what the filename we made up is
echo $filename;
//if receiveing a file with a name, eg from mp3recorder
} elseif (isset($_FILES["newfile"])) {
//make sure the user is logged in
require_login();
// make sure the file is not too big
$user_context = context_user::instance($USER->id);
$maxbytes = get_user_max_upload_file_size($user_context);
if ($maxbytes !== -1 && filesize($_FILES[$newfile]['tmp_name']) > $maxbytes) {
throw new file_exception('maxbytes');
}
//make sure the filename is clean, and then make the savepath
$filename = clean_param($_FILES["newfile"]['name'], PARAM_FILE);
if (preg_match('/\\.([a-z0-9]+)$/i', $filename, $match)) {
if (isset($match[1])) {
$ext = $match[1];
}
}
$ext = !empty($ext) ? $ext : '';
if ($ext != 'mp3') {
throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $filename)));
}
//make savepath
开发者ID:laiello,项目名称:poodll.poodll2,代码行数:31,代码来源:uploadHandler.php
示例7: definition
//.........这里部分代码省略.........
$options = array("1" => "File Upload", "2" => "Text Submission");
$mform->addElement('select', 'submissiontype', get_string('selectoption', 'turnitintool'), $options, array("class" => "formnarrow"));
$mform->addHelpButton('submissiontype', 'submissiontype', 'turnitintool');
break;
case 1:
case 2:
$mform->addElement('hidden', 'submissiontype', $turnitintool->type);
$mform->setType('submissiontype', PARAM_INT);
}
$istutor = turnitintool_istutor($USER->email);
$userid = $USER->id;
// User id if applicable.
if ($istutor) {
$mform->addElement('hidden', 'studentsname', $USER->id);
$mform->setType('studentsname', PARAM_INT);
}
$context = turnitintool_get_context('MODULE', $cm->id);
$submissiontitle = optional_param('submissiontitle', '', PARAM_CLEAN);
$disableform = false;
if (has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) {
$utype = "tutor";
// If tutor submitting on behalf of student
if (count($cansubmit) > 0) {
$module_group = turnitintool_module_group($cm);
$studentusers = array_keys(get_users_by_capability($context, 'mod/turnitintool:submit', 'u.id', '', '', '', $module_group, '', false));
// Append course users.
$courseusers = array();
$selected = "";
foreach ($cansubmit as $courseuser) {
// Filter Guest users, admins and grader users
if (in_array($courseuser->id, $studentusers)) {
if (!is_null($optional_params->userid) and $optional_params->userid == $courseuser->id) {
$selected = $courseuser->id;
}
$courseusers[$courseuser->id] = $courseuser->lastname . ', ' . $courseuser->firstname;
}
}
$select = $mform->addElement('select', 'userid', get_string('studentsname', 'turnitintool'), $courseusers, array("class" => "formnarrow", "onchange" => "updateSubForm(submissionArray,stringsArray,this.form," . $turnitintool->reportgenspeed . ")"));
$mform->addHelpButton('userid', 'studentsname', 'turnitintool');
if ($selected != "") {
$select->setSelected($selected);
}
if (empty($courseusers)) {
$mform->addElement('static', 'allsubmissionsmade', get_string('allsubmissionsmade', 'turnitintool'));
}
} else {
$mform->addElement('static', 'noenrolledstudents', get_string('noenrolledstudents', 'turnitintool'));
}
} else {
// If student submitting
$utype = "student";
$mform->addElement('hidden', 'userid', $USER->id);
$mform->setType('userid', PARAM_INT);
}
if (!$disableform) {
// Submission Title.
$mform->addElement('text', 'submissiontitle', get_string('submissiontitle', 'turnitintool'), array("class" => "formwide"));
$mform->setType('submissiontitle', PARAM_TEXT);
$mform->addHelpButton('submissiontitle', 'submissiontitle', 'turnitintool');
$mform->addRule('submissiontitle', get_string('submissiontitleerror', 'turnitintool'), 'required', '', 'client');
// Handle assignment parts.
if (count($parts) > 1) {
foreach ($parts as $part) {
$options_parts[$part->id] = $part->partname;
}
$mform->addElement('select', 'submissionpart', get_string('submissionpart', 'turnitintool'), $options_parts, array("class" => "formnarrow", "onchange" => "updateSubForm(submissionArray,stringsArray,this.form," . $turnitintool->reportgenspeed . ",'" . $utype . "')"));
$mform->addHelpButton('submissionpart', 'submissionpart', 'turnitintool');
} else {
foreach ($parts as $part) {
$mform->addElement('hidden', 'submissionpart', $part->id);
$mform->setType('submissionpart', PARAM_INT);
break;
}
}
// File input.
$maxbytessite = $CFG->maxbytes == 0 || $CFG->maxbytes > TURNITINTOOL_MAX_FILE_UPLOAD_SIZE ? TURNITINTOOL_MAX_FILE_UPLOAD_SIZE : $CFG->maxbytes;
$maxbytescourse = $COURSE->maxbytes == 0 || $COURSE->maxbytes > TURNITINTOOL_MAX_FILE_UPLOAD_SIZE ? TURNITINTOOL_MAX_FILE_UPLOAD_SIZE : $COURSE->maxbytes;
$maxfilesize = get_user_max_upload_file_size(context_module::instance($cm->id), $maxbytessite, $maxbytescourse, $turnitintool->maxfilesize);
$maxfilesize = $maxfilesize <= 0 ? TURNITINTOOL_MAX_FILE_UPLOAD_SIZE : $maxfilesize;
$turnitintoolfileuploadoptions = array('maxbytes' => $maxfilesize, 'subdirs' => false, 'maxfiles' => 1, 'accepted_types' => array('.doc', '.docx', '.rtf', '.txt', '.pdf', '.htm', '.html', '.odt', '.eps', '.ps', '.wpd', '.hwp', '.ppt', '.pptx', '.ppsx', '.pps'));
$mform->addElement('filemanager', 'submissionfile', get_string('filetosubmit', 'turnitintool'), null, $turnitintoolfileuploadoptions);
$mform->addHelpButton('submissionfile', 'filetosubmit', 'turnitintool');
// Text input input.
$mform->addElement('textarea', 'submissiontext', get_string('texttosubmit', 'turnitintool'), array("class" => "submissionText"));
$mform->addHelpButton('submissiontext', 'texttosubmit', 'turnitintool');
$checked = '';
if (!is_null($optional_params->agreement)) {
$checked = ' checked';
}
if (has_capability('mod/turnitintool:grade', $context) or empty($CFG->turnitin_agreement)) {
$mform->addElement('hidden', 'agreement', '1');
$mform->setType('agreement', PARAM_INT);
} else {
$mform->addElement('checkbox', 'agreement', '', $CFG->turnitin_agreement);
$mform->setDefault('agreement', '1', true);
}
$mform->addElement('submit', 'submitbutton', get_string('addsubmission', 'turnitintool'));
}
}
}
开发者ID:ULCC-QMUL,项目名称:moodle-mod_turnitintool,代码行数:101,代码来源:submit_assignment.php
示例8: update
/**
* Updates a lesson page and its answers within the database
*
* @param object $properties
* @return bool
*/
public function update($properties, $context = null, $maxbytes = null)
{
global $DB, $PAGE;
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
if (empty($properties->qoption)) {
$properties->qoption = '0';
}
if (empty($context)) {
$context = $PAGE->context;
}
if ($maxbytes === null) {
$maxbytes = get_user_max_upload_file_size($context);
}
$properties->timemodified = time();
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes), $context, 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
if (!array_key_exists($i, $this->answers)) {
$this->answers[$i] = new stdClass();
$this->answers[$i]->lessonid = $this->lesson->id;
$this->answers[$i]->pageid = $this->id;
$this->answers[$i]->timecreated = $this->timecreated;
}
if (!empty($properties->answer_editor[$i]) && is_array($properties->answer_editor[$i])) {
$this->answers[$i]->answer = $properties->answer_editor[$i]['text'];
$this->answers[$i]->answerformat = $properties->answer_editor[$i]['format'];
}
if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i])) {
$this->answers[$i]->response = $properties->response_editor[$i]['text'];
$this->answers[$i]->responseformat = $properties->response_editor[$i]['format'];
}
// we don't need to check for isset here because properties called it's own isset method.
if ($this->answers[$i]->answer != '') {
if (isset($properties->jumpto[$i])) {
$this->answers[$i]->jumpto = $properties->jumpto[$i];
}
if ($this->lesson->custom && isset($properties->score[$i])) {
$this->answers[$i]->score = $properties->score[$i];
}
if (!isset($this->answers[$i]->id)) {
$this->answers[$i]->id = $DB->insert_record("lesson_answers", $this->answers[$i]);
} else {
$DB->update_record("lesson_answers", $this->answers[$i]->properties());
}
// Save files in answers and responses.
$this->save_answers_files($context, $maxbytes, $this->answers[$i], $properties->answer_editor[$i], $properties->response_editor[$i]);
} else {
if (isset($this->answers[$i]->id)) {
$DB->delete_records('lesson_answers', array('id' => $this->answers[$i]->id));
unset($this->answers[$i]);
}
}
}
return true;
}
开发者ID:nikitskynikita,项目名称:moodle,代码行数:63,代码来源:locallib.php
示例9: get_string
$file->errortype = 'fileoversized';
$file->error = get_string('maxbytes', 'error');
} else {
$file->filepath = $_FILES[$fieldname]['tmp_name'];
// calculate total size of upload
$totalsize += $_FILES[$fieldname]['size'];
}
$files[] = $file;
}
$fs = get_file_storage();
if ($filearea == 'draft' && $itemid <= 0) {
$itemid = file_get_unused_draft_itemid();
}
// Get any existing file size limits.
$maxareabytes = FILE_AREA_MAX_BYTES_UNLIMITED;
$maxupload = get_user_max_upload_file_size($context, $CFG->maxbytes);
if ($filearea == 'private') {
// Private files area is limited by $CFG->userquota.
if (!has_capability('moodle/user:ignoreuserquota', $context)) {
$maxareabytes = $CFG->userquota;
}
// Count the size of all existing files in this area.
if ($maxareabytes > 0) {
$usedspace = 0;
$existingfiles = $fs->get_area_files($context->id, 'user', $filearea, false, 'id', false);
foreach ($existingfiles as $file) {
$usedspace += $file->get_filesize();
}
if ($totalsize > $maxareabytes - $usedspace) {
throw new file_exception('userquotalimit');
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:upload.php
示例10: file_options
public static function file_options()
{
global $COURSE, $PAGE, $CFG;
$configmaxbytes = get_config('local_mail', 'maxbytes') ?: LOCAL_MAIL_MAXBYTES;
$configmaxfiles = get_config('local_mail', 'maxfiles');
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes, $configmaxbytes);
$maxfiles = is_numeric($configmaxfiles) ? $configmaxfiles : LOCAL_MAIL_MAXFILES;
return array('accepted_types' => '*', 'maxbytes' => $maxbytes, 'maxfiles' => $maxfiles, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL, 'subdirs' => false);
}
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:9,代码来源:compose_form.php
示例11: get_max_bytes
/**
* @return int Max bytes for attachments or -1 if upload is prevented
*/
public function get_max_bytes()
{
if ($this->forumfields->attachmentmaxbytes) {
if ($this->forumfields->attachmentmaxbytes == -1) {
return -1;
} else {
return get_user_max_upload_file_size($this->get_context(), $this->forumfields->attachmentmaxbytes);
}
} else {
return get_user_max_upload_file_size($this->get_context(), $this->get_course()->maxbytes);
}
}
开发者ID:ULCC-QMUL,项目名称:moodle-mod_forumng,代码行数:15,代码来源:mod_forumng.php
示例12: get_string
if (!confirm_sesskey()) {
$err->error = get_string('invalidsesskey', 'error');
die(json_encode($err));
}
// Get repository instance information
$repooptions = array('ajax' => true, 'mimetypes' => $accepted_types);
ajax_capture_output();
$repo = repository::get_repository_by_id($repo_id, $contextid, $repooptions);
// Check permissions
$repo->check_capability();
$coursemaxbytes = 0;
if (!empty($course)) {
$coursemaxbytes = $course->maxbytes;
}
// Make sure maxbytes passed is within site filesize limits.
$maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes, $coursemaxbytes, $maxbytes, null, $repo->uses_post_requests());
// Wait as long as it takes for this script to finish
core_php_time_limit::raise();
// These actions all occur on the currently active repository instance
switch ($action) {
case 'sign':
case 'signin':
case 'list':
if ($repo->check_login()) {
$listing = repository::prepare_listing($repo->get_listing($req_path, $page));
$listing['repo_id'] = $repo_id;
ajax_check_captured_output();
echo json_encode($listing);
break;
} else {
$action = 'login';
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:31,代码来源:repository_ajax.php
示例13: update
/**
* Updates a lesson page and its answers within the database
*
* @param object $properties
* @return bool
*/
public function update($properties, $context = null, $maxbytes = null)
{
global $DB, $PAGE;
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
if (empty($properties->qoption)) {
$properties->qoption = '0';
}
if (empty($context)) {
$context = $PAGE->context;
}
if ($maxbytes === null) {
$maxbytes = get_user_max_upload_file_size($context);
}
$properties->timemodified = time();
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes), $context, 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
if ($this->type == self::TYPE_STRUCTURE && $this->get_typeid() != LESSON_PAGE_BRANCHTABLE) {
if (count($answers) > 1) {
$answer = array_shift($answers);
foreach ($answers as $a) {
$DB->delete_record('lesson_answers', array('id' => $a->id));
}
} else {
if (count($answers) == 1) {
$answer = array_shift($answers);
} else {
$answer = new stdClass();
$answer->lessonid = $properties->lessonid;
$answer->pageid = $properties->id;
$answer->timecreated = time();
}
}
$answer->timemodified = time();
if (isset($properties->jumpto[0])) {
$answer->jumpto = $properties->jumpto[0];
}
if (isset($properties->score[0])) {
$answer->score = $properties->score[0];
}
if (!empty($answer->id)) {
$DB->update_record("lesson_answers", $answer->properties());
} else {
$DB->insert_record("lesson_answers", $answer);
}
} else {
for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
if (!array_key_exists($i, $this->answers)) {
$this->answers[$i] = new stdClass();
$this->answers[$i]->lessonid = $this->lesson->id;
$this->answers[$i]->pageid = $this->id;
$this->answers[$i]->timecreated = $this->timecreated;
}
if (!empty($properties->answer_editor[$i]) && is_array($properties->answer_editor[$i])) {
$this->answers[$i]->answer = $properties->answer_editor[$i]['text'];
$this->answers[$i]->answerformat = $properties->answer_editor[$i]['format'];
}
if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i])) {
$this->answers[$i]->response = $properties->response_editor[$i]['text'];
$this->answers[$i]->responseformat = $properties->response_editor[$i]['format'];
}
if (isset($this->answers[$i]->answer) && $this->answers[$i]->answer != '') {
if (isset($properties->jumpto[$i])) {
$this->answers[$i]->jumpto = $properties->jumpto[$i];
}
if ($this->lesson->custom && isset($properties->score[$i])) {
$this->answers[$i]->score = $properties->score[$i];
}
if (!isset($this->answers[$i]->id)) {
$this->answers[$i]->id = $DB->insert_record("lesson_answers", $this->answers[$i]);
} else {
$DB->update_record("lesson_answers", $this->answers[$i]->properties());
}
} else {
if (isset($this->answers[$i]->id)) {
$DB->delete_records('lesson_answers', array('id' => $this->answers[$i]->id));
unset($this->answers[$i]);
}
}
}
}
return true;
}
开发者ID:educacionbe,项目名称:cursos,代码行数:90,代码来源:locallib.php
示例14: attachment_options
public static function attachment_options()
{
global $COURSE, $PAGE, $CFG;
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes, 0);
return array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
}
开发者ID:jrlamb,项目名称:alexBado,代码行数:6,代码来源:submission_form.php
示例15: print_error
print_error('notcreatestage', 'treasurehunt', $returnurl);
}
$stage = new stdClass();
$stage->id = null;
$stage->roadid = $roadid;
}
if (!isset($stage->questiontext) || $stage->questiontext === '') {
$stage->addsimplequestion = optional_param('addsimplequestion', 0, PARAM_INT);
$stage->noanswers = optional_param('noanswers', 2, PARAM_INT);
if (!empty($addanswers)) {
$stage->noanswers += NUMBER_NEW_ANSWERS;
}
}
$stage->cmid = $cmid;
$returnurl = new moodle_url('/mod/treasurehunt/edit.php', array('id' => $cmid, 'roadid' => $stage->roadid));
$maxbytes = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $COURSE->maxbytes);
$editoroptions = array('trusttext' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes, 'context' => $context, 'subdirs' => file_area_contains_subdirs($context, 'mod_treasurehunt', 'cluetext', $stage->id));
// List activities with Completion enabled
$completioninfo = new completion_info($course);
$completionactivities = $completioninfo->get_activities();
$mform = new stage_form(null, array('current' => $stage, 'context' => $context, 'editoroptions' => $editoroptions, 'completionactivities' => $completionactivities));
//name of the form you defined in file above.
if ($mform->is_reloaded()) {
// Si se ha recargado es porque hemos cambiado algo
} else {
if ($mform->is_cancelled()) {
// You need this section if you have a cancel button on your form
// here you tell php what to do if your user presses cancel
// probably a redirect is called for!
// PLEASE NOTE: is_cancelled() should be called before get_data().
redirect($returnurl);
开发者ID:juacas,项目名称:moodle-mod_treasurehunt,代码行数:31,代码来源:editstage.php
示例16: get_string
}
if (!confirm_sesskey()) {
$err->error = get_string('invalidsesskey', 'error');
die(json_encode($err));
}
// Get repository instance information
$repooptions = array('ajax' => true, 'mimetypes' => $accepted_types);
$repo = repository::get_repository_by_id($repo_id, $contextid, $repooptions);
// Check permissions
$repo->check_capability();
$coursemaxbytes = 0;
if (!empty($course)) {
$coursemaxbytes = $course->maxbytes;
}
// Make sure maxbytes passed is within site filesize limits.
$maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes, $coursemaxbytes, $maxbytes);
// Wait as long as it takes for this script to finish
core_php_time_limit::raise();
// These actions all occur on the currently active repository instance
switch ($action) {
case 'sign':
case 'signin':
case 'list':
if ($repo->check_login()) {
$listing = repository::prepare_listing($repo->get_listing($req_path, $page));
$listing['repo_id'] = $repo_id;
echo json_encode($listing);
break;
} else {
$action = 'login';
}
开发者ID:covex-nn,项目名称:moodle,代码行数:31,代码来源:repository_ajax.php
示例17: description_form_field_options
/**
* Options for displaying the rubric description field in the form
*
* @param object $context
* @return array options for the form description field
*/
public static function description_form_field_options($context)
{
global $CFG;
return array('maxfiles' => -1, 'maxbytes' => get_user_max_upload_file_size($context, $CFG->maxbytes), 'context' => $context);
}
开发者ID:JP-Git,项目名称:moodle,代码行数:11,代码来源:lib.php
示例18: update
/**
* Updates a lesson page and its answers within the database
*
* @param object $properties
* @return bool
*/
public function update($properties, $context = null, $maxbytes = null)
{
global $DB, $PAGE;
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
if (empty($properties->qoption)) {
$properties->qoption = '0';
}
if (empty($context)) {
$context = $PAGE->context;
}
if ($maxbytes === null) {
$maxbytes = get_user_max_upload_file_size($context);
}
$properties->timemodified = time();
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes), $context, 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
// Trigger an event: page updated.
\mod_lesson\event\page_updated::create_from_lesson_page($this, $context)->trigger();
if ($this->type == self::TYPE_STRUCTURE && $this->get_typeid() != LESSON_PAGE_BRANCHTABLE) {
// These page types have only one answer to save the jump and score.
if (count($answers) > 1) {
$answer = array_shift($answers);
foreach ($answers as $a) {
$DB->delete_record('lesson_answers', array('id' => $a->id));
}
} else {
if (count($answers) == 1) {
$answer = array_shift($answers);
} else {
$answer = new stdClass();
$answer->lessonid = $properties->lessonid;
$answer->pageid = $properties->id;
$answer->timecreated = time();
}
}
$answer->timemodified = time();
if (isset($properties->jumpto[0])) {
$answer->jumpto = $properties->jumpto[0];
}
if (isset($properties->score[0])) {
$answer->score = $properties->score[0];
}
if (!empty($answer->id)) {
$DB->update_record("lesson_answers", $answer->properties());
} else {
$DB->insert_record("lesson_answers", $answer);
}
} else {
for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
if (!array_key_exists($i, $this->answers)) {
$this->answers[$i] = new stdClass();
$this->answers[$i]->lessonid = $this->lesson->id;
$this->answers[$i]->pageid = $this->id;
$this->answers[$i]->timecreated = $this->timecreated;
}
if (isset($properties->answer_editor[$i])) {
if (is_array($properties->answer_editor[$i])) {
// Multichoice and true/false pages have an HTML editor.
$this->answers[$i]->answer = $properties->answer_editor[$i]['text'];
$this->answers[$i]->answerformat = $properties->answer_editor[$i]['format'];
} else {
// Branch tables, shortanswer and mumerical pages have only a text field.
$this->answers[$i]->answer = $properties->answer_editor[$i];
$this->answers[$i]->answerformat = FORMAT_MOODLE;
}
}
if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i]))
|
请发表评论