HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
RWebUser.php
Go to the documentation of this file.
1 <?php
10 class RWebUser extends CWebUser
11 {
18  public function afterLogin($fromCookie)
19  {
20  parent::afterLogin($fromCookie);
21 
22  // Mark the user as a superuser if necessary.
23  if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
24  $this->isSuperuser = true;
25  }
26  }
27 
45  public function checkAccess($operation, $params = array(), $allowCaching = true)
46  {
47  // Allow superusers access implicitly and do CWebUser::checkAccess for others.
48  return $this->isSuperuser === true ? true : parent::checkAccess($operation, $params, $allowCaching);
49  }
50 
54  public function setIsSuperuser($value)
55  {
56  $this->setState('Rights_isSuperuser', $value);
57  }
58 
62  public function getIsSuperuser()
63  {
64  return $this->getState('Rights_isSuperuser');
65  }
66 
70  public function setRightsReturnUrl($value)
71  {
72  $this->setState('Rights_returnUrl', $value);
73  }
74 
85  public function getRightsReturnUrl($defaultUrl = null)
86  {
87  if (($returnUrl = $this->getState('Rights_returnUrl')) !== null) {
88  $this->returnUrl = null;
89  }
90 
91  return $returnUrl !== null ? CHtml::normalizeUrl($returnUrl) : CHtml::normalizeUrl($defaultUrl);
92  }
93 
94  // spv
95  public function updateSession()
96  {
97  $user = Yii::app()->getModule('user')->user($this->id);
98  $userAttributes = CMap::mergeArray(array(
99  'email' => $user->email,
100  'username' => $user->username,
101  'create_at' => $user->create_at,
102  'lastvisit_at' => $user->lastvisit_at,
103  ), $user->profile->getAttributes());
104  foreach ($userAttributes as $attrName => $attrValue) {
105  $this->setState($attrName, $attrValue);
106  }
107  }
108 }