function instance_config_save($data, $nolongerused = false)
 {
     if (empty($data->quizid)) {
         $data->quizid = $this->get_owning_quiz();
     }
     parent::instance_config_save($data);
 }
 function get_required_javascript()
 {
     parent::get_required_javascript();
     $this->page->requires->jquery();
     $this->page->requires->jquery_plugin('ui');
     $this->page->requires->jquery_plugin('ui-css');
 }
 function after_install()
 {
     global $CFG;
     // initialize the global configuration
     $global_config = array("block_moodle_notifications_email_channel" => 1, "block_moodle_notifications_sms_channel" => 1, "block_moodle_notifications_rss_channel" => 1, "block_moodle_notifications_frequency" => 12, "block_moodle_notifications_email_notification_preset" => 1, "block_moodle_notifications_sms_notification_preset" => 1);
     return parent::config_save($global_config);
 }
예제 #4
0
 function instance_config_save($data)
 {
     if (empty($data->quizid)) {
         $data->quizid = $this->get_owning_quiz();
     }
     parent::instance_config_save($data);
 }
예제 #5
0
 function definition()
 {
     $mform =& $this->_form;
     // First show fields specific to this type of block.
     $this->specific_definition($mform);
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'whereheader', get_string('wherethisblockappears', 'block'));
     // If the current weight of the block is out-of-range, add that option in.
     $blockweight = $this->block->instance->weight;
     $weightoptions = array();
     if ($blockweight < -block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     for ($i = -block_manager::MAX_WEIGHT; $i <= block_manager::MAX_WEIGHT; $i++) {
         $weightoptions[$i] = $i;
     }
     if ($blockweight > block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     $first = reset($weightoptions);
     $weightoptions[$first] = get_string('bracketfirst', 'block', $first);
     $last = end($weightoptions);
     $weightoptions[$last] = get_string('bracketlast', 'block', $last);
     $regionoptions = $this->page->theme->get_all_block_regions();
     $parentcontext = get_context_instance_by_id($this->block->instance->parentcontextid);
     $mform->addElement('static', 'contextname', get_string('thisblockbelongsto', 'block'), print_context_name($parentcontext));
     $mform->addElement('selectyesno', 'bui_showinsubcontexts', get_string('appearsinsubcontexts', 'block'));
     $pagetypeoptions = matching_page_type_patterns($this->page->pagetype);
     $pagetypeoptions = array_combine($pagetypeoptions, $pagetypeoptions);
     $mform->addElement('select', 'bui_pagetypepattern', get_string('pagetypes', 'block'), $pagetypeoptions);
     if ($this->page->subpage) {
         $subpageoptions = array('%@NULL@%' => get_string('anypagematchingtheabove', 'block'), $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage));
         $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions);
     }
     $defaultregionoptions = $regionoptions;
     $defaultregion = $this->block->instance->defaultregion;
     if (!array_key_exists($defaultregion, $defaultregionoptions)) {
         $defaultregionoptions[$defaultregion] = $defaultregion;
     }
     $mform->addElement('select', 'bui_defaultregion', get_string('defaultregion', 'block'), $defaultregionoptions);
     $mform->addElement('select', 'bui_defaultweight', get_string('defaultweight', 'block'), $weightoptions);
     // Where this block is positioned on this page.
     $mform->addElement('header', 'whereheader', get_string('onthispage', 'block'));
     $mform->addElement('selectyesno', 'bui_visible', get_string('visible', 'block'));
     $blockregion = $this->block->instance->region;
     if (!array_key_exists($blockregion, $regionoptions)) {
         $regionoptions[$blockregion] = $blockregion;
     }
     $mform->addElement('select', 'bui_region', get_string('region', 'block'), $regionoptions);
     $mform->addElement('select', 'bui_weight', get_string('weight', 'block'), $weightoptions);
     $pagefields = array('bui_visible', 'bui_region', 'bui_weight');
     if (!$this->block->user_can_edit()) {
         $mform->hardFreezeAllVisibleExcept($pagefields);
     }
     if (!$this->page->user_can_edit_blocks()) {
         $mform->hardFreeze($pagefields);
     }
     $this->add_action_buttons();
 }
 public function get_required_javascript()
 {
     global $PAGE;
     $PAGE->requires->yui_module('moodle-block_databasebookmarks-bookmark', 'M.block_databasebookmarks.bookmark.init');
     $PAGE->requires->strings_for_js(array('deletebookmark', 'bookmark', 'bookmarkname', 'bookmarkheader'), 'block_databasebookmarks');
     $PAGE->requires->strings_for_js(array('buttons'), 'mod_data');
     return parent::get_required_javascript();
 }
예제 #7
0
 /**
  * Returns the attributes to set for this block
  *
  * This function returns an array of HTML attributes for this block including
  * the defaults.
  * {@link block_tree::html_attributes()} is used to get the default arguments
  * and then we check whether the user has enabled hover expansion and add the
  * appropriate hover class if it has.
  *
  * @return array An array of HTML attributes
  */
 public function html_attributes()
 {
     $attributes = parent::html_attributes();
     if (!empty($this->config->enablehoverexpansion) && $this->config->enablehoverexpansion == 'yes') {
         $attributes['class'] .= ' block_js_expansion';
     }
     $attributes['class'] .= ' block_uai';
     return $attributes;
 }
 /**
  * Serialize and store config data
  */
 function instance_config_save($data, $nolongerused = false)
 {
     global $DB;
     $config = clone $data;
     // Move embedded files into a proper filearea and adjust HTML links to match
     $config->text = file_save_draft_area_files($data->text['itemid'], $this->context->id, 'block_html', 'content', 0, array('subdirs' => true), $data->text['text']);
     $config->format = $data->text['format'];
     parent::instance_config_save($config, $nolongerused);
 }
 function instance_config_save($data)
 {
     $savedata = null;
     if (isset($data->general['moduleUrl'])) {
         $savedata->moduleUrl = $data->general['moduleUrl'];
     }
     $savedata->configuration = $data->configuration;
     $savedata->preferences = $data->preferences;
     return parent::instance_config_save($savedata);
 }
예제 #10
0
 function _print_block()
 {
     global $USER;
     // make sure they are looged in or they cant see it
     if (isloggedin() && isset($USER) && $USER->username != 'guest') {
         return parent::_print_block();
     } else {
         return "";
     }
 }
예제 #11
0
 /**
  * Will be called before an instance of this block is backed up, so that any links in
  * any links in any HTML fields on config can be encoded.
  * @return string
  */
 function get_backup_encoded_config()
 {
     /// Prevent clone for non configured block instance. Delegate to parent as fallback.
     if (empty($this->config)) {
         return parent::get_backup_encoded_config();
     }
     $data = clone $this->config;
     $data->text = backup_encode_absolute_links($data->text);
     return base64_encode(serialize($data));
 }
 /**
  * The block depends upon a React app (which should only be loaded once).
  * Unfortunately, it is necessary to use the Moodle page requirements manager.
  * It is also necessary to hide RequireJS from the React app.
  */
 public function get_required_javascript()
 {
     parent::get_required_javascript();
     // if debugging, load unminified script
     $script_src = 'build/activity_tree.min.js';
     if (debugging()) {
         $script_src = str_replace('.min.js', '.js', $script_src);
     }
     /** @var page_requirements_manager $prm */
     $prm = $this->page->requires;
     $prm->js('/blocks/activity_tree/static/js/other/requirejs_hide.js');
     $prm->js(new moodle_url('/blocks/activity_tree/static/js/' . $script_src));
     $prm->js('/blocks/activity_tree/static/js/other/requirejs_show.js');
 }
예제 #13
0
 function instance_config($instance)
 {
     parent::instance_config($instance);
     $course = get_record('course', 'id', $this->instance->pageid);
     if (isset($course->format)) {
         if ($course->format == 'topics') {
             $this->title = get_string('topics', 'block_section_links');
         } else {
             if ($course->format == 'weeks') {
                 $this->title = get_string('weeks', 'block_section_links');
             } else {
                 $this->title = get_string('blockname', 'block_section_links');
             }
         }
     }
 }
예제 #14
0
 function instance_config($instance)
 {
     global $DB;
     parent::instance_config($instance);
     $course = $this->page->course;
     if (isset($course->format)) {
         if ($course->format == 'topics') {
             $this->title = get_string('topics', 'block_section_links');
         } else {
             if ($course->format == 'weeks') {
                 $this->title = get_string('weeks', 'block_section_links');
             } else {
                 $this->title = get_string('pluginname', 'block_section_links');
             }
         }
     }
 }
예제 #15
0
 /**
  * @desc Saves the form data from configuration into the wwassignment_bridge table.
  */
 function instance_config_save($data)
 {
     $webworkcourse = $data->webwork_link_id;
     $moodlecourse = $data->courseid;
     $wwassignmentbridge = new stdClass();
     $wwassignmentbridge->course = $moodlecourse;
     $wwassignmentbridge->webwork_course = $webworkcourse;
     //has this mapping been defined
     $record = get_record('wwassignment_bridge', 'course', $moodlecourse);
     if (!$record) {
         //new one
         insert_record('wwassignment_bridge', $wwassignmentbridge);
     } else {
         //update
         $wwassignmentbridge->id = $record->id;
         update_record('wwassignment_bridge', $wwassignmentbridge);
     }
     return parent::instance_config_save($data);
 }
 public function instance_config_save($data)
 {
     global $DB, $USER;
     $alerts = $DB->get_records('block_itutor_profiler_alerts', array('course_id' => $data->courseid));
     foreach ($alerts as $alert) {
         $s = 'isalerting' . $alert->id;
         //alert has been unticked
         if (!isset($data->{$s})) {
             //remove alert from database
             $DB->delete_records('block_itutor_profiler_alerts', array('id' => $alert->id));
         }
         unset($data->{$s});
     }
     //If new alert create => add it to the DB
     if ($data->alerttype != 0) {
         $record = new stdClass();
         $record->course_id = $data->courseid;
         $record->alert_date = $data->alertdate;
         $record->alert_type = $data->alerttype;
         $record->alert_data = $data->alertdata;
         $record->alert_message = $data->alertmessage;
         if (isset($data->sendtostaff)) {
             $record->alert_sendto = $USER->id;
         } else {
             $record->alert_sendto = null;
         }
         $DB->insert_record('block_itutor_profiler_alerts', $record, false);
         //false, no return, no bulk
     }
     unset($data->courseid);
     unset($data->alertdate);
     unset($data->alerttype);
     unset($data->alertdata);
     unset($data->alertmessage);
     unset($data->sendtostaff);
     //Call normal save functionality
     return parent::instance_config_save($data);
 }
예제 #17
0
파일: blocklib.php 프로젝트: Burick/moodle
 /**
  * @param block_base $block a block that appears on this page.
  * @return boolean boolean whether the currently logged in user is allowed to delete this block.
  */
 protected function user_can_delete_block($block)
 {
     return $this->page->user_can_edit_blocks() && $block->user_can_edit() && $block->user_can_addto($this->page) && !in_array($block->instance->blockname, self::get_undeletable_block_types());
 }
 /**
  * Serialize and store config data
  */
 function instance_config_save($data, $nolongerused = false)
 {
     global $USER, $COURSE;
     $config = new stdClass();
     foreach ($data as $fieldname => $fieldvalue) {
         if (is_array($fieldvalue)) {
             $config->{$fieldname} = array();
         } else {
             $config->{$fieldname} = $fieldvalue;
         }
     }
     $fileoptions = array('subdirs' => false, 'maxfiles' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'web_image', 'return_types' => FILE_INTERNAL);
     $saved = 0;
     for ($i = 0; $i < $data->slides; $i++) {
         $usercontext = context_user::instance($USER->id);
         $fs = get_file_storage();
         $draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $data->imageslide[$i], 'id');
         if (count($draftfiles) > 1 || isset($data->title[$i]) && !empty($data->title[$i]) || isset($data->caption[$i]) && !empty($data->caption[$i]) || isset($data->link[$i]) && !empty($data->link[$i])) {
             $config->enabled[$saved] = 0;
             if (isset($data->enabled[$i]) && !empty($data->enabled[$i])) {
                 $config->enabled[$saved] = $data->enabled[$i];
                 if ($data->firstslide >= $saved) {
                     $config->firstslide = $saved;
                 }
             }
             if (isset($data->imageslide[$i]) && !empty($data->imageslide[$i])) {
                 $config->imageslide[$saved] = $data->imageslide[$i];
                 file_save_draft_area_files($config->imageslide[$saved], $this->context->id, 'block_slideshow', 'slides', $saved, $fileoptions);
             }
             $config->imageposition[$saved] = isset($data->imageposition[$i]) && !empty($data->imageposition[$i]) ? $data->imageposition[$i] : '';
             $config->title[$saved] = isset($data->title[$i]) && !empty($data->title[$i]) ? $data->title[$i] : '';
             $config->caption[$saved] = isset($data->caption[$i]) && !empty($data->caption[$i]) ? $data->caption[$i] : '';
             $config->captionposition[$saved] = isset($data->captionposition[$i]) && !empty($data->captionposition[$i]) ? $data->captionposition[$i] : '';
             $config->link[$saved] = isset($data->link[$i]) && !empty($data->link[$i]) ? $data->link[$i] : '';
             $saved++;
         }
     }
     for ($i = $saved; $i < $data->slides; $i++) {
         file_save_draft_area_files($data->imageslide[$i], $this->context->id, 'block_slideshow', 'slides', $i, $fileoptions);
     }
     $config->slides = $saved;
     parent::instance_config_save($config, $nolongerused);
 }
 public function instance_can_be_docked()
 {
     return parent::instance_can_be_docked() && (empty($this->config->enabledock) || $this->config->enabledock == 'yes');
 }
 function instance_config_save($data, $notused = false)
 {
     global $USER;
     // check if curent user forcing a filelocationadminoverride can really do it
     // in case it seems to be forced, set it to empty anyway.
     if (!has_capability('block/dashboard:systempathaccess', context_system::instance())) {
         $data->filepathadminoverride = '';
     }
     // retrieve sql params directly from POST
     $data->sqlparams = @$_POST['sqlparams'];
     // print_object($data);
     return parent::instance_config_save($data, $notused);
 }
예제 #21
0
 function instance_config_save($data, $nolongerused = false)
 {
     parent::instance_config_save($data);
 }
예제 #22
0
 function html_attributes()
 {
     $attributes = parent::html_attributes();
     $attributes['class'] .= ' list_block';
     return $attributes;
 }
예제 #23
0
 /**
  * The block should only be dockable when the title of the block is not empty
  * and when parent allows docking.
  *
  * @return bool
  */
 public function instance_can_be_docked()
 {
     return !empty($this->config->title) && parent::instance_can_be_docked();
 }
예제 #24
0
 /**
  * Used to save the form config data
  * @param stdclass $data
  * @param bool $nolongerused
  */
 public function instance_config_save($data, $nolongerused = false)
 {
     global $DB;
     if (empty($data->activitygradeitemid)) {
         // Figure out info about parent module.
         $info = $this->get_owning_activity();
         $data->activitygradeitemid = $info->id;
         if ($info->id < 1) {
             // No activity was selected.
             $info->itemmodule = '';
             $info->iteminstance = '';
         } else {
             $data->activityparent = $info->itemmodule;
             $data->activityparentid = $info->iteminstance;
         }
     } else {
         // Lookup info about the parent module (we have the id from mdl_grade_items.
         $info = $DB->get_record('grade_items', array('id' => $data->activitygradeitemid));
         $data->activityparent = $info->itemmodule;
         $data->activityparentid = $info->iteminstance;
     }
     parent::instance_config_save($data);
 }
    function reportdashboard_attributes() {
        global $CFG;

        $attributes = parent::reportdashboard_attributes();

        if (!empty($CFG->block_reportdashboard_allowcssclasses)) {
            if (!empty($this->config->classes)) {
                $attributes['class'] .= ' ' . $this->config->classes;
            }
        }

        return $attributes;
    }
 public function html_attributes()
 {
     $attributes = parent::html_attributes();
     $attributes['class'] .= ' block_' . $this->name();
     return $attributes;
 }
예제 #27
0
 function definition()
 {
     $mform =& $this->_form;
     // First show fields specific to this type of block.
     $this->specific_definition($mform);
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'whereheader', get_string('wherethisblockappears', 'block'));
     // If the current weight of the block is out-of-range, add that option in.
     $blockweight = $this->block->instance->weight;
     $weightoptions = array();
     if ($blockweight < -block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     for ($i = -block_manager::MAX_WEIGHT; $i <= block_manager::MAX_WEIGHT; $i++) {
         $weightoptions[$i] = $i;
     }
     if ($blockweight > block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     $first = reset($weightoptions);
     $weightoptions[$first] = get_string('bracketfirst', 'block', $first);
     $last = end($weightoptions);
     $weightoptions[$last] = get_string('bracketlast', 'block', $last);
     $regionoptions = $this->page->theme->get_all_block_regions();
     foreach ($this->page->blocks->get_regions() as $region) {
         // Make sure to add all custom regions of this particular page too.
         if (!isset($regionoptions[$region])) {
             $regionoptions[$region] = $region;
         }
     }
     $parentcontext = context::instance_by_id($this->block->instance->parentcontextid);
     $mform->addElement('hidden', 'bui_parentcontextid', $parentcontext->id);
     $mform->setType('bui_parentcontextid', PARAM_INT);
     $mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), $parentcontext->get_context_name());
     $mform->addHelpButton('bui_homecontext', 'createdat', 'block');
     // For pre-calculated (fixed) pagetype lists
     $pagetypelist = array();
     // parse pagetype patterns
     $bits = explode('-', $this->page->pagetype);
     // First of all, check if we are editing blocks @ front-page or no and
     // make some dark magic if so (MDL-30340) because each page context
     // implies one (and only one) harcoded page-type that will be set later
     // when processing the form data at {@link block_manager::process_url_edit()}
     // There are some conditions to check related to contexts
     $ctxconditions = $this->page->context->contextlevel == CONTEXT_COURSE && $this->page->context->instanceid == get_site()->id;
     // And also some pagetype conditions
     $pageconditions = isset($bits[0]) && isset($bits[1]) && $bits[0] == 'site' && $bits[1] == 'index';
     // So now we can be 100% sure if edition is happening at frontpage
     $editingatfrontpage = $ctxconditions && $pageconditions;
     // Let the form to know about that, can be useful later
     $mform->addElement('hidden', 'bui_editingatfrontpage', (int) $editingatfrontpage);
     $mform->setType('bui_editingatfrontpage', PARAM_INT);
     // Front page, show the page-contexts element and set $pagetypelist to 'any page' (*)
     // as unique option. Processign the form will do any change if needed
     if ($editingatfrontpage) {
         $contextoptions = array();
         $contextoptions[BUI_CONTEXTS_FRONTPAGE_ONLY] = get_string('showonfrontpageonly', 'block');
         $contextoptions[BUI_CONTEXTS_FRONTPAGE_SUBS] = get_string('showonfrontpageandsubs', 'block');
         $contextoptions[BUI_CONTEXTS_ENTIRE_SITE] = get_string('showonentiresite', 'block');
         $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);
         $mform->addHelpButton('bui_contexts', 'contexts', 'block');
         $pagetypelist['*'] = '*';
         // This is not going to be shown ever, it's an unique option
         // Any other system context block, hide the page-contexts element,
         // it's always system-wide BUI_CONTEXTS_ENTIRE_SITE
     } else {
         if ($parentcontext->contextlevel == CONTEXT_SYSTEM) {
             $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_ENTIRE_SITE);
         } else {
             if ($parentcontext->contextlevel == CONTEXT_COURSE) {
                 // 0 means display on current context only, not child contexts
                 // but if course managers select mod-* as pagetype patterns, block system will overwrite this option
                 // to 1 (display on current context and child contexts)
                 $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_CURRENT);
             } else {
                 if ($parentcontext->contextlevel == CONTEXT_MODULE or $parentcontext->contextlevel == CONTEXT_USER) {
                     // module context doesn't have child contexts, so display in current context only
                     $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_CURRENT);
                 } else {
                     $parentcontextname = $parentcontext->get_context_name();
                     $contextoptions[BUI_CONTEXTS_CURRENT] = get_string('showoncontextonly', 'block', $parentcontextname);
                     $contextoptions[BUI_CONTEXTS_CURRENT_SUBS] = get_string('showoncontextandsubs', 'block', $parentcontextname);
                     $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);
                 }
             }
         }
     }
     $mform->setType('bui_contexts', PARAM_INT);
     // Generate pagetype patterns by callbacks if necessary (has not been set specifically)
     if (empty($pagetypelist)) {
         $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context);
         $displaypagetypewarning = false;
         if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) {
             // Pushing block's existing page type pattern
             $pagetypestringname = 'page-' . str_replace('*', 'x', $this->block->instance->pagetypepattern);
             if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) {
                 $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype');
             } else {
                 //as a last resort we could put the page type pattern in the select box
                 //however this causes mod-data-view to be added if the only option available is mod-data-*
                 // so we are just showing a warning to users about their prev setting being reset
                 $displaypagetypewarning = true;
             }
         }
     }
     // hide page type pattern select box if there is only one choice
     if (count($pagetypelist) > 1) {
         if ($displaypagetypewarning) {
             $mform->addElement('static', 'pagetypewarning', '', get_string('pagetypewarning', 'block'));
         }
         $mform->addElement('select', 'bui_pagetypepattern', get_string('restrictpagetypes', 'block'), $pagetypelist);
     } else {
         $values = array_keys($pagetypelist);
         $value = array_pop($values);
         $mform->addElement('hidden', 'bui_pagetypepattern', $value);
         $mform->setType('bui_pagetypepattern', PARAM_RAW);
         // Now we are really hiding a lot (both page-contexts and page-type-patterns),
         // specially in some systemcontext pages having only one option (my/user...)
         // so, until it's decided if we are going to add the 'bring-back' pattern to
         // all those pages or no (see MDL-30574), we are going to show the unique
         // element statically
         // TODO: Revisit this once MDL-30574 has been decided and implemented, although
         // perhaps it's not bad to always show this statically when only one pattern is
         // available.
         if (!$editingatfrontpage) {
             // Try to beautify it
             $strvalue = $value;
             $strkey = 'page-' . str_replace('*', 'x', $strvalue);
             if (get_string_manager()->string_exists($strkey, 'pagetype')) {
                 $strvalue = get_string($strkey, 'pagetype');
             }
             // Show as static (hidden has been set already)
             $mform->addElement('static', 'bui_staticpagetypepattern', get_string('restrictpagetypes', 'block'), $strvalue);
         }
     }
     if ($this->page->subpage) {
         if ($parentcontext->contextlevel == CONTEXT_USER) {
             $mform->addElement('hidden', 'bui_subpagepattern', '%@NULL@%');
             $mform->setType('bui_subpagepattern', PARAM_RAW);
         } else {
             $subpageoptions = array('%@NULL@%' => get_string('anypagematchingtheabove', 'block'), $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage));
             $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions);
         }
     }
     $defaultregionoptions = $regionoptions;
     $defaultregion = $this->block->instance->defaultregion;
     if (!array_key_exists($defaultregion, $defaultregionoptions)) {
         $defaultregionoptions[$defaultregion] = $defaultregion;
     }
     $mform->addElement('select', 'bui_defaultregion', get_string('defaultregion', 'block'), $defaultregionoptions);
     $mform->addHelpButton('bui_defaultregion', 'defaultregion', 'block');
     $mform->addElement('select', 'bui_defaultweight', get_string('defaultweight', 'block'), $weightoptions);
     $mform->addHelpButton('bui_defaultweight', 'defaultweight', 'block');
     // Where this block is positioned on this page.
     $mform->addElement('header', 'onthispage', get_string('onthispage', 'block'));
     $mform->addElement('selectyesno', 'bui_visible', get_string('visible', 'block'));
     $blockregion = $this->block->instance->region;
     if (!array_key_exists($blockregion, $regionoptions)) {
         $regionoptions[$blockregion] = $blockregion;
     }
     $mform->addElement('select', 'bui_region', get_string('region', 'block'), $regionoptions);
     $mform->addElement('select', 'bui_weight', get_string('weight', 'block'), $weightoptions);
     $pagefields = array('bui_visible', 'bui_region', 'bui_weight');
     if (!$this->block->user_can_edit()) {
         $mform->hardFreezeAllVisibleExcept($pagefields);
     }
     if (!$this->page->user_can_edit_blocks()) {
         $mform->hardFreeze($pagefields);
     }
     $this->add_action_buttons();
 }
예제 #28
0
        	function get_required_javascript() {
		global $CFG;
		parent::get_required_javascript();
		user_preference_allow_ajax_update('docked_block_instance_'.$this->instance->id, PARAM_INT);
		$limit = 20;
		if (!empty($CFG->navcourselimit)) {
			$limit = $CFG->navcourselimit;
		}
		$expansionlimit = 0;
		if (!empty($this->config->expansionlimit)) {
			$expansionlimit = $this->config->expansionlimit;
		}
		$arguments = array(
				'id'             => $this->instance->id,
				'instance'       => $this->instance->id,
				'candock'        => $this->instance_can_be_docked(),
				'courselimit'    => $limit,
				'expansionlimit' => $expansionlimit
		);
		$this->page->requires->string_for_js('viewallcourses', 'moodle');
		$this->page->requires->yui_module(array('core_dock', 'moodle-block_navigation-navigation'), 'M.block_navigation.init_add_tree', array($arguments));
	}
 public function html_attributes()
 {
     $attributes = parent::html_attributes();
     // Get default values
     $attributes['class'] .= ' block_' . $this->name();
     // Append our class to class attribute
     return $attributes;
 }
예제 #30
0
 /**
  * Replace the instance's configuration data with those currently in $this->config;
  */
 function instance_config_commit($nolongerused = false)
 {
     // Unset config variables that are no longer used.
     unset($this->config->globalglossary);
     unset($this->config->courseid);
     parent::instance_config_commit($nolongerused);
 }