Skip to content

Commit

Permalink
Merge branch 'w13_MDL-32095_m23_strict2' of git://github.com/skodak/m…
Browse files Browse the repository at this point in the history
…oodle
  • Loading branch information
stronk7 committed Mar 28, 2012
2 parents e63f95d + 17854cb commit 3f0cb42
Show file tree
Hide file tree
Showing 36 changed files with 117 additions and 78 deletions.
1 change: 1 addition & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
}

if (empty($confirmupgrade)) {
$a = new stdClass();
$a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)";
$strdatabasechecking = get_string('databasechecking', '', $a);
Expand Down
2 changes: 1 addition & 1 deletion backup/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display();
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion backup/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display();
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
echo $OUTPUT->footer();
2 changes: 1 addition & 1 deletion backup/moodle2/backup_root_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function define_settings() {
require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
// Define filename setting
$filename = new backup_filename_setting('filename', base_setting::IS_FILENAME, 'backup.mbz');
$filename->set_ui(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50));
$filename->set_ui_filename(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50));
$this->add_setting($filename);

//Sample custom settings
Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/backup_settingslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function __construct($name, $vtype, $value = null, $visibility = self::VI
parent::__construct($name, $vtype, $value, $visibility, $status);
}

public function set_ui($label, $value, array $options = null) {
parent::make_ui(self::UI_HTML_TEXTFIELD, $label, null, $options);
public function set_ui_filename($label, $value, array $options = null) {
$this->make_ui(self::UI_HTML_TEXTFIELD, $label, null, $options);
$this->set_value($value);
}
}
Expand Down
6 changes: 5 additions & 1 deletion backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,11 @@ public function process_block($data) {
// If there is already one block of that type in the parent context
// and the block is not multiple, stop processing
// Use blockslib loader / method executor
if (!block_method_result($data->blockname, 'instance_allow_multiple')) {
if (!$bi = block_instance($data->blockname)) {
return false;
}

if (!$bi->instance_allow_multiple()) {
if ($DB->record_exists_sql("SELECT bi.id
FROM {block_instances} bi
JOIN {block} b ON b.name = bi.blockname
Expand Down
5 changes: 4 additions & 1 deletion backup/util/settings/backup_setting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public function make_ui($type, $label, array $attributes = null, array $options
}
}

public function add_dependency(backup_setting $dependentsetting, $type=setting_dependency::DISABLED_VALUE, $options=array()) {
public function add_dependency(base_setting $dependentsetting, $type=setting_dependency::DISABLED_VALUE, $options=array()) {
if (!($dependentsetting instanceof backup_setting)) {
throw new backup_setting_exception('invalid_backup_setting_parameter');
}
// Check the dependency level is >= current level
if ($dependentsetting->get_level() < $this->level) {
throw new backup_setting_exception('cannot_add_upper_level_dependency');
Expand Down
21 changes: 12 additions & 9 deletions backup/util/ui/backup_ui_stage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ protected function initialise_stage_form() {
/**
* should NEVER be called... throws an exception
*/
public function display() {
public function display(core_backup_renderer $renderer) {
throw new backup_ui_exception('backup_ui_must_execute_first');
}
}
Expand Down Expand Up @@ -444,13 +444,13 @@ public function __construct(backup_ui $ui, array $params=null, array $results=nu
/**
* Displays the completed backup stage.
*
* Currently this just envolves redirecting to the file browser with an
* Currently this just involves redirecting to the file browser with an
* appropriate message.
*
* @global core_renderer $OUTPUT
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
global $OUTPUT;
public function display(core_backup_renderer $renderer) {

// Get the resulting stored_file record
$type = $this->get_ui()->get_controller()->get_type();
Expand All @@ -468,9 +468,12 @@ public function display() {
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
}

echo $OUTPUT->box_start();
echo $OUTPUT->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
echo $OUTPUT->continue_button($restorerul);
echo $OUTPUT->box_end();
$output = '';
$output .= $renderer->box_start();
$output .= $renderer->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
$output .= $renderer->continue_button($restorerul);
$output .= $renderer->box_end();

return $output;
}
}
8 changes: 4 additions & 4 deletions backup/util/ui/base_ui.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ public function save_controller() {
/**
* Displays the UI for the backup!
*
* @throws base_ui_exception
* @return string HTML code
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
if ($this->progress < self::PROGRESS_SAVED) {
throw new base_ui_exception('backupsavebeforedisplay');
}
return $this->stage->display();
return $this->stage->display($renderer);
}
/**
* Gets all backup tasks from the controller
Expand Down
5 changes: 3 additions & 2 deletions backup/util/ui/base_ui_stage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ final public function get_uniqueid() {
* By default this involves instantiating the form for the stage and the calling
* it to display.
*
* @return string HTML code to display
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {

$form = $this->initialise_stage_form();
// a nasty hack follows to work around the sad fact that moodle quickforms
Expand Down
14 changes: 13 additions & 1 deletion backup/util/ui/import_extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ protected function initialise_stage_form() {
*
* This function is overriden so that we can manipulate the strings on the
* buttons.
*
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
$form = $this->initialise_stage_form();
$form->require_definition_after_data();
if ($e = $form->get_element('submitbutton')) {
Expand All @@ -147,7 +150,16 @@ public function display() {
}
}
}

// a nasty hack follows to work around the sad fact that moodle quickforms
// do not allow to actually return the HTML content, just to echo it
flush();
ob_start();
$form->display();
$output = ob_get_contents();
ob_end_clean();

return $output;
}
}
/**
Expand Down
2 changes: 1 addition & 1 deletion backup/util/ui/restore_ui.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function requires_substage() {
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
if ($this->progress < self::PROGRESS_SAVED) {
throw new base_ui_exception('backupsavebeforedisplay');
}
Expand Down
9 changes: 5 additions & 4 deletions backup/util/ui/restore_ui_stage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final public function is_first_stage() {
abstract class restore_ui_independent_stage {
abstract public function __construct($contextid);
abstract public function process();
abstract public function display($renderer);
abstract public function display(core_backup_renderer $renderer);
abstract public function get_stage();
/**
* Gets an array of progress bar items that can be displayed through the restore renderer.
Expand Down Expand Up @@ -177,7 +177,7 @@ protected function extract_file_to_dir() {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {

$prevstageurl = new moodle_url('/backup/restorefile.php', array('contextid' => $this->contextid));
$nextstageurl = new moodle_url('/backup/restore.php', array(
Expand Down Expand Up @@ -262,7 +262,7 @@ public function process() {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {

$format = backup_general_helper::detect_backup_format($this->filepath);

Expand Down Expand Up @@ -676,7 +676,7 @@ protected function initialise_stage_form() {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
global $PAGE;

$html = '';
Expand Down Expand Up @@ -752,6 +752,7 @@ public function __construct(restore_ui $ui, array $params=null, array $results=n
* appropriate message.
*
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display(core_backup_renderer $renderer) {

Expand Down
4 changes: 2 additions & 2 deletions enrol/category/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* it may fail sometimes, so we always do a full sync in cron too.
*/
class enrol_category_handler {
public function role_assigned($ra) {
public static function role_assigned($ra) {
global $DB;

if (!enrol_is_enabled('category')) {
Expand Down Expand Up @@ -84,7 +84,7 @@ public function role_assigned($ra) {
return true;
}

public function role_unassigned($ra) {
public static function role_unassigned($ra) {
global $DB;

if (!enrol_is_enabled('category')) {
Expand Down
6 changes: 3 additions & 3 deletions enrol/cohort/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class enrol_cohort_handler {
* @param stdClass $ca
* @return bool
*/
public function member_added($ca) {
public static function member_added($ca) {
global $DB;

if (!enrol_is_enabled('cohort')) {
Expand Down Expand Up @@ -79,7 +79,7 @@ public function member_added($ca) {
* @param stdClass $ca
* @return bool
*/
public function member_removed($ca) {
public static function member_removed($ca) {
global $DB;

// does anything want to sync with this cohort?
Expand Down Expand Up @@ -114,7 +114,7 @@ public function member_removed($ca) {
* @param stdClass $cohort
* @return bool
*/
public function deleted($cohort) {
public static function deleted($cohort) {
global $DB;

// does anything want to sync with this cohort?
Expand Down
20 changes: 10 additions & 10 deletions filter/activitynames/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ function filter($text, array $options = array()) {
}

// Initialise/invalidate our trivial cache if dealing with a different course
if (!isset($this->cachedcourseid) || $this->cachedcourseid !== (int)$courseid) {
$this->activitylist = null;
if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int)$courseid) {
self::$activitylist = null;
}
$this->cachedcourseid = (int)$courseid;
self::$cachedcourseid = (int)$courseid;

/// It may be cached

if (is_null($this->activitylist)) {
$this->activitylist = array();
if (is_null(self::$activitylist)) {
self::$activitylist = array();

if ($COURSE->id == $courseid) {
$course = $COURSE;
Expand All @@ -68,7 +68,7 @@ function filter($text, array $options = array()) {

if (!empty($modinfo)) {

$this->activitylist = array(); /// We will store all the activities here
self::$activitylist = array(); /// We will store all the activities here

//Sort modinfo by name length
usort($modinfo, 'filter_activitynames_comparemodulenamesbylength');
Expand All @@ -82,18 +82,18 @@ function filter($text, array $options = array()) {
/// Avoid empty or unlinkable activity names
if (!empty($title)) {
$href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/$activity->mod/view.php?id=$activity->cm\">";
$this->activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
self::$activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
if ($currentname != $entitisedname) { /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545
$this->activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
self::$activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
}
}
}
}
}
}

if ($this->activitylist) {
return $text = filter_phrases ($text, $this->activitylist);
if (self::$activitylist) {
return $text = filter_phrases ($text, self::$activitylist);
} else {
return $text;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/pear/HTML/QuickForm/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ class HTML_QuickForm_Rule

/**
* Validates a value
*
*
* @access public
* @abstract
*/
function validate($value)
function validate($value, $options = null)
{
return true;
}

/**
* Sets the rule name
*
*
* @access public
*/
function setName($ruleName)
Expand Down
8 changes: 4 additions & 4 deletions lib/pear/HTML/QuickForm/Rule/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule
* @access public
* @return boolean true if value is valid
*/
function validate($value, $options)
function validate($value, $options = null)
{
$length = strlen($value);
switch ($this->name) {
Expand All @@ -48,13 +48,13 @@ function validate($value, $options)
function getValidationScript($options = null)
{
switch ($this->name) {
case 'minlength':
case 'minlength':
$test = '{jsVar}.length < '.$options;
break;
case 'maxlength':
case 'maxlength':
$test = '{jsVar}.length > '.$options;
break;
default:
default:
$test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')';
}
return array('', "{jsVar} != '' && {$test}");
Expand Down
Loading

0 comments on commit 3f0cb42

Please sign in to comment.