Пример #1
0
 public static function instance_config_form($instance)
 {
     $user_storage = new GcrUserStorageAccessS3();
     $file_list = $user_storage->getFileList(false);
     $options = array();
     foreach ($file_list as $filename) {
         $options[$user_storage->getStaticUrl($filename)] = $filename;
     }
     $configdata = $instance->get('configdata');
     return array('videoid' => array('title' => get_string('videourl', 'blocktype.cloudstoragevideo'), 'description' => get_string('videourldescription2', 'blocktype.cloudstoragevideo'), 'type' => 'select', 'multiple' => false, 'options' => $options, 'collapseifoneoption' => false, 'type' => 'select', 'width' => '90%', 'defaultvalue' => isset($configdata['videoid']) ? $configdata['videoid'] : null, 'rules' => array('required' => true)), 'width' => array('type' => 'text', 'title' => get_string('width', 'blocktype.cloudstoragevideo'), 'size' => 3, 'rules' => array('required' => true, 'integer' => true, 'minvalue' => 100, 'maxvalue' => 800), 'defaultvalue' => !empty($configdata['width']) ? $configdata['width'] : self::$default_width), 'height' => array('type' => 'text', 'title' => get_string('height', 'blocktype.cloudstoragevideo'), 'size' => 3, 'rules' => array('required' => true, 'integer' => true, 'minvalue' => 100, 'maxvalue' => 800), 'defaultvalue' => !empty($configdata['height']) ? $configdata['height'] : self::$default_height));
 }
 public function executeDeleteUserStorageFile(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $CFG->current_app->requireLogin();
     $form = $request->getPostParameters();
     if ($file = $request->getParameter('file')) {
         $user_storage = new GcrUserStorageAccessS3();
         $user_storage->deleteObject($file);
     }
     $url = $CFG->current_app->getUrl() . '/institution/viewUserStorage';
     $folder = $request->getParameter('key');
     if (isset($folder)) {
         $url .= '?folder=' . $folder;
     }
     $this->redirect($url);
 }
Пример #3
0
 /**
  * Download S3 files to moodle
  *
  * @param string $filepath
  * @param string $file The file path in moodle
  * @return array The local stored path
  */
 public function get_file($filepath, $file = '')
 {
     list($bucket, $uri) = $this->explode_path($filepath);
     $path = $this->prepare_file($file);
     // OVERWRITE 5: insert
     global $CFG;
     $user_storage = new GcrUserStorageAccessS3();
     $bucket = $user_storage->getBucket();
     if (!$user_storage->authorizeAccess($filepath)) {
         $CFG->current_app->gcError('User does not have permission to access bucket ' . $bucket . ', file: ' . $file, 'gcpageaccessdenied');
     }
     // END OVERWRITE 5
     try {
         $this->s->getObject($bucket, $uri, $path);
     } catch (S3Exception $e) {
         throw new moodle_exception('errorwhilecommunicatingwith', 'repository', '', $this->get_name());
     }
     return array('path' => $path);
 }