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)) {
         $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));
         }
     }
 }