conditionally show action link in a view

I’m trying to set up an extended version of CHtml that checks user states before displaying links in a view. To make this work, I need to identify Yii action links as opposed to arbitrary non-action links. I also have to allow for other types of links that are formatted like actions (e.g. helpIndex.)

Any ideas how to efficiently check all controllers to see if something is an action, for both function and class actions? I fear that I’ll have to register all actions somehow.

I have my fingers crossed that there is some function that will fail if fed a non-action string, but has no substantial side effects.

Thank you kindly, Ivo

I’m currently trying to figure out the below section of [font=“Courier New”]CUrlManager::parseUrl($request)[/font] in hopes I can adapt the foreach loop somehow.


	$rawPathInfo=urldecode($request->getPathInfo());

	$pathInfo=$this->removeUrlSuffix($rawPathInfo,$this->urlSuffix);

	foreach($this->_rules as $rule)

	{

		if(($r=$rule->parseUrl($this,$pathInfo,$rawPathInfo))!==false)

			return isset($_GET[$this->routeVar]) ? $_GET[$this->routeVar] : $r;

	}

I roughly understand most of this snippet, but I’m not sure what the point of the [font=“Courier New”]$_GET routeVar[/font] stuff is on the return line, and will look at that next.

Well, I haven’t found a reasonably efficient way to do this (efficient since this will be called for every link on most pages), so I’ve decided to simply rewrite [font=“Courier New”]CHtml::link()[/font] to assume that the url parameter is an action. Any non-action urls will have to be manually specified with the old version of the function, either directly, or by way of a newly created [font=“Courier New”]linkStatic()[/font] wrapper function.

I’m still curious if anyone knows of a good way to make links display conditionally, where actions are automatically identified and handled differently than external urls.

<waves cheerfully>