Limit plain html files to authenticated users

Hi guys,

Is there any way to generate a documentation for a project but display it only to people who are authenticated by applying filters?

The only solution I came up with is to create a project, apply filter rules to an action called actionShowDocumentation(), in this action I read the html documentation files as plain text files. Those files are located under /protected so no one can access them from outside. After I read the plain html in the controller I render the view and echo the read html lines in it.

The problem with that solution is obvious - I loose the links inside the plain html documentation pages.

Any smarter solutions?

Do you mean static html? You can use CViewAction for this. See You could then use the accessControl() filter to restrict access to team members etc.

Hope it helps,


Thanks for the answer,

That works well but the problem is that inside those static pages I have links which lead to other static pages located in the same directory. Furthermore I have javascript and css files related to those static pages.

Do I have to extend CViewAction to replace all the static links with the appropriate urlManager generated links and regarding the js and css do I have to register them as scripts in the controller?

You should be able to add the js (and css) files via Yii::app()->clientScript->registerScriptFile(’/js/myJsFile.js’) to your layout file. You could create a custom layout for your static pages with nothing in there but the links to js and css files so they always get loaded.

The static link thing is a tricky one I guess. I don’t know how your links look like. You may be able to catch them with a custom urlManager rule and always route them to your view action. But I never tried something like that so I am not sure if that is even possible.