/**
  * Removes the metadata files for all known studio layouts.
  *
  * @return html output record of the files deleted
  */
 function removeCustomLayouts()
 {
     $module = StudioModuleFactory::getStudioModule($this->module);
     $sources = $module->getViewMetadataSources();
     $out = "";
     // list of existing platforms including BWC
     $platforms = MetaDataManager::getPlatformList();
     array_unshift($platforms, '');
     // Flag to tell the autoloader whether to save itself or not when done
     $saveMap = false;
     foreach ($sources as $view) {
         foreach ($platforms as $platform) {
             $file = MetaDataFiles::getDeployedFileName($view['type'], $this->module, MB_CUSTOMMETADATALOCATION, $platform);
             // Ensure we are working on files that the autoloader knows about
             if (SugarAutoLoader::fileExists($file)) {
                 // Since we are in a loop inside of a loop do NOT send the
                 // save flag as true to unlink() but be sure to save the file
                 // map after the process is finished so that all changes to
                 // the map are saved.
                 SugarAutoLoader::unlink($file);
                 $out .= "Removed layout {$view['type']}.php<br/>";
                 // Tell the autoloader to save itself
                 $saveMap = true;
             }
         }
     }
     // now clear the cache
     include_once 'include/TemplateHandler/TemplateHandler.php';
     TemplateHandler::clearCache($this->module);
     // If the file map needs saving, handle that now
     if ($saveMap) {
         SugarAutoLoader::saveMap();
     }
     return $out;
 }
 /**
  * Returns Smarty template for authenticating the application with the data
  * obtained from external identity provider
  *
  * @return string
  */
 protected function getAuthenticateTemplate()
 {
     if (isset($this->platform)) {
         $platforms = MetaDataManager::getPlatformList();
         if (in_array($this->platform, $platforms, true)) {
             $platformTemplate = SugarAutoLoader::existingCustomOne('modules/Users/tpls/Authenticate' . ucfirst($this->platform) . '.tpl');
             if ($platformTemplate) {
                 return $platformTemplate;
             }
         }
     }
     return SugarAutoLoader::existingCustomOne('modules/Users/tpls/AuthenticateParent.tpl');
 }