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;
 }
 public function checkForJumpRequest()
 {
     if (strpos($_SERVER['REQUEST_URI'], '/auth/xmlrpc/jump.php')) {
         if (!isset($_GET['wr']) && isset($_GET['hostwwwroot'])) {
             // Ron Stewart: 06/14/2012
             // This is a bug fix for moodle generated urls which only provide
             // a hostwwwroot parameter to feed to the remote mnet host's jump
             // page. IMO, this should be corrected on the mahara side, since
             // connected network nodes cannot be expected to provide an
             // instance id (ins param) for their host record on the mahara side.
             // For the time being, correcting the params here is the most lightweight
             // way of dealing with the issue (no overwrites required).
             $remotewwwroot = $_GET['hostwwwroot'];
             $short_name = GcrEschoolTable::parseShortNameFromUrl($remotewwwroot);
             $eschool = GcrEschoolTable::getEschool($short_name);
             $mhr_auth_instance = $this->getAuthInstance($eschool);
             if ($mhr_auth_instance) {
                 $_GET['wr'] = $remotewwwroot;
                 $_GET['ins'] = $mhr_auth_instance->id;
             }
         } else {
             $remotewwwroot = param_variable('wr');
             $short_name = GcrEschoolTable::parseShortNameFromUrl($remotewwwroot);
         }
         if (isset($_COOKIE['gc_eschools'])) {
             if (strpos($_COOKIE['gc_eschools'], ';' . $short_name . ';') === false) {
                 setcookie('gc_eschools', $_COOKIE['gc_eschools'] . $short_name . ';', false, '/');
             }
         } else {
             setcookie('gc_eschools', ';' . $short_name . ';', false, '/');
         }
     }
 }
 public function getHost($mdl_mnet_host)
 {
     if ($short_name = GcrEschoolTable::parseShortNameFromUrl($mdl_mnet_host->wwwroot)) {
         if ($institution = Doctrine::getTable('GcrInstitution')->findOneByShortName($short_name)) {
             return $institution;
         }
     }
     return false;
 }
 public function getHost($mhr_host)
 {
     if ($short_name = GcrEschoolTable::parseShortNameFromUrl($mhr_host->wwwroot)) {
         if ($eschool = Doctrine::getTable('GcrEschool')->findOneByShortName($short_name)) {
             return $eschool;
         }
     }
     return false;
 }