Esempio n. 1
0
 /**
  *
  * @param type $property_id
  * @return boolean 
  */
 public static function changeActiveProperty($property_id)
 {
     $userId = Yii::app()->user->getState('id');
     $userModel = new \User();
     $isValidProperty = UserAccessTable::checkUser2PropertyAccess($userId, $property_id, UserAccessTable::GUEST);
     if (!$isValidProperty) {
         return false;
     } else {
         $result = $userModel->updateByPk($userId, array('property_id' => $property_id));
         $userControl = new userControl();
         $userControl->update();
         return true;
     }
 }
 protected function backTutorial($tutorial)
 {
     $api = sharedkeyApi::create('usersAPI');
     $api->addParams(array($tutorial => '1', 'id' => Yii::app()->user->getState('id')));
     $result = $api->tutorial('update');
     $user = new userControl();
     $user->update();
     return $result;
 }
Esempio n. 3
0
 public function actionChangeactiveproperty($id)
 {
     if (isset($_GET['token'])) {
         //login user and redirect back to complete the action
         $this->redirect(basePath('activeuser?token=' . $_GET['token'] . '&url=app/changeactiveproperty/' . $id));
     }
     $userId = Yii::app()->user->getState('id');
     $userModel = new \User();
     $isValidProperty = UserAccessTable::checkUser2PropertyAccess($userId, $id, UserAccessTable::GUEST);
     if (!$isValidProperty) {
         Yii::app()->request->redirect(basePath('app/gallery'));
     } else {
         /* https://www.pivotaltracker.com/story/show/80061356
            ADMIN
                1. Owner/Admin deletes his LAST property.
                2. Keep his email so that he can reactivate and being taken to billings page upon logging in.
                3. Email is only kept for 30 days. Therefore he can only reactivare within 30 days.
                4. After 30 days, he will have re-sign up like a new user.
            */
         if ($this->_isAllUserPropertiesDeactivated($userId) && $this->_daysSinceLastPropertyEditDate($id) >= 30) {
             $this->removeUser($userId);
             return;
         }
         $result = $userModel->updateByPk($userId, array('property_id' => $id));
         $userControl = new userControl();
         $userControl->update();
         Yii::app()->request->redirect(basePath('app/gallery'));
     }
 }