コード例 #1
0
 public static function refreshUrl($mdl_mediaelementjs)
 {
     $url = $mdl_mediaelementjs->externalurl;
     if (strpos($url, 'institution/getUserStorageFile?')) {
         $file_param = self::FILE_GET_PARAMETER . '=';
         $str_start = strpos($url, $file_param);
         if ($str_start) {
             $short_name = GcrEschoolTable::parseShortNameFromUrl($url);
             $app = GcrInstitutionTable::getApp($short_name);
             $institution = $app->getInstitution();
             $short_name = $institution->getShortName();
             $str_start += strlen($file_param);
             $str_end = strpos($url, '&', $str_start);
             $filename = substr($url, $str_start, $str_end - $str_start);
             $filename = urldecode($filename);
             $str_start = strpos($url, '&app=');
             if ($str_start) {
                 $str_start += strlen('&app=');
                 $str_end = strpos($url, '&', $str_start);
                 $short_name_user_app = substr($url, $str_start, $str_end - $str_start);
                 $user_app = GcrInstitutionTable::getApp($short_name_user_app);
                 if ($user_app) {
                     $short_name = $short_name_user_app;
                 }
             }
             $params = array(self::FILE_GET_PARAMETER => $filename, 'course_id' => $mdl_mediaelementjs->course, 'app' => $short_name);
             $mdl_mediaelementjs->externalurl = GcrStorageAccessS3::generateStaticUrl($filename, $params, $app);
         }
     }
     return $mdl_mediaelementjs;
 }