예제 #1
1
 /**
  * Constructor for the base resource class
  *
  * Constructor for the base resource class.
  * If cmid is set create the cm, course, resource objects.
  * and do some checks to make sure people can be here, and so on.
  *
  * @param cmid   integer, the current course module id - not set for new resources
  */
 function resource_base($cmid = 0)
 {
     global $CFG, $COURSE;
     $this->navlinks = array();
     if ($cmid) {
         if (!($this->cm = get_coursemodule_from_id('resource', $cmid))) {
             error("Course Module ID was incorrect");
         }
         if (!($this->course = get_record("course", "id", $this->cm->course))) {
             error("Course is misconfigured");
         }
         if (!($this->resource = get_record("resource", "id", $this->cm->instance))) {
             error("Resource ID was incorrect");
         }
         $this->strresource = get_string("modulename", "resource");
         $this->strresources = get_string("modulenameplural", "resource");
         if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
             $pagetitle = strip_tags($this->course->shortname . ': ' . $this->strresource);
             $navigation = build_navigation($this->navlinks, $this->cm);
             print_header($pagetitle, $this->course->fullname, $navigation, "", "", true, '', navmenu($this->course, $this->cm));
             notice(get_string("activityiscurrentlyhidden"), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}");
         }
     } else {
         $this->course = $COURSE;
     }
 }
예제 #2
0
 /**
  * Sets up the edit page
  *
  * @param string $baseurl the base url of the
  *
  * @return array Array of variables that the page is set up with
  */
 public function setup_page($baseurl)
 {
     global $PAGE, $CFG, $DB;
     $this->pagevars = array();
     $pageurl = new \moodle_url($baseurl);
     $pageurl->remove_all_params();
     $id = optional_param('cmid', false, PARAM_INT);
     $quizid = optional_param('quizid', false, PARAM_INT);
     // get necessary records from the DB
     if ($id) {
         $cm = get_coursemodule_from_id('activequiz', $id, 0, false, MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
         $quiz = $DB->get_record('activequiz', array('id' => $cm->instance), '*', MUST_EXIST);
     } else {
         $quiz = $DB->get_record('activequiz', array('id' => $quizid), '*', MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
         $cm = get_coursemodule_from_instance('activequiz', $quiz->id, $course->id, false, MUST_EXIST);
     }
     $this->get_parameters();
     // get the rest of the parameters and set them in the class
     if ($CFG->version < 2011120100) {
         $this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
     } else {
         $this->context = \context_module::instance($cm->id);
     }
     // set up question lib
     list($this->pageurl, $this->contexts, $cmid, $cm, $quiz, $this->pagevars) = question_edit_setup('editq', '/mod/activequiz/edit.php', true);
     $PAGE->set_url($this->pageurl);
     $this->pagevars['pageurl'] = $this->pageurl;
     $PAGE->set_title(strip_tags($course->shortname . ': ' . get_string("modulename", "activequiz") . ': ' . format_string($quiz->name, true)));
     $PAGE->set_heading($course->fullname);
     // setup classes needed for the edit page
     $this->RTQ = new \mod_activequiz\activequiz($cm, $course, $quiz, $this->pagevars);
     $this->RTQ->get_renderer()->init($this->RTQ, $this->pageurl, $this->pagevars);
 }
예제 #3
0
파일: lib.php 프로젝트: nigeldaley/moodle
/**
 * Gets the name for the provided section.
 *
 * @param stdClass $course
 * @param stdClass $section
 * @return string
 */
function callback_weeks_get_section_name($course, $section)
{
    // We can't add a node without text
    if (!empty($section->name)) {
        // Return the name the user set
        return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
    } else {
        if ($section->section == 0) {
            // Return the section0name
            return get_string('section0name', 'format_weeks');
        } else {
            // Got to work out the date of the week so that we can show it
            $sections = get_all_sections($course->id);
            $weekdate = $course->startdate + 7200;
            foreach ($sections as $sec) {
                if ($sec->id == $section->id) {
                    break;
                } else {
                    if ($sec->section != 0) {
                        $weekdate += 604800;
                    }
                }
            }
            $strftimedateshort = ' ' . get_string('strftimedateshort');
            $weekday = userdate($weekdate, $strftimedateshort);
            $endweekday = userdate($weekdate + 518400, $strftimedateshort);
            return $weekday . ' - ' . $endweekday;
        }
    }
}
예제 #4
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $syscontext = get_context_instance(CONTEXT_SYSTEM);
     $actions = array(0 => get_string('choose') . '...');
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[1] = get_string('confirm');
     }
     if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) {
         $actions[2] = get_string('messageselectadd');
     }
     if (has_capability('moodle/user:delete', $syscontext)) {
         $actions[3] = get_string('delete');
     }
     $actions[4] = get_string('displayonpage');
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[5] = get_string('download', 'admin');
     }
     if (has_capability('moodle/role:assign', $syscontext)) {
         $actions[6] = get_string('enrolmultipleusers', 'admin');
     }
     $objs = array();
     $objs[] =& $mform->createElement('select', 'action', null, $actions);
     $objs[] =& $mform->createElement('submit', 'doaction', get_string('go'));
     $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false);
 }
예제 #5
0
 function definition_after_data()
 {
     global $CFG;
     $mform =& $this->_form;
     $courseid = $mform->getElementValue('courseid');
     if ($id = $mform->getElementValue('id')) {
         $scale = grade_scale::fetch(array('id' => $id));
         $used = $scale->is_used();
         if ($used) {
             $mform->hardFreeze('scale');
         }
         if (empty($courseid)) {
             $mform->hardFreeze('standard');
         } else {
             if (empty($scale->courseid) and !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
                 $mform->hardFreeze('standard');
             } else {
                 if ($used and !empty($scale->courseid)) {
                     $mform->hardFreeze('standard');
                 }
             }
         }
         $usedstr = $scale->is_used() ? get_string('yes') : get_string('no');
         $used_el =& $mform->getElement('used');
         $used_el->setValue($usedstr);
     } else {
         $mform->removeElement('used');
         if (empty($courseid) or !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
             $mform->hardFreeze('standard');
         }
     }
 }
예제 #6
0
파일: editlib.php 프로젝트: nmicha/moodle
/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/gdlib.php";
    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    $user = $DB->get_record('user', array('id' => $usernew->id), 'id, picture', MUST_EXIST);
    $newpicture = $user->picture;
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'icon');
        // drop all images in area
        $newpicture = 0;
    } else {
        if ($iconfile = $userform->save_temp_file('imagefile')) {
            // There is a new image that has been uploaded
            // Process the new image and set the user to make use of it.
            // NOTE: Uploaded images always take over Gravatar
            $newpicture = (int) process_new_icon($context, 'user', 'icon', 0, $iconfile);
            // Delete the file that has now been processed
            @unlink($iconfile);
        }
    }
    if ($newpicture != $user->picture) {
        $DB->set_field('user', 'picture', $newpicture, array('id' => $user->id));
        return true;
    } else {
        return false;
    }
}
예제 #7
0
파일: enrol.php 프로젝트: vuchannguyen/web
 /**
  * Returns list of courses that we offer to the caller for remote enrolment of their users
  *
  * Since Moodle 2.0, courses are made available for MNet peers by creating an instance
  * of enrol_mnet plugin for the course. Hidden courses are not returned. If there are two
  * instances - one specific for the host and one for 'All hosts', the setting of the specific
  * one is used. The id of the peer is kept in customint1, no other custom fields are used.
  *
  * @uses mnet_remote_client Callable via XML-RPC only
  * @return array
  */
 public function available_courses()
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/filelib.php';
     if (!($client = get_mnet_remote_client())) {
         die('Callable via XML-RPC only');
     }
     // we call our id as 'remoteid' because it will be sent to the peer
     // the column aliases are required by MNet protocol API for clients 1.x and 2.0
     $sql = "SELECT c.id AS remoteid, c.fullname, c.shortname, c.idnumber, c.summary, c.summaryformat,\n                       c.sortorder, c.startdate, cat.id AS cat_id, cat.name AS cat_name,\n                       cat.description AS cat_description, cat.descriptionformat AS cat_descriptionformat,\n                       e.cost, e.currency, e.roleid AS defaultroleid, r.name AS defaultrolename,\n                       e.customint1\n                  FROM {enrol} e\n            INNER JOIN {course} c ON c.id = e.courseid\n            INNER JOIN {course_categories} cat ON cat.id = c.category\n            INNER JOIN {role} r ON r.id = e.roleid\n                 WHERE e.enrol = 'mnet'\n                       AND (e.customint1 = 0 OR e.customint1 = ?)\n                       AND c.visible = 1\n              ORDER BY cat.sortorder, c.sortorder, c.shortname";
     $rs = $DB->get_recordset_sql($sql, array($client->id));
     $courses = array();
     foreach ($rs as $course) {
         // use the record if it does not exist yet or is host-specific
         if (empty($courses[$course->remoteid]) or $course->customint1 > 0) {
             unset($course->customint1);
             // the client does not need to know this
             $context = get_context_instance(CONTEXT_COURSE, $course->remoteid);
             // Rewrite file URLs so that they are correct
             $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', false);
             $courses[$course->remoteid] = $course;
         }
     }
     $rs->close();
     return array_values($courses);
     // can not use keys for backward compatibility
 }
예제 #8
0
 /**
  * Constructor - instantiates one object of this class
  */
 public function __construct($name, $blockid, $moduleid = null, $plan = null)
 {
     global $DB;
     // Check blockid exists
     if (!($block = $DB->get_record('block_instances', array('id' => $blockid)))) {
         throw new backup_task_exception('block_task_block_instance_not_found', $blockid);
     }
     $this->blockid = $blockid;
     $this->blockname = $block->blockname;
     $this->contextid = get_context_instance(CONTEXT_BLOCK, $this->blockid)->id;
     $this->moduleid = $moduleid;
     $this->modulename = null;
     $this->parentcontextid = null;
     // If moduleid passed, check exists, supports moodle2 format and save info
     // Check moduleid exists
     if (!empty($moduleid)) {
         if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) {
             throw new backup_task_exception('block_task_coursemodule_not_found', $moduleid);
         }
         // Check activity supports this moodle2 backup format
         if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) {
             throw new backup_task_exception('block_task_activity_lacks_moodle2_backup_support', $coursemodule->modname);
         }
         $this->moduleid = $moduleid;
         $this->modulename = $coursemodule->modname;
         $this->parentcontextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id;
     }
     parent::__construct($name, $plan);
 }
예제 #9
0
 /**
  * Content generation method of block; list of page links
  **/
 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     global $CFG, $USER;
     $this->content = new stdClass();
     $user = CoursePrefsUser::findByUnique($USER->username);
     $this->content->icons = array();
     $this->content->footer = '';
     $this->content->items = array();
     $context = get_context_instance(CONTEXT_SYSTEM);
     if (has_capability('block/courseprefs:viewdata', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/content_viewer.php">' . get_string('content_viewer', 'block_courseprefs') . '</a>';
     }
     if (!$user || !$user->isTeacher()) {
         $this->content->items[] = get_string('block_request_link', 'block_courseprefs') . " <a href=\"{$CFG->wwwroot}/blocks/courseprefs/request.php\">here</a> to" . ' request a course';
         return $this->content;
     }
     // Removing Links that might break current courses
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/creation_enrol.php">' . get_string('creation_link', 'block_courseprefs') . '</a>';
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/split.php">' . get_string('split_link', 'block_courseprefs') . '</a>';
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/crosslist.php">' . get_string('crosslist_link', 'block_courseprefs') . '</a>';
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/teamteach.php">' . get_string('teamteach_link', 'block_courseprefs') . '</a>';
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/materials.php">' . get_string('materials_link', 'block_courseprefs') . '</a>';
     $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/unwanted.php">' . get_string('unwanted_link', 'block_courseprefs') . '</a>';
     return $this->content;
 }
 function get_content()
 {
     global $THEME, $CFG, $USER;
     // only for logged in users!
     if (!isloggedin() || isguest()) {
         return false;
     }
     // check for outgoing roaming permission first
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
         return '';
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     // TODO: Test this query - it's appropriate? It works?
     // get the hosts and whether we are doing SSO with them
     $sql = "\n             SELECT DISTINCT \n                 h.id, \n                 h.name,\n                 h.wwwroot,\n                 a.name as application,\n                 a.display_name\n             FROM \n                 {$CFG->prefix}mnet_host h,\n                 {$CFG->prefix}mnet_application a,\n                 {$CFG->prefix}mnet_host2service h2s_IDP,\n                 {$CFG->prefix}mnet_service s_IDP,\n                 {$CFG->prefix}mnet_host2service h2s_SP,\n                 {$CFG->prefix}mnet_service s_SP\n             WHERE\n                 h.id != '{$CFG->mnet_localhost_id}' AND\n                 h.id = h2s_IDP.hostid AND\n                 h.applicationid = a.id AND\n                 h2s_IDP.serviceid = s_IDP.id AND\n                 s_IDP.name = 'sso_idp' AND\n                 h2s_IDP.publish = '1' AND\n                 h.id = h2s_SP.hostid AND\n                 h2s_SP.serviceid = s_SP.id AND\n                 s_SP.name = 'sso_idp' AND\n                 h2s_SP.publish = '1'\n             ORDER BY\n                 a.display_name,\n                 h.name";
     $hosts = get_records_sql($sql);
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if ($hosts) {
         foreach ($hosts as $host) {
             $icon = '<img src="' . $CFG->pixpath . '/i/' . $host->application . '_host.gif"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />';
             $this->content->icons[] = $icon;
             if ($host->id == $USER->mnethostid) {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . s($host->name) . "</a>";
             } else {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) . "</a>";
             }
         }
     }
     return $this->content;
 }
예제 #11
0
파일: lib.php 프로젝트: esyacelga/sisadmaca
 protected function get_init_params($elementid, array $options = null)
 {
     global $CFG, $PAGE, $OUTPUT;
     //TODO: we need to implement user preferences that affect the editor setup too
     $directionality = get_string('thisdirection', 'langconfig');
     $strtime = get_string('strftimetime');
     $strdate = get_string('strftimedaydate');
     $lang = current_language();
     $contentcss = $PAGE->theme->editor_css_url()->out(false);
     $context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
     $xmedia = 'moodlemedia,';
     // HQ thinks it should be always on, so it is no matter if it will actually work or not
     /*
             if (!empty($options['legacy'])) {
                 $xmedia = 'moodlemedia,';
             } else {
                 if (!empty($options['noclean']) or !empty($options['trusted'])) {
                 }
             }*/
     $filters = filter_get_active_in_context($context);
     if (array_key_exists('filter/tex', $filters)) {
         $xdragmath = 'dragmath,';
     } else {
         $xdragmath = '';
     }
     if (array_key_exists('filter/emoticon', $filters)) {
         $xemoticon = 'moodleemoticon,';
     } else {
         $xemoticon = '';
     }
     $params = array('mode' => "exact", 'elements' => $elementid, 'relative_urls' => false, 'document_base_url' => $CFG->httpswwwroot, 'content_css' => $contentcss, 'language' => $lang, 'directionality' => $directionality, 'plugin_insertdate_dateFormat ' => $strdate, 'plugin_insertdate_timeFormat ' => $strtime, 'theme' => "advanced", 'skin' => "o2k7", 'skin_variant' => "silver", 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", 'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect", 'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen", 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright", 'theme_advanced_buttons2_add' => "|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,|,image,{$xemoticon}{$xmedia}{$xdragmath}nonbreaking,charmap", 'theme_advanced_buttons3_add' => "table,|,code,spellchecker", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom", 'spellchecker_rpc_url' => $CFG->wwwroot . "/lib/editor/tinymce/tiny_mce/{$this->version}/plugins/spellchecker/rpc.php");
     if ($xemoticon) {
         $manager = get_emoticon_manager();
         $emoticons = $manager->get_emoticons();
         $imgs = array();
         // see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S
         $index = 0;
         foreach ($emoticons as $emoticon) {
             $imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++)));
         }
         $params['moodleemoticon_emoticons'] = json_encode($imgs);
     }
     if (empty($CFG->xmlstrictheaders) and (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted']))) {
         // now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
         // but they scream even more when we strip all tags that are not strict :-(
         $params['valid_elements'] = 'script[src|type],*[*]';
         // for some reason the *[*] does not inlcude javascript src attribute MDL-25836
         $params['invalid_elements'] = '';
     }
     if (empty($options['legacy'])) {
         if (isset($options['maxfiles']) and $options['maxfiles'] != 0) {
             $params['file_browser_callback'] = "M.editor_tinymce.filepicker";
         }
     }
     //Add onblur event for client side text validation
     if (!empty($options['required'])) {
         $params['init_instance_callback'] = 'M.editor_tinymce.onblur_event';
     }
     return $params;
 }
 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $content = '';
     $footer = '';
     $nologin_auths = block_repository_nopasswd_auths();
     if (!empty($USER->auth) && in_array($USER->auth, $nologin_auths)) {
         return '';
     }
     if (isloggedin() && file_exists($CFG->dirroot . '/file/repository/alfresco/repository.php')) {
         require_once $CFG->dirroot . '/file/repository/repository.class.php';
         if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
             if ($repo = repository_factory::factory('alfresco')) {
                 if ($repo->alfresco_userdir($USER->username) !== false) {
                     // Fix username
                     $username = repository_plugin_alfresco::fix_username($USER->username);
                     // So that we don't conflict with the default Alfresco admin account.
                     $username = $username == 'admin' ? $CFG->repository_alfresco_admin_username : $username;
                     $hastenant = false;
                     // We must include the tenant portion of the username here.
                     if (($tenantname = strpos($CFG->repository_alfresco_server_username, '@')) > 0) {
                         $username .= substr($CFG->repository_alfresco_server_username, $tenantname);
                         $hastenant = true;
                     }
                     // Display a link to access the Alfresco repository directly.
                     $content .= get_string('webappaccess', 'block_repository', $repo->get_webapp_url()) . '<br /><br />';
                     // Display a link to the configured embedded WebDAV client (if defined).
                     if (!empty($CFG->block_course_repository_webdav_client)) {
                         $content .= get_string('embeddedwebdavlink', 'block_repository', $CFG->block_course_repository_webdav_client) . '<br /><br />';
                     }
                     if ($hastenant || $username != $USER->username) {
                         $content .= get_string('usernametenantinfo', 'block_repository', $username);
                     } else {
                         $content .= get_string('usernameinfo', 'block_repository', $username);
                     }
                     // Display a link to defined help files
                     if (!empty($CFG->block_course_repository_help_link)) {
                         $footer = get_string('helpfileslink', 'block_repository', $CFG->block_course_repository_help_link);
                     }
                 }
             }
         }
     }
     // If there is no content and the current user can actually modify the site settings, display some text
     // in the block explaining what is happening.
     if (empty($content) && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
         if (file_exists($CFG->dirroot . '/admin/file/repositories.php')) {
             $content = get_string('alfresconotconfigured', 'block_repository', $CFG->wwwroot . '/admin/file/' . 'repositories.php');
         } else {
             $content = get_string('norepositorypluginsystem', 'block_repository');
         }
     }
     $this->content = new stdClass();
     $this->content->text = $content;
     $this->content->footer = $footer;
     return $this->content;
 }
 public function __construct(stdClass $options)
 {
     global $CFG, $USER, $PAGE;
     require_once $CFG->dirroot . '/repository/lib.php';
     $defaults = array('accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'env' => 'filepicker', 'client_id' => uniqid(), 'itemid' => 0, 'maxbytes' => -1, 'maxfiles' => 1, 'buttonname' => false);
     foreach ($defaults as $key => $value) {
         if (empty($options->{$key})) {
             $options->{$key} = $value;
         }
     }
     $options->currentfile = '';
     if (!empty($options->itemid)) {
         $fs = get_file_storage();
         $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
         if (empty($options->filename)) {
             if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id DESC', false)) {
                 $file = reset($files);
             }
         } else {
             $file = $fs->get_file($usercontext->id, 'user', 'draft', $options->itemid, $options->filepath, $options->filename);
         }
         if (!empty($file)) {
             $options->currentfile = html_writer::link(moodle_url::make_draftfile_url($file->get_itemid(), $file->get_filepath(), $file->get_filename()), $file->get_filename());
         }
     }
     // initilise options, getting files in root path
     $this->options = initialise_filepicker($options);
     // copying other options
     foreach ($options as $name => $value) {
         if (!isset($this->options->{$name})) {
             $this->options->{$name} = $value;
         }
     }
 }
예제 #14
0
/**
 *
 * @since 2.0
 * @package blocks
 * @copyright 2011 Dustin Durand
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function xmldb_block_roomscheduler_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011150301) {
        $timenow = time();
        $sysctx = get_context_instance(CONTEXT_SYSTEM);
        /// Fully setup the Elluminate Moderator role.
        if (!($mrole = $DB->get_record('role', array('shortname' => 'roomschedulermanager')))) {
            if ($rid = create_role(get_string('roomschedulermanager', 'block_roomscheduler'), 'roomschedulemanager', get_string('roomschedulermanagerdescription', 'block_roomscheduler'))) {
                $mrole = $DB->get_record('role', array('id' => $rid));
                assign_capability('block/roomscheduler:manage', CAP_ALLOW, $mrole->id, $sysctx->id);
                set_role_contextlevels($mrole->id, array(CONTEXT_SYSTEM));
            } else {
                $mrole = $DB->get_record('role', array('shortname' => 'roomschedulermanager'));
                set_role_contextlevels($mrole->id, array(CONTEXT_SYSTEM));
            }
        }
        upgrade_block_savepoint(true, 2011150301, 'roomscheduler');
    }
    if ($oldversion < 2011140315) {
        // Define field reservable to be added to roomscheduler_rooms
        $table = new xmldb_table('roomscheduler_rooms');
        $field = new xmldb_field('reservable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'active');
        // Conditionally launch add field reservable
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_block_savepoint(true, 2011140315, 'roomscheduler');
    }
    return true;
}
예제 #15
0
 function get_content()
 {
     global $CFG, $OUTPUT;
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return '';
     }
     $this->content = new stdClass();
     $options = new stdClass();
     $options->noclean = true;
     // Don't clean Javascripts etc
     $options->overflowdiv = true;
     $context = get_context_instance(CONTEXT_COURSE, $this->page->course->id);
     $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
     $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
     if ($this->page->user_is_editing()) {
         if ($this->page->course->id == SITEID) {
             $editpage = $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=frontpagesettings';
         } else {
             $editpage = $CFG->wwwroot . '/course/edit.php?id=' . $this->page->course->id;
         }
         $this->content->text .= "<div class=\"editbutton\"><a href=\"{$editpage}\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"" . get_string('edit') . "\" /></a></div>";
     }
     $this->content->footer = '';
     return $this->content;
 }
예제 #16
0
/**
 * Save the course category
 *
 * @author Andrew Zoltay
 * date    2011-05-30
 * @global type $DB
 * @param string $categoryname
 * @param int $parent
 * @return boolean - success or failure
 */
function save_category($categoryname, $parent = 0)
{
    global $DB;
    // First off - don't save any categories that are null.
    if (empty($categoryname) or is_null($categoryname)) {
        return false;
    }
    // Next check to see if category already exists.
    $categoryid = $DB->get_field_select('course_categories', 'id', 'name = ? AND parent = ?', array($categoryname, $parent));
    // Finally save the category if it hasnt been found.
    if ($categoryid) {
        echo 'Found existing cat: ' . $categoryname . ' with id=' . $categoryid . '</br>';
        return $categoryid;
    } else {
        // Save the new category.
        $newcategory->name = $categoryname;
        $newcategory->description = '';
        // Don't define a description.
        $newcategory->descriptionformat = 1;
        // Default to HTML format.
        $newcategory->parent = $parent;
        $newcategory->sortorder = 999;
        $newcategory->id = $DB->insert_record('course_categories', $newcategory);
        $newcategory->context = get_context_instance(CONTEXT_COURSECAT, $newcategory->id);
        $categorycontext = $newcategory->context;
        mark_context_dirty($newcategory->context->path);
        // Now that we have the context, we need to update the category's path info.
        $DB->update_record('course_categories', $newcategory);
        fix_course_sortorder();
        echo 'Added new cat: ' . $categoryname . ' with id=' . $newcategory->id . '</br>';
        return $newcategory->id;
    }
}
예제 #17
0
 function get_content()
 {
     global $CFG, $OUTPUT;
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     /// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
     $currentcontext = $this->page->context;
     if ($this->page->course->id == SITEID) {
         if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
             $this->content = '';
             return $this->content;
         }
     } else {
         if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
             $this->content = '';
             return $this->content;
         }
     }
     $icon = '<img src="' . $OUTPUT->pix_url('i/users') . '" class="icon" alt="" />&nbsp;';
     $this->content->items[] = '<a title="' . get_string('listofallpeople') . '" href="' . $CFG->wwwroot . '/user/index.php?contextid=' . $currentcontext->id . '">' . $icon . get_string('participants') . '</a>';
     return $this->content;
 }
예제 #18
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $tocoursefilesid = $this->_customdata['tocoursefilesid'];
     $fromcoursefilesid = $this->_customdata['fromcoursefilesid'];
     if (isset($data['urls']) && count($data['urls'])) {
         foreach ($data['urls'] as $key => $urlaction) {
             switch ($urlaction) {
                 case QUESTION_FILEMOVE:
                     if (!has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $fromcoursefilesid))) {
                         $errors["urls[{$key}]"] = get_string('filecantmovefrom', 'question');
                     }
                     //no break; COPY check is also applied to MOVE action
                 //no break; COPY check is also applied to MOVE action
                 case QUESTION_FILECOPY:
                     if (!has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $tocoursefilesid))) {
                         $errors["urls[{$key}]"] = get_string('filecantmoveto', 'question');
                     }
                     break;
                 case QUESTION_FILEMOVELINKSONLY:
                 case QUESTION_FILEDONOTHING:
                     break;
             }
         }
     }
     //check that there hasn't been any changes in files between time form was displayed
     //and now when it has been submitted.
     if (isset($data['urls']) && count($data['urls']) != count($this->_customdata['urls'])) {
         $errors['urls[0]'] = get_string('errorfileschanged', 'question');
     }
     return $errors;
 }
예제 #19
0
 /**
  * Prints the tabs for the learning path type
  *
  * @param string $currenttab Tab to highlight
  * @return void
  **/
 function print_tabs($currenttab = 'layout')
 {
     global $COURSE;
     $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
     $tabs = $row = $inactive = $active = array();
     $row[] = new tabobject('view', $this->url_get_full(), get_string('editpage', 'format_page'));
     if (has_capability('format/page:addpages', $context)) {
         $row[] = new tabobject('addpage', $this->url_build('action', 'editpage'), get_string('addpage', 'format_page'));
     }
     if (has_capability('format/page:managepages', $context)) {
         $row[] = new tabobject('manage', $this->url_build('action', 'manage'), get_string('manage', 'format_page'));
     }
     if (has_capability('moodle/local:managepageactivities', $context)) {
         $row[] = new tabobject('activities', $this->url_build('action', 'activities'), get_string('managemods', 'format_page'));
     }
     if (has_capability('moodle/local:classifylearningpath', $context)) {
         $row[] = new tabobject('classify', $this->url_build('action', 'classify'), get_string('classification', 'local'));
     }
     if (has_capability('moodle/local:savelearningpathtemplate', $context)) {
         $row[] = new tabobject('backup', $this->url_build('action', 'backup'), get_string('makebackup', 'local'));
     }
     $tabs[] = $row;
     if (in_array($currenttab, array('layout', 'settings', 'view'))) {
         $active[] = 'view';
         $row = array();
         $row[] = new tabobject('layout', $this->url_get_full(), get_string('layout', 'format_page'));
         $row[] = new tabobject('settings', $this->url_get_full(array('action' => 'editpage')), get_string('settings', 'format_page'));
         $tabs[] = $row;
     }
     print_tabs($tabs, $currenttab, $inactive, $active);
 }
예제 #20
0
/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform) {
    global $CFG, $DB;
    require_once("$CFG->libdir/gdlib.php");

    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    // This will hold the value to set to the user's picture field at the end of
    // this function
    $picturetouse = null;
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'icon'); // drop all areas
        $picturetouse = 0;
    } else if ($iconfile = $userform->save_temp_file('imagefile')) {
        // There is a new image that has been uploaded
        // Process the new image and set the user to make use of it.
        // NOTE: This may be overridden by Gravatar
        if (process_new_icon($context, 'user', 'icon', 0, $iconfile)) {
            $picturetouse = 1;
        }
        // Delete the file that has now been processed
        @unlink($iconfile);
    }

    // If we have a picture to set we can now do so. Note this will still be NULL
    // unless the user has changed their picture or caused a change by selecting
    // to delete their picture or use gravatar
    if (!is_null($picturetouse)) {
        $DB->set_field('user', 'picture', $picturetouse, array('id' => $usernew->id));
        return true;
    }

    return false;
}
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $syscontext = get_context_instance(CONTEXT_SYSTEM);
     $actions = array(0 => get_string('choose') . '...');
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[1] = get_string('confirm');
     }
     if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) {
         $actions[2] = get_string('messageselectadd');
     }
     if (has_capability('moodle/user:delete', $syscontext)) {
         $actions[3] = get_string('delete');
     }
     $actions[4] = get_string('displayonpage');
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[5] = get_string('download', 'admin');
     }
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[6] = get_string('forcepasswordchange');
     }
     if (has_capability('moodle/user:update', $syscontext)) {
         // nadavkav
         $actions[7] = get_string('enrollintocourses', 'user_bulk_actions', '', $CFG->dirroot . '/admin/user/lang/');
     }
     if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) {
         // nadavkav
         $actions[8] = get_string('sendemail', 'user_bulk_actions', '', $CFG->dirroot . '/admin/user/lang/');
     }
     $objs = array();
     $objs[] =& $mform->createElement('select', 'action', null, $actions);
     $objs[] =& $mform->createElement('submit', 'doaction', get_string('choose'));
     $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false);
 }
예제 #22
0
 /**
  * Figure out whether annotation is permitted here
  */
 function can_annotate($url)
 {
     global $USER;
     if (isguestuser() or !isloggedin()) {
         return false;
     }
     $handler = annotation_summary_query::handler_for_url($url);
     if (!$handler) {
         return false;
     }
     $handler->fetch_metadata();
     if ($handler->modulename && $handler->courseid) {
         $cm = get_coursemodule_from_instance($handler->modulename, $handler->modinstanceid, $handler->courseid);
         if ($cm) {
             $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
             if (!$handler->capannotate) {
                 return false;
             } else {
                 return has_capability($handler->capannotate, $modcontext);
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function get_children()
 {
     global $DB;
     $children = array();
     if ($child = $this->browser->get_file_info($this->context, 'coursecat_intro', 0)) {
         $children[] = $child;
     }
     $course_cats = $DB->get_records('course_categories', array('parent' => $this->category->id), 'sortorder');
     foreach ($course_cats as $category) {
         $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
         if (!$category->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
             continue;
         }
         if ($child = $this->browser->get_file_info($context)) {
             $children[] = $child;
         }
     }
     $courses = $DB->get_records('course', array('category' => $this->category->id), 'sortorder');
     foreach ($courses as $course) {
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
         if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
             continue;
         }
         if ($child = $this->browser->get_file_info($context)) {
             $children[] = $child;
         }
     }
     return $children;
 }
예제 #24
0
/**
 * Creates a new Hawthorn object.
 * @param object $course Moodle course object. If not supplied, uses $COURSE.
 *   Only required field is ->id.
 */
function get_hawthorn($course = null)
{
    global $USER, $COURSE, $CFG;
    if ($course == null) {
        $course = $COURSE;
    }
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    // Work out user permissions
    $permissions = '';
    if (has_capability('block/hawthorn:chat', $context)) {
        $permissions .= 'rw';
    }
    if (has_capability('block/hawthorn:moderate', $context)) {
        $permissions .= 'm';
    }
    if (has_capability('block/hawthorn:admin', $context)) {
        $permissions .= 'a';
    }
    // Get user picture URL
    $userpic = print_user_picture($USER, $COURSE->id, NULL, 0, true, false);
    $userpic = preg_replace('~^.*src="([^"]*)".*$~', '$1', $userpic);
    // Decide key expiry (ms). Usually 1 hour, unless session timeout is lower.
    $keyExpiry = 3600000;
    if ($CFG->sessiontimeout * 1000 < $keyExpiry) {
        // Set expiry to session timeout (note that the JS will make a re-acquire
        // request 5 minutes before this)
        $keyExpiry = $CFG->sessiontimeout * 1000;
    }
    // Get server list
    $servers = empty($CFG->block_hawthorn_servers) ? array() : explode(',', $CFG->block_hawthorn_servers);
    $magicnumber = empty($CFG->block_hawthorn_magicnumber) ? 'xxx' : $CFG->block_hawthorn_magicnumber;
    // Construct Hawthorn object
    return new hawthorn($magicnumber, $servers, hawthorn::escapeId($USER->username), fullname($USER), $userpic, $permissions, $CFG->wwwroot . '/blocks/hawthorn/hawthorn.js', $CFG->wwwroot . '/blocks/hawthorn/popup.php', $CFG->wwwroot . '/blocks/hawthorn/reacquire.php', false, $keyExpiry);
}
예제 #25
0
    function validation($data, $files) {
        global $USER;

        if ($errors = parent::validation($data, $files)) {
            return $errors;
        }

        $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
        $fs = get_file_storage();

        if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['package'], 'id', false)) {
            if (!$this->current->instance) {
                $errors['package'] = get_string('required');
                return $errors;
            }
        } else {
            $file = reset($files);
            if ($file->get_mimetype() != 'application/zip') {
                $errors['package'] = get_string('invalidfiletype', 'error', '', $file);
                // better delete current file, it is not usable anyway
                $fs->delete_area_files($usercontext->id, 'user', 'draft', $data['package']);
            }
        }

        return $errors;
    }
 function get_content()
 {
     global $CFG, $COURSE;
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     // the following 3 lines is need to pass _self_test();
     if (empty($this->instance->pageid)) {
         return '';
     }
     $this->content = new object();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     /// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
     if (!($currentcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
         $this->content = '';
         return $this->content;
     }
     if ($COURSE->id == SITEID) {
         if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
             $this->content = '';
             return $this->content;
         }
     } else {
         if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
             $this->content = '';
             return $this->content;
         }
     }
     $this->content->items[] = '<a title="' . get_string('listofallpeople') . '" href="' . $CFG->wwwroot . '/user/index.php?contextid=' . $currentcontext->id . '">' . get_string('participants') . '</a>';
     $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/users.gif" class="icon" alt="" />';
     return $this->content;
 }
예제 #27
0
 public function get_children()
 {
     $children = array();
     if ($child = $this->browser->get_file_info($this->context, 'course_intro', 0)) {
         $children[] = $child;
     }
     if ($child = $this->browser->get_file_info($this->context, 'course_section')) {
         $children[] = $child;
     }
     if ($child = $this->browser->get_file_info($this->context, 'course_backup', 0)) {
         $children[] = $child;
     }
     if ($child = $this->browser->get_file_info($this->context, 'course_content', 0)) {
         $children[] = $child;
     }
     $modinfo = get_fast_modinfo($this->course);
     foreach ($modinfo->cms as $cminfo) {
         if (empty($cminfo->uservisible)) {
             continue;
         }
         $modcontext = get_context_instance(CONTEXT_MODULE, $cminfo->id);
         if ($child = $this->browser->get_file_info($modcontext)) {
             $children[] = $child;
         }
     }
     return $children;
 }
예제 #28
0
 /**
  * Create all the steps that will be part of this task
  */
 public function build()
 {
     // Define the task contextid (the course one)
     $this->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
     // Executed conditionally if restoring to new course or if overwrite_conf setting is enabled
     if ($this->get_target() == backup::TARGET_NEW_COURSE || $this->get_setting_value('overwrite_conf') == true) {
         $this->add_step(new restore_course_structure_step('course_info', 'course.xml'));
     }
     // Restore course role assignments and overrides (internally will observe the role_assignments setting)
     $this->add_step(new restore_ras_and_caps_structure_step('course_ras_and_caps', 'roles.xml'));
     // Restore course enrolments (plugins and membership). Conditionally prevented for any IMPORT/HUB operation
     if ($this->plan->get_mode() != backup::MODE_IMPORT && $this->plan->get_mode() != backup::MODE_HUB) {
         $this->add_step(new restore_enrolments_structure_step('course_enrolments', 'enrolments.xml'));
     }
     // Restore course filters (conditionally)
     if ($this->get_setting_value('filters')) {
         $this->add_step(new restore_filters_structure_step('course_filters', 'filters.xml'));
     }
     // Restore course comments (conditionally)
     if ($this->get_setting_value('comments')) {
         $this->add_step(new restore_comments_structure_step('course_comments', 'comments.xml'));
     }
     // At the end, mark it as built
     $this->built = true;
 }
function game_showusers($game)
{
    global $CFG, $USER, $DB;
    $users = array();
    $context = get_context_instance(CONTEXT_COURSE, $game->course);
    $groupid = optional_param('groupid', 0, PARAM_INT);
    $sql = "SELECT DISTINCT ra.userid,u.lastname,u.firstname FROM {role_assignments} ra, {user} u " . " WHERE ra.contextid={$context->id} AND ra.userid=u.id";
    if ($groupid != 0) {
        $sql .= " AND ra.userid IN (SELECT gm.userid FROM {groups_members} gm WHERE gm.groupid={$groupid})";
    }
    if ($recs = $DB->get_records_sql($sql)) {
        foreach ($recs as $rec) {
            $users[$rec->userid] = $rec->lastname . ' ' . $rec->firstname;
        }
    }
    if ($guest = guest_user()) {
        $users[$guest->id] = fullname($guest);
    }
    ?>
            <script type="text/javascript">
                function onselectuser()
                {
                    window.location.href = "<?php 
    echo $CFG->wwwroot . '/mod/game/showattempts.php?q=' . $game->id . '&userid=';
    ?>
" + document.getElementById('menuuser').value + '&groupid=' + document.getElementById('menugroup').value;
                }
            </script>
        <?php 
    $attributes = 'onchange="javascript:onselectuser();"';
    $name = 'user';
    $id = 'menu' . $name;
    $class = 'menu' . $name;
    $class = 'select ' . $class;
    /// Add 'select' selector always
    $nothing = get_string("allparticipants");
    $nothingvalue = '0';
    $options = $users;
    $selected = optional_param('userid', 0, PARAM_INT);
    $output = '<select id="' . $id . '" class="' . $class . '" name="' . $name . '" ' . $attributes . '>' . "\n";
    $output .= '   <option value="' . s($nothingvalue) . '"' . "\n";
    if ($nothingvalue === $selected) {
        $output .= ' selected="selected"';
    }
    $output .= '>' . $nothing . '</option>' . "\n";
    if (!empty($options)) {
        foreach ($options as $value => $label) {
            $output .= '   <option value="' . s($value) . '"';
            if ((string) $value == (string) $selected || is_array($selected) && in_array($value, $selected)) {
                $output .= ' selected="selected"';
            }
            if ($label === '') {
                $output .= '>' . $value . '</option>' . "\n";
            } else {
                $output .= '>' . $label . '</option>' . "\n";
            }
        }
    }
    echo $output . '</select>' . "\n";
}
예제 #30
0
    public function definition() {
        global $CFG;

        $item = $this->_customdata['item'];
        $common = $this->_customdata['common'];
        $presentationoptions = $this->_customdata['presentationoptions'];
        $positionlist = $this->_customdata['positionlist'];
        $position = $this->_customdata['position'];

        $context = get_context_instance(CONTEXT_MODULE, $common['cmid']);

        $mform =& $this->_form;

        $mform->addElement('hidden', 'required', 0);
        $mform->setType('required', PARAM_INT);
        $mform->addElement('hidden', 'name', 'label');
        $mform->setType('template', PARAM_ALPHA);
        $mform->addElement('hidden', 'label', '-');
        $mform->setType('label', PARAM_ALPHA);

        $mform->addElement('header', 'general', get_string($this->type, 'feedback'));
        $mform->addElement('editor', 'presentation_editor', '', null, $presentationoptions);
        $mform->setType('presentation_editor', PARAM_CLEANHTML);

        parent::definition();
        $this->set_data($item);

    }