Example #1
3
 function set_data($defaults)
 {
     if (empty($entry->id)) {
         $entry = new stdClass();
         $entry->id = null;
     }
     $draftitemid = file_get_submitted_draft_itemid('config_attachments');
     file_prepare_draft_area($draftitemid, $this->block->context->id, 'block_slider', 'content', 0, array('subdirs' => true));
     $entry->attachments = $draftitemid;
     parent::set_data($defaults);
     if ($data = parent::get_data()) {
         file_save_draft_area_files($data->config_attachments, $this->block->context->id, 'block_slider', 'content', 0, array('subdirs' => true));
     }
 }
 function set_data($defaults)
 {
     if (!empty($this->block->config) && is_object($this->block->config)) {
         $whatshot = $this->block->config->whatshot;
         $draftid_editor = file_get_submitted_draft_itemid('config_whatshot');
         if (empty($whatshot)) {
             $currenttext = '';
         } else {
             $currenttext = $whatshot;
         }
         $defaults->config_whatshot['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_dashboard', 'content', 0, array('subdirs' => true), $currenttext);
         $defaults->config_whatshot['itemid'] = $draftid_editor;
         $defaults->config_whatshot['format'] = $this->block->config->format;
     } else {
         $whatshot = '';
     }
     if (!$this->block->user_can_edit() && !empty($this->block->config->title)) {
         // If a title has been set but the user cannot edit it format it nicely
         $title = $this->block->config->title;
         $defaults->config_title = format_string($title, true, $this->page->context);
         // Remove the title from the config so that parent::set_data doesn't set it.
         unset($this->block->config->title);
     }
     // have to delete text here, otherwise parent::set_data will empty content
     // of editor
     unset($this->block->config->whatshot);
     parent::set_data($defaults);
     // restore $text
     $this->block->config->whatshot = $whatshot;
     if (isset($title)) {
         // Reset the preserved title
         $this->block->config->title = $title;
     }
 }
 function set_data($defaults)
 {
     $block_config = new Object();
     $block_config->notify_by_email = file_get_submitted_draft_itemid('notify_by_email');
     $block_config->notify_by_sms = file_get_submitted_draft_itemid('notify_by_sms');
     $block_config->notify_by_rss = file_get_submitted_draft_itemid('notify_by_rss');
     $block_config->notification_frequency = file_get_submitted_draft_itemid('notification_frequency');
     $block_config->email_notification_preset = file_get_submitted_draft_itemid('email_notification_preset');
     $block_config->sms_notification_preset = file_get_submitted_draft_itemid('sms_notification_preset');
     unset($this->block->config->text);
     parent::set_data($defaults);
     $this->block->config = $block_config;
 }
 /**
  * constructor
  *
  * @param object $actionurl
  * @param object $block
  * @param object $page
  * @return void, but will update $this
  */
 function __construct($actionurl, $block, $page)
 {
     if (isset($block->config->showactivitygrades)) {
         $value = $block->config->showactivitygrades;
     } else {
         $value = 'all';
         // default value
     }
     if ($value == 'all') {
         $block->config->showactivitygrades = 'all';
         $block->config->showactivitygradestypes = '';
     } else {
         $block->config->showactivitygrades = 'specific';
         $block->config->showactivitygradestypes = $value;
     }
     parent::__construct($actionurl, $block, $page);
 }
Example #5
0
    function set_data($defaults) {

        if (!$this->block->user_can_edit() && !empty($this->block->config->title)) {
            // If a title has been set but the user cannot edit it format it nicely
            $title = $this->block->config->title;
            $defaults->config_title = format_string($title, true, $this->page->context);
            // Remove the title from the config so that parent::set_data doesn't set it.
            unset($this->block->config->title);
        }
        parent::set_data($defaults);
        // restore $text
        if (!isset($this->block->config)) {
            $this->block->config = new stdClass();
        }
        if (isset($title)) {
            // Reset the preserved title
            $this->block->config->title = $title;
        }
    }
Example #6
0
 function set_data($defaults)
 {
     if (!empty($this->block->config) && is_object($this->block->config)) {
         $text = $this->block->config->text;
         $draftid_editor = file_get_submitted_draft_itemid('config_text');
         if (empty($text)) {
             $currenttext = '';
         } else {
             $currenttext = $text;
         }
         $defaults->config_text['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_html', 'content', 0, array('subdirs' => true), $currenttext);
         $defaults->config_text['itemid'] = $draftid_editor;
         $defaults->config_text['format'] = $this->block->config->format;
     } else {
         $text = '';
     }
     // have to delete text here, otherwise parent::set_data will empty content
     // of editor
     unset($this->block->config->text);
     parent::set_data($defaults);
     // restore $text
     $this->block->config->text = $text;
 }
 function set_data($defaults)
 {
     if (!empty($this->block->config) && is_object($this->block->config)) {
         $defaults->config_courses_shown = (int) $this->block->config->courses_shown;
         $defaults->config_show_price = !!$this->block->config->show_price;
         $defaults->config_show_image = !!$this->block->config->show_image;
         $defaults->config_show_description = !!$this->block->config->show_description;
         $defaults->config_course_selection = (int) $this->block->config->course_selection;
         if ($defaults->config_course_selection === 2) {
             $defaults->config_manual_course_1 = (int) $this->block->config->manual_course_1;
             if (1 < $defaults->config_courses_shown) {
                 $defaults->config_manual_course_2 = (int) $this->block->config->manual_course_2;
             }
             if (2 < $defaults->config_courses_shown) {
                 $defaults->config_manual_course_3 = (int) $this->block->config->manual_course_3;
             }
             if (3 < $defaults->config_courses_shown) {
                 $defaults->config_manual_course_4 = (int) $this->block->config->manual_course_4;
             }
         }
     }
     parent::set_data($defaults);
 }
 function set_data($defaults)
 {
     global $COURSE;
     if (!$this->block->user_can_edit()) {
         if (!empty($this->block->config->title)) {
             // If a title has been set but the user cannot edit it format it nicely
             $title = $this->block->config->title;
             $defaults->config_title = format_string($title, true, $this->page->context);
             // Remove the title from the config so that parent::set_data doesn't set it.
             unset($this->block->config->title);
         }
         if (!empty($this->block->config->imagespot)) {
             $fileoptions = array('subdirs' => false, 'maxfiles' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'web_image', 'return_types' => FILE_INTERNAL);
             $draftitemid = '';
             file_prepare_draft_area($draftitemid, $this->block->context->id, 'block_informationspot', 'image', 0, $fileoptions);
             $defaults->config_imagespot = $draftitemid;
             unset($this->block->config->imagespot);
         }
         if (!empty($this->block->config->text)) {
             $text = $this->block->config->text;
             $defaults->config_text = format_text($text, true, $this->page->context);
             unset($this->block->config->text);
         }
         if (!empty($this->block->config->buttontext)) {
             $buttontext = $this->block->config->buttontext;
             $defaults->config_buttontext = format_string($buttontext, true, $this->page->context);
             unset($this->block->config->buttontext);
         }
         if (!empty($this->block->config->buttonlink)) {
             $buttonlink = $this->block->config->buttonlink;
             $defaults->config_buttonlink = $buttonlink;
             unset($this->block->config->buttonlink);
         }
     }
     parent::set_data($defaults);
     if (!isset($this->block->config)) {
         $this->block->config = new stdClass();
     }
     if (isset($title)) {
         $this->block->config->title = $title;
     }
     if (isset($draftitemid)) {
         $this->block->config->imagespot = $draftitemid;
     }
     if (isset($title)) {
         $this->block->config->title = $title;
     }
     if (isset($text)) {
         $this->block->config->text = $text;
     }
     if (isset($buttontext)) {
         $this->block->config->buttontext = $buttontext;
     }
     if (isset($buttonlink)) {
         $this->block->config->buttonlink = $title;
     }
 }
 public function validation($data, $files)
 {
     $glossaryid = $data['config_glossary'];
     if ($glossaryid == 0) {
         return;
     }
     $errors = parent::validation($data, $files);
     $glossary = explode(",", $glossaryid);
     $glossaryid = $glossary[0];
     $categoryid = $glossary[1];
     $glossarynumentries = $this->numentriesincategory[$glossaryid][$categoryid];
     $questiontype = $data['config_questiontype'];
     $maxentries = $data['config_limitnum'];
     if ($questiontype < 4 && ($maxentries < 4 || $glossarynumentries < 4)) {
         if ($maxentries < 4) {
             $errormsg = 'notenoughentriesselected';
             $numentries = $maxentries;
         }
         if ($glossarynumentries < 4) {
             $errormsg = 'notenoughentriesavailable';
             $numentries = $glossarynumentries;
         }
         $errors['config_limitnum'] = get_string($errormsg, 'block_advanced_grading_export', $numentries);
     }
     return $errors;
 }
 function set_data($defaults)
 {
     if (!empty($this->block->config)) {
         if (!empty($this->block->config->sqlparams)) {
             foreach ($this->block->config->sqlparams as $paramid => $paramdef) {
                 print_object($paramdef);
                 $varkey = "config_sqlparams[{$paramid}][sqlparamvar]";
                 $defaults->{$varkey} = $paramdef['sqlparamvar'];
             }
         }
     }
     parent::set_data($defaults);
 }
 function set_data($defaults)
 {
     global $COURSE;
     if ($this->block->user_can_edit()) {
         if (!empty($this->block->config->slides)) {
             $slidenumber = $this->block->config->slides;
             $fileoptions = array('subdirs' => false, 'maxfiles' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'web_image', 'return_types' => FILE_INTERNAL);
             $slides = array();
             for ($i = 0; $i < $slidenumber; $i++) {
                 $slides[$i] = new stdClass();
                 if (!empty($this->block->config->enabled[$i])) {
                     $slides[$i]->enabled = $this->block->config->enabled[$i];
                 }
                 if (!empty($this->block->config->imageslide[$i])) {
                     $draftitemid = '';
                     file_prepare_draft_area($draftitemid, $this->block->context->id, 'block_slideshow', 'slides', $i, $fileoptions);
                     $this->block->config->imageslide[$i] = $draftitemid;
                     $slides[$i]->imageslide = $draftitemid;
                 }
                 if (!empty($this->block->config->imageposition[$i])) {
                     $slides[$i]->imageposition = $this->block->config->imageposition[$i];
                 }
                 if (!empty($this->block->config->title[$i])) {
                     $slides[$i]->title = $this->block->config->title[$i];
                 }
                 if (!empty($this->block->config->caption[$i])) {
                     $slides[$i]->caption = $this->block->config->caption[$i];
                 }
                 if (!empty($this->block->config->captionposition[$i])) {
                     $slides[$i]->captionposition = $this->block->config->captionposition[$i];
                 }
                 if (!empty($this->block->config->link[$i])) {
                     $slides[$i]->link = $this->block->config->link[$i];
                 }
             }
         }
         if (!empty($this->block->config->showslides)) {
             $showslides = $this->block->config->showslides;
         }
         if (!empty($this->block->config->interval)) {
             $showslides = $this->block->config->interval;
         }
         if (!empty($this->block->config->firstslide)) {
             $firstslide = $this->block->config->firstslide;
         }
         if (!empty($this->block->config->transition)) {
             $transition = $this->block->config->transition;
         }
         if (!empty($this->block->config->transitiontime)) {
             $transition = $this->block->config->transitiontime;
         }
         if (!empty($this->block->config->pagerposition)) {
             $transition = $this->block->config->pagerposition;
         }
     }
     parent::set_data($defaults);
     /*
             if (!isset($this->block->config)) {
                 $this->block->config = new stdClass();
             }
             if (isset($slidenumber)) {
                 $this->block->config->slides = $slidenumber;
                 if (isset($slides)) {
                     for ($i=0; $i<$slidenumber; $i++) {
                          if (isset($slides[$i]->enabled)) {
                              $this->block->config->enabled[$i] = $slides[$i]->enabled;
                          }
                          if (isset($slides[$i]->imageslide)) {
                              $this->block->config->imageslide[$i] = $slides[$i]->imageslide;
                          }
                          if (isset($slides[$i]->imageposition)) {
                              $this->block->config->imageposition[$i] = $slides[$i]->imageposition;
                          }
                          if (isset($slides[$i]->title)) {
                              $this->block->config->title[$i] = $slides[$i]->title;
                          }
                          if (isset($slides[$i]->caption)) {
                              $this->block->config->caption[$i] = $slides[$i]->caption;
                          }
                          if (isset($slides[$i]->captionposition)) {
                              $this->block->config->captionposition[$i] = $slides[$i]->captionposition;
                          }
                          if (isset($slides[$i]->link)) {
                              $this->block->config->link[$i] = $slides[$i]->link;
                          }
                     }
                 }
             }
             if (isset($showslides)) {
                 $this->block->config->showslides = $showslides;
             }
             if (isset($firstslide)) {
                 $this->block->config->firstslide = $firstslide;
             }
             if (isset($transition)) {
                 $this->block->config->transition = $transition;
             }
     */
 }
 function set_data($defaults)
 {
     if (!empty($this->block->config) && is_object($this->block->config)) {
         $draftPhotoId1 = file_get_submitted_draft_itemid('config_testimonial_photo_1');
         $draftPhotoId2 = file_get_submitted_draft_itemid('config_testimonial_photo_2');
         $draftPhotoId3 = file_get_submitted_draft_itemid('config_testimonial_photo_3');
         $draftPhotoId4 = file_get_submitted_draft_itemid('config_testimonial_photo_4');
         $draftPhotoId5 = file_get_submitted_draft_itemid('config_testimonial_photo_5');
         file_prepare_draft_area($draftPhotoId1, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_1, array('subdirs' => true));
         file_prepare_draft_area($draftPhotoId2, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_2, array('subdirs' => true));
         file_prepare_draft_area($draftPhotoId3, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_3, array('subdirs' => true));
         file_prepare_draft_area($draftPhotoId4, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_4, array('subdirs' => true));
         file_prepare_draft_area($draftPhotoId5, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_5, array('subdirs' => true));
     }
     parent::set_data($defaults);
     if ($data = parent::get_data()) {
         if (isset($data->config_testimonial_photo_1) && isset($this->block->config->testimonial_photo_1)) {
             file_save_draft_area_files($data->config_testimonial_photo_1, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_1, array('subdirs' => true));
         }
         if (isset($data->config_testimonial_photo_2) && isset($this->block->config->testimonial_photo_2)) {
             file_save_draft_area_files($data->config_testimonial_photo_2, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_2, array('subdirs' => true));
         }
         if (isset($data->config_testimonial_photo_3) && isset($this->block->config->testimonial_photo_3)) {
             file_save_draft_area_files($data->config_testimonial_photo_3, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_3, array('subdirs' => true));
         }
         if (isset($data->config_testimonial_photo_4) && isset($this->block->config->testimonial_photo_4)) {
             file_save_draft_area_files($data->config_testimonial_photo_4, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_4, array('subdirs' => true));
         }
         if (isset($data->config_testimonial_photo_5) && isset($this->block->config->testimonial_photo_5)) {
             file_save_draft_area_files($data->config_testimonial_photo_5, $this->block->context->id, 'block_testimonials', 'photo', (int) $this->block->config->testimonial_photo_5, array('subdirs' => true));
         }
     }
 }
 function set_data($defaults)
 {
     $block_config = new Object();
     $block_config->notify_by_email = file_get_submitted_draft_itemid('notify_by_email');
     $block_config->notify_by_sms = file_get_submitted_draft_itemid('notify_by_sms');
     $block_config->notify_by_rss = file_get_submitted_draft_itemid('notify_by_rss');
     $block_config->rss_shortname_url_param = file_get_submitted_draft_itemid('rss_shortname_url_param');
     $block_config->email_notification_preset = file_get_submitted_draft_itemid('email_notification_preset');
     $block_config->sms_notification_preset = file_get_submitted_draft_itemid('sms_notification_preset');
     foreach (\block_notifications\SupportedEvents::getShortNames() as $block_instance_setting => $platform_event_name) {
         $block_config->{$block_instance_setting} = file_get_submitted_draft_itemid($block_instance_setting);
     }
     unset($this->block->config->text);
     parent::set_data($defaults);
     $this->block->config = $block_config;
 }
 function set_data($defaults)
 {
     parent::set_data($defaults);
 }
 function set_data($defaults, &$files = null)
 {
     global $COURSE;
     $groups = groups_get_all_groups($COURSE->id);
     if (!empty($this->block->config) && is_object($this->block->config)) {
         // draft file handling for all
         $text_all = $this->block->config->text_all;
         $draftid_editor = file_get_submitted_draft_itemid('config_text_all');
         if (empty($text_all)) {
             $currenttext = '';
         } else {
             $currenttext = $text_all;
         }
         $defaults->config_text_all['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_groupspecifichtml', 'content', 0, array('subdirs' => true), $currenttext);
         $defaults->config_text_all['itemid'] = $draftid_editor;
         $defaults->config_text_all['format'] = @$this->block->config->format;
         // draft file handling for any
         $text_0 = $this->block->config->text_0;
         $draftid_editor = file_get_submitted_draft_itemid('config_text_0');
         if (empty($text_0)) {
             $currenttext = '';
         } else {
             $currenttext = $text_0;
         }
         $defaults->config_text_0['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_groupspecifichtml', 'content', 0, array('subdirs' => true), $currenttext);
         $defaults->config_text_0['itemid'] = $draftid_editor;
         $defaults->config_text_0['format'] = @$this->block->config->format;
         if (!empty($groups)) {
             foreach ($groups as $g) {
                 // draft file handling for each
                 $textvar = 'text_' . $g->id;
                 $configtextvar = 'config_text_' . $g->id;
                 ${$textvar} = $this->block->config->{$textvar};
                 $draftid_editor = file_get_submitted_draft_itemid('config_text_' . $g->id);
                 if (empty(${$textvar})) {
                     $currenttext = '';
                 } else {
                     $currenttext = ${$textvar};
                 }
                 $defaults->{$configtextvar}['text'] = file_prepare_draft_area($draftid_editor, $this->block->context->id, 'block_groupspecifichtml', 'content', 0, array('subdirs' => true), $currenttext);
                 $defaults->{$configtextvar}['itemid'] = $draftid_editor;
                 $defaults->{$configtextvar}['format'] = @$this->block->config->format;
             }
         }
     } else {
         $text_all = '';
         $text_0 = '';
         if (!empty($groups)) {
             foreach ($groups as $g) {
                 $textvar = 'text_' . $g->id;
                 ${$textvar} = '';
             }
         }
     }
     if (!$this->block->user_can_edit() && !empty($this->block->config->title)) {
         // If a title has been set but the user cannot edit it format it nicely
         $title = $this->block->config->title;
         $defaults->config_title = format_string($title, true, $this->page->context);
         // Remove the title from the config so that parent::set_data doesn't set it.
         unset($this->block->config->title);
     }
     // have to delete text here, otherwise parent::set_data will empty content
     // of editor
     unset($this->block->config->text_all);
     unset($this->block->config->text_0);
     if (!empty($groups)) {
         foreach ($groups as $g) {
             $textvar = 'text_' . $g->id;
             unset($this->block->config->{$textvar});
         }
     }
     parent::set_data($defaults);
     // restore $text
     $this->block->config->text_all = $text_all;
     $this->block->config->text_0 = $text_0;
     if (!empty($groups)) {
         foreach ($groups as $g) {
             $textvar = 'text_' . $g->id;
             $this->block->config->{$textvar} = ${$textvar};
         }
     }
     if (isset($title)) {
         // Reset the preserved title
         $this->block->config->title = $title;
     }
 }