View/Helper/ClearanceHelper.php
public function execute($route, $title, $url = null, $options = array(), $confirmMessage = false) {
		if (empty($route['rules'])) {
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (isset($route['rules']['deny'])) {
			return ($route['rules']['deny'] == true) ? null : $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (!isset($route['rules']['auth'])) {
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (is_bool($route['rules']['auth'])) {
			$isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}");

			if ($route['rules']['auth'] == true && !$isAuthed) {
				return;
			}
			if ($route['rules']['auth'] == false && $isAuthed) {
				return;
			}
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		$count = count($route['rules']['auth']);
		if ($count == 0) {
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (($user = $this->Session->read("{$this->settings['path']}")) == false) {
			return;
		}

		foreach ($route['rules']['auth'] as $field => $value) {
			if (strpos($field, '.') !== false) {
				$field = '/' . str_replace('.', '/', $field);
			}

			if ($field[0] == "/") {
				$values = (array)Set::extract($field, $user);
				foreach ($value as $condition) {
					if (in_array($condition, $values)) {
						$count--;
					}
				}
			} else {
				if ($user[$field] == $value) {
					$count--;
				}
			}
		}

		return ($count != 0) ? null : $this->Html->link($title, $url, $options, $confirmMessage);
	}
public function execute($route, $title, $url = null, $options = array(), $confirmMessage = false) {
		if (empty($route['rules'])) {
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (isset($route['rules']['deny'])) {
			return ($route['rules']['deny'] == true) ? null : $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (!isset($route['rules']['auth'])) {
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (is_bool($route['rules']['auth'])) {
			$isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}");

			if ($route['rules']['auth'] == true && !$isAuthed) {
				return;
			}
			if ($route['rules']['auth'] == false && $isAuthed) {
				return;
			}
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		$count = count($route['rules']['auth']);
		if ($count == 0) {
			return $this->Html->link($title, $url, $options, $confirmMessage);
		}

		if (($user = $this->Session->read("{$this->settings['path']}")) == false) {
			return;
		}

		foreach ($route['rules']['auth'] as $field => $value) {
			if (strpos($field, '.') !== false) {
				$field = '/' . str_replace('.', '/', $field);
			}

			if ($field[0] == "/") {
				$values = (array)Set::extract($field, $user);
				foreach ($value as $condition) {
					if (in_array($condition, $values)) {
						$count--;
					}
				}
			} else {
				if ($user[$field] == $value) {
					$count--;
				}
			}
		}

		return ($count != 0) ? null : $this->Html->link($title, $url, $options, $confirmMessage);
	}
public function execute ( $ route , $ title , $ url = null , $ options = array ( ) , $ confirmMessage = false ) { if ( empty ( $ route [ 'rules' ] ) ) { return $ this -> Html -> link ( $ title , $ url , $ options , $ confirmMessage ) ; } if ( isset ( $ route [ 'rules' ] [ 'deny' ] ) ) { return ( $ route [ 'rules' ] [ 'deny' ] == true ) ? null : $ this -> Html -> link ( $ title , $ url , $ options , $ confirmMessage ) ; } if ( ! isset ( $ route [ 'rules' ] [ 'auth' ] ) ) { return $ this -> Html -> link ( $ title , $ url , $ options , $ confirmMessage ) ; } if ( is_bool ( $ route [ 'rules' ] [ 'auth' ] ) ) { $ isAuthed = $ this -> Session -> read ( "{$this->settings['path']}.{$this->settings['check']}" ) ; if ( $ route [ 'rules' ] [ 'auth' ] == true && ! $ isAuthed ) { return ; } if ( $ route [ 'rules' ] [ 'auth' ] == false && $ isAuthed ) { return ; } return $ this -> Html -> link ( $ title , $ url , $ options , $ confirmMessage ) ; } $ count = count ( $ route [ 'rules' ] [ 'auth' ] ) ; if ( $ count == 0 ) { return $ this -> Html -> link ( $ title , $ url , $ options , $ confirmMessage ) ; } if ( ( $ user = $ this -> Session -> read ( "{$this->settings['path']}" ) ) == false ) { return ; } foreach ( $ route [ 'rules' ] [ 'auth' ] as $ field => $ value ) { if ( strpos ( $ field , '.' ) !== false ) { $ field = '/' . str_replace ( '.' , '/' , $ field ) ; } if ( $ field [ 0 ] == "/" ) { $ values = ( array ) Set :: extract ( $ field , $ user ) ; foreach ( $ value as $ condition ) { if ( in_array ( $ condition , $ values ) ) { $ count -- ; } } } else { if ( $ user [ $ field ] == $ value ) { $ count -- ; } } } return ( $ count != 0 ) ? null : $ this -> Html -> link ( $ title , $ url , $ options , $ confirmMessage ) ; }
Executes the route based on it's rules

@param string $route route being executed
@param string $title The content to be wrapped by <a> tags.
@param mixed $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
@param array $options Array of HTML attributes.
@param string $confirmMessage JavaScript confirmation message.
@return string An `<a />` element.
@author Jose Diaz-Gonzalez
Executes the route based on it s rules