Skip to content

Commit

Permalink
Amend mybooks problem getting settings
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Jul 17, 2015
1 parent 49a18ff commit 4c9f601
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
22 changes: 19 additions & 3 deletions moodle/blocks/my_books/block_my_books.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function instance_allow_multiple() {
}

function has_config() {
return false;
return true;
}

/*function applicable_formats() {
Expand All @@ -37,7 +37,7 @@ function get_content() {
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$mybooksconfig = get_config('mybooks');
$mybooksconfig = self::get_mybooksconfig();

require_once($CFG->dirroot.'/local/rcommon/locallib.php');
require_once($CFG->dirroot.'/mod/rcontent/lib.php');
Expand Down Expand Up @@ -70,6 +70,22 @@ function get_content() {
return $this->content;
}

private static function get_mybooksconfig() {
$mybooksconfig = get_config('mybooks');
if (!isset($mybooksconfig->viewer_opening)) {
$mybooksconfig->viewer_opening = 1;
$mybooksconfig->width = 800;
$mybooksconfig->height = 600;
$mybooksconfig->activity_opening = 0;
$mybooksconfig->scrollbars = 1;
$mybooksconfig->menubar = 0;
$mybooksconfig->toolbar = 0;
$mybooksconfig->status = 1;
$mybooksconfig->addkey = 1;
}
return $mybooksconfig;
}

private function get_item($isbn, $mybooksconfig) {
global $DB, $CFG;
// Deleted book
Expand Down Expand Up @@ -105,7 +121,7 @@ private function get_item($isbn, $mybooksconfig) {
$add->frame = 0;
$add->coursemodule = 0;
$add->cmidnumber = 0;
$add->popup = $mybooksconfig->activity_opening;
$add->popup = $mybooksconfig->activity_opening;
$add->scrollbars = $mybooksconfig->scrollbars;
$add->menubar = $mybooksconfig->menubar;
$add->toolbar = $mybooksconfig->toolbar;
Expand Down
11 changes: 0 additions & 11 deletions moodle/blocks/my_books/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@
//delete all rscorm my_books auto add entries
//TODO abertranb confirmar que sigui necessari
if (false) {
if ($module = $DB->get_record('modules', array('name' => 'rscorm'), 'id')){
if ($cs = $DB->get_record('course_sections', array('course' => 1, 'section' => 2), 'id')){
if ($cms = $DB->get_records_select('course_modules', 'course = 1 AND module = '.$module->id.' AND section = '.$cs->id, array(), 'id, instance')){
include_once($CFG->dirroot.'/mod/rscorm/lib.php');
foreach ($cms as $cm){
rscorm_delete_instance($cm->instance);
$DB->delete_records('course_modules', array('id' => $cm->id));
}
}
}
}
//delete all rcontent my_books out add entries
if ($module = $DB->get_record('modules', array('name' => 'rcontent'), 'id')){
if ($cs = $DB->get_record('course_sections', array('course' => 1, 'section' => 2), 'id')){
Expand Down

0 comments on commit 4c9f601

Please sign in to comment.