Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
RController.php
1 <?php
2 /**
3  * Rights base controller class file.
4  *
5  * @author Christoffer Niska <cniska@live.com>
6  * @copyright Copyright &copy; 2010 Christoffer Niska
7  * @since 0.6
8  */
9 class RController extends CController
10 {
11  /**
12  * @property string the default layout for the controller view. Defaults to '//layouts/column1',
13  * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
14  */
15  public $layout = '//layouts/column1';
16  /**
17  * @property array context menu items. This property will be assigned to {@link CMenu::items}.
18  */
19  public $menu = array();
20  /**
21  * @property array the breadcrumbs of the current page. The value of this property will
22  * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
23  * for more details on how to specify this property.
24  */
25  public $breadcrumbs = array();
26 
27 
28  public function filterAccessControl($filterChain)
29  {
30  $filter = new AccessControlFilter;
31  $filter->setRules($this->accessRules());
32  $filter->filter($filterChain);
33  }
34 
35  /**
36  * The filter method for 'rights' access filter.
37  * This filter is a wrapper of {@link CAccessControlFilter}.
38  * @param CFilterChain $filterChain the filter chain that the filter is on.
39  */
40  public function filterRights($filterChain)
41  {
42  $filter = new RightsFilter;
43  $filter->allowedActions = $this->allowedActions();
44  $filter->filter($filterChain);
45  }
46 
47  /**
48  * @return string the actions that are always allowed separated by commas.
49  */
50  public function allowedActions()
51  {
52  return '';
53  }
54 
55  /**
56  * Denies the access of the user.
57  * @param string $message the message to display to the user.
58  * This method may be invoked when access check fails.
59  * @throws CHttpException when called unless login is required.
60  */
61  public function accessDenied($message = null)
62  {
63  if ($message === null)
64  $message = Rights::t('core', 'You are not authorized to perform this action.');
65 
66  $user = Yii::app()->getUser();
67  if ($user->isGuest === true)
68  $user->loginRequired();
69  else
70  throw new CHttpException(403, $message);
71  }
72 }