public function uniqueEmail($attribute, $params) { $userApi = sharedkeyApi::create('usersAPI'); $userApi->addParams(array('email' => $this->{$attribute}, 'format' => 'json')); $isExists = json_decode($userApi->byEmail('get')); if ($isExists->result == true) { $this->addError('email', 'Email already exists'); } }
public function update() { $id = YII::app()->user->getState('id'); $userApi = sharedkeyApi::create('usersAPI'); $userApi->addParams(array('id' => $id, 'format' => 'json')); $data = $userApi->byid('get'); $data = json_decode($data); $this->setData((array) $data); return true; }
public function actionBullingInformation() { $this->pageName = "billing"; // if (!Yii::app()->request->isPostRequest) { // $this->redirect(basePath('')); // } if (Yii::app()->user->isGuest) { Yii::app()->request->redirect(basePath('')); } // if (UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), Yii::app()->user->getState('propertyId'), UserAccessTable::OWNER)) { // $this->redirect(basePath('')); // ; // } $model = new PayPalPaymentModel(); $model->setAttributes($_POST); $model->validate(); $errors = $model->getErrors(); if (count($errors) > 0) { $this->render('index', array('errors' => $errors, 'bull' => $model->attributes, 'countries' => $this->getCountries(), 'provinces' => $this->getProvinces())); return; } $userApi = sharedkeyApi::create('usersAPI'); $userApi->addParams(array('email' => Yii::app()->user->getState('email'), 'format' => 'json')); $property = Properties::model()->findByPk(Yii::app()->user->getState('propertyId')); $byEmail = json_decode($userApi->byEmail('get')); $userData = (array) $byEmail->data; $userData['prop_name'] = $property ? $property->property_name : ""; $response = PayPalHelper::createBullingRequest($model, $userData); if (!$response->status) { $errors['0'] = $response->errorMessage; $this->render('index', array('errors' => $errors, 'countries' => $this->getCountries(), 'provinces' => $this->getProvinces())); return; } //activate property $property->isdeactivated = 0; $property->trialPeriodStartDate = null; $property->edt = new CDbExpression('NOW()'); $property->save(); //update property Admin $user2property = User2property::model()->findByAttributes(array('propertyId' => $property->getAttribute('id'), 'access' => UserAccessTable::OWNER)); if ($user2property->getAttribute('userId') != Yii::app()->user->getState('id')) { //need update property admin $user2property->access = UserAccessTable::FULL_ACCESS; $user2property->save(); //find current payer link and set it to Admin mode $u2p = User2property::model()->findByAttributes(array('userId' => Yii::app()->user->getState('id'), 'propertyId' => $property->getAttribute('id'))); $u2p->access = UserAccessTable::OWNER; $u2p->save(); } $this->redirect(basePath('app/gallery')); }
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; }
public function actionRemoveproperty($id) { $userId = Yii::app()->user->getState('id'); //all users can remove itself from property member's list if (!UserAccessTable::checkUser2PropertyAccess($userId, $id, UserAccessTable::GUEST)) { Yii::app()->request->redirect(basePath('app/gallery')); } $user2property = User2property::model()->findByAttributes(array('userId' => $userId, 'propertyId' => $id)); if ($user2property->getAttribute('access') != UserAccessTable::OWNER) { //email to member (NOT admin) $this->layout = "emailmaster"; $body = $this->render("../emails/emailItselfRemove", array('name' => $user2property->user->getAttribute('firstname') . ' ' . $user2property->user->getAttribute('lastname'), 'propertyName' => $user2property->property->getAttribute('property_name')), true); MailHelper::send($body, "SharedKey - Removed Property", array($user2property->user->getAttribute('email'))); //clear calendar events first $calendar = new Calendar(); $calendar = $calendar->findAllByAttributes(array('linkid' => $user2property->getAttribute('id'))); foreach ($calendar as $cal) { $cal->delete(); } //for not property Administrator we just remove a link to property $user2property->delete(); if ($this->_isAllUserPropertiesDeactivated($userId)) { //removed last property need remove user $this->removeUser($userId); return; } Yii::app()->request->redirect(basePath('app/properties')); return; } //member is administrator we need cancel RecurringPaymentsProfile and deactivate property //lets find last transaction $transaction = Transaction::model()->findByAttributes(array('userid' => $userId, 'propertyid' => $id)); if (!$transaction) { //no previous transactions not need to refund } $userApi = sharedkeyApi::create('usersAPI'); $userEmail = Yii::app()->user->getState('email'); $userApi->addParams(array('email' => $userEmail)); $byEmail = json_decode($userApi->byEmail('get')); $userData = (array) $byEmail->data; $userData['property_id'] = $id; //close RecurringPaymentsProfile if ($transaction) { YII::app()->user->setState("addPropertyEmailed", true); $temp = PayPalHelper::cancelRecurringPaymentsProfile($transaction->getAttribute('pp_PROFILEID'), $userData); } //do deactivated $property = Properties::model()->findByPk($id); $property->isdeactivated = 1; $property->edt = new CDbExpression('NOW()'); //$property->trialPeriodStartDate = null; $property->save(); $this->layout = "emailmaster"; //mail to admin $token = uniqid(); $body = $this->render("../emails/emailAdminAfterRemove", array('name' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'url' => basePathByHost("/app/changeactiveproperty/" . $property->getAttribute("id")) . '?token=' . $token), true); MailHelper::send($body, "SharedKey - Removed Property", array($userEmail)); //informative other user about property deactivated $users2properties = User2property::model()->with('user')->findAll('propertyId=:propertyId', array(':propertyId' => $id)); foreach ($users2properties as $key => $u2p) { if ($u2p->getAttribute('access') == UserAccessTable::OWNER) { continue; } } if ($this->_isAllUserPropertiesDeactivated($userId)) { $user = User::model()->find('id=:id', array(':id' => $userId)); $user->verificationToken = $token; $user->save(); $this->redirect(basePath('user/logout')); return; } Yii::app()->request->redirect(basePath('app/properties')); }
public function actionDeleteHouseRule() { if ($this->access > UserAccessTable::FULL_ACCESS) { return 0; } $data = array(); $data['property_id'] = Yii::app()->user->getState('property_id', 0); $data['id'] = YII::app()->request->getPost('id', 0); $data['notification'] = trim(YII::app()->request->getParam('notification', 0)); $api = sharedkeyApi::create('houserulesAPI'); $api->addParams($data); $dataObj = json_decode($api->byHouserulesId('get')); $result = $api->byHouserulesId('delete'); $result = json_decode($result); $all = $data['notification'] == 1 ? true : false; if ($result->result == true) { $this->NotificationMembers("Deleted", $all, (array) $dataObj->data); } $this->renderPartial('delete', array('result' => $result->result)); }
public function actionSignUp() { $data = $this->getSignUpData(); $errors = $this->signUpValidation($data); if ($data['PP_TRIAL'] != 'YES') { $paypalModel = new PayPalPaymentModel(); if (empty($errors)) { $paypalModel->setAttributes($_POST); $paypalModel->validate(); $errors = $paypalModel->getErrors(); } } if (empty($errors)) { //registration $userApi = sharedkeyApi::create('usersAPI'); $verificationToken = uniqid(); $data['verificationToken'] = $verificationToken; $data['status'] = 0; $userApi->addParams($data); $signup = $userApi->signUp('create'); $signup = json_decode($signup); if ($signup->result == false) { $this->redirect(basePath('signup')); } else { $userApi = sharedkeyApi::create('usersAPI'); $userApi->addParams(array('email' => $data['email'], 'password' => $data['password'], 'format' => 'json')); $byEmail = json_decode($userApi->byEmail('get')); $userData = $byEmail->data; if ($data['PP_TRIAL'] != 'YES') { //send paypal request $response = PayPalHelper::createBullingRequest($paypalModel, (array) $userData); if (!$response->status) { $this->clearDataAfterSignUpByEmail($data['email']); $errors['paypal_error'] = $response->errorMessage; //show errors $this->setFlashErrors($errors); $this->setFlashData($data); $this->redirect(basePath('signup')); } } $this->layout = "emailmaster"; $message = $this->render('../emails/newuseremail', array('token' => $verificationToken, 'url' => Yii::app()->params['domain'] . '/activeuser', 'email' => $data['email'], 'password' => $data['password'], 'fullname' => $data['firstname'] . ' ' . $data['lastname']), true); MailHelper::send($message, "Welcome to SharedKey", array($data['email'])); //$identity->authenticate(); //Yii::app()->user->login($identity); Yii::app()->user->setState('new_email', $data['email']); $this->redirect(basePath('activateusermessage')); } } else { $this->clearDataAfterSignUpByEmail($data['email']); //show errors $this->setFlashErrors($errors); $this->setFlashData($data); $this->redirect(basePath('signup')); } }
public function actionGetNotice() { if ($this->access > UserAccessTable::BASIC_ACCESS) { return 0; } $data = array(); $data['property_id'] = Yii::app()->user->getState('property_id', 0); $page = YII::app()->request->getParam('page', null); $data['limit'] = $this->_limit; $data['offset'] = $page * $this->_limit; $api = sharedkeyApi::create('noticeboardAPI'); $api->addParams($data); $result = $api->byPropertyId('get'); $result = json_decode($result); foreach ($result->data as $key => $item) { $result->data[$key]->updatetime = date('F jS \\, Y ', strtotime($result->data[$key]->updatetime)); } if (!isset($result->data)) { $result->data = array(); } $this->renderPartial('get', array('data' => $result->data, 'result' => $result->result)); }
public function actionDeleteActive() { if ($this->access > UserAccessTable::FULL_ACCESS) { return 0; } $data = array(); $data['property_id'] = Yii::app()->user->getState('property_id', 0); $data['id'] = YII::app()->request->getPost('id', 0); $api = sharedkeyApi::create('touristinfoAPI'); $api->addParams($data); $result = $api->byInfoId('delete'); $result = json_decode($result); $this->renderPartial('delete', array('result' => $result->result)); }
public function actionPrintpart($id = false) { $property_id = Yii::app()->user->getState('property_id'); $KeycontactApi = sharedkeyApi::create('keycontactAPI'); if ($id) { $KeycontactApi->addParams(array('id' => $id, 'property_id' => $property_id, 'limit' => $this->_limit, 'offset' => $this->_offset)); $results = json_decode($KeycontactApi->byContactId('get')); $results->data = array($results->data); } else { $KeycontactApi->addParams(array('property_id' => $property_id, 'limit' => $this->_limit, 'offset' => $this->_offset)); $results = json_decode($KeycontactApi->byPropertyId('get')); } $results = $results->data; $results = (object) $results; $this->tabName = 'Key Contacts'; $this->layout = 'print'; return $this->render('print', array('items' => $results), true); }