Beispiel #1
0
 public function registration()
 {
     $bookhouse = new Model_BookhouseModel();
     $bookhouse->loadActiveBookhouse();
     if ($bookhouse->getCanUserRegister() == 0) {
         $this->setValidationError('Bookhouse', 'Registration is disabled');
     }
     $userCheckModel = new Model_UserModel();
     $userCheckModel->load(array('user_name' => $this->getUserName()));
     $userId = $userCheckModel->getUserId();
     if (isset($userId)) {
         $this->setValidationError('username', 'Username already exist');
         return;
     }
     $userCheckModel->load(array('email' => $this->getEmail()));
     $userId = $userCheckModel->getUserId();
     if (isset($userId)) {
         $this->setValidationError('username', 'Email already exist');
         return;
     }
     $this->setLastLogin(date('Y-m-d H:i:s'));
     $this->setUserStatusIdFK(3);
     $this->setBanned(0);
     $this->setEmailValidated(0);
     $this->insert();
     $userIdFK = $this->getConnection()->getInsertId();
     $transaction = new Model_TransactionModel();
     $transaction->setUserIdFK($userIdFK);
     $transaction->setTransactionTypeIdFK(1);
     $transaction->setMoney($bookhouse->getDefaultMoneyValue());
     $transaction->setTransactionTypeIdendifier(null);
     $transaction->insert();
 }
Beispiel #2
0
 public function actionRegistration()
 {
     $this->preventTemplateRender();
     $user = new Model_UserModel();
     $isVarsSet = true;
     if (!isset($_POST['user_nameReg'])) {
         $user->setValidationError('username', 'Username not set');
         $isVarsSet = false;
     }
     if (!isset($_POST['passwordReg'])) {
         $user->setValidationError('password', 'Password not set');
         $isVarsSet = false;
     }
     if (!isset($_POST['first_name'])) {
         $user->setValidationError('first_name', 'Firstname not set');
         $isVarsSet = false;
     }
     if (!isset($_POST['last_name'])) {
         $user->setValidationError('password', 'Last name not set');
         $isVarsSet = false;
     }
     if (!isset($_POST['email'])) {
         $user->setValidationError('email', 'Email not set');
         $isVarsSet = false;
     }
     if (!$isVarsSet) {
         echo json_encode(array('status' => 'error', 'errors' => $user->getValidationErrors()));
         return false;
     }
     $user->setUserName($_POST['user_nameReg']);
     $user->setPasswordBeforeSalt($_POST['passwordReg']);
     $user->setFirstName($_POST['first_name']);
     $user->setLastName($_POST['last_name']);
     $user->setEmail($_POST['email']);
     $user->validateFields(array('user_name', 'password', 'first_name', 'last_name', 'email'));
     if ($user->isValid()) {
         $user->registration();
         if (!$user->isValid()) {
             echo json_encode(array('status' => 'error', 'errors' => $user->getValidationErrors()));
         } else {
             echo json_encode(array('status' => 'ok', 'message' => 'Registration is complete<br /> You may login now'));
         }
     } else {
         echo json_encode(array('status' => 'error', 'errors' => $user->getValidationErrors()));
     }
 }
Beispiel #3
0
 private function setUsersTablePanel()
 {
     $table = $this->usersTableWithPanel->getTable();
     $model = new Model_UserModel();
     $model->addQuery('select', array('table' => $model->getTableName()));
     $model->addQuery('order', array('order' => implode($model->getPrimaryKeys(), ",") . ' DESC'));
     $model->addQuery('limit', array('limit' => 20));
     $this->usersTableWithPanel->addRemoveKeyFromData('password');
     $this->usersTableWithPanel->addRemoveKeyFromData('salt');
     $this->usersTableWithPanel->addRemoveKeyFromData('mail_validation');
     $this->usersTableWithPanel->setModel($model);
     $table->addColumn(array('key' => 'user_id', 'label' => 'ID'));
     $table->addColumn(array('key' => 'first_name', 'label' => 'First Name'));
     $table->addColumn(array('key' => 'last_name', 'label' => 'Last Name'));
     $table->addColumn(array('key' => 'user_name', 'label' => 'User Name'));
     $table->addColumn(array('key' => 'password_before_salt', 'label' => 'Password'));
     $table->addColumn(array('key' => 'last_login', 'label' => 'Last login'));
     $table->addColumn(array('key' => 'email', 'label' => 'Email'));
     $table->addColumn(array('key' => 'banned', 'label' => 'Banned'));
     $table->addColumn('{key:"email_validated",label:"E-Validated",allowHTML:true,formatter:' . $table->getFormatter("selectYesNo", array('attributes' => array('name' => 'model[' . $this->usersTableWithPanel->getModelName() . '][email_validated]'))) . '}', false, 'email_validated');
     $table->addColumn('{key:"banned",label:"Banned",allowHTML:true,formatter:' . $table->getFormatter("selectYesNo", array('attributes' => array('name' => 'model[' . $this->usersTableWithPanel->getModelName() . '][banned]'))) . '}', false, 'banned');
     $edit = Application::getBaseRelativeUrl() . '/images/edit.png';
     $this->usersTableWithPanel->addRemoveKeyFromData('password');
     $this->usersTableWithPanel->setUpdateRule('exclude', 'last_login');
     $this->usersTableWithPanel->setUpdateRule('exclude', 'yui_datatablepanel_bets_bank');
     $this->usersTableWithPanel->setInsertRule('exclude', 'yui_datatablepanel_bets_bank');
     $userStatusModel = new Model_UserStatusModel();
     $userStatusModel->addQuery('select', array('table' => $userStatusModel->getTableName()));
     $userStatusCollection = new Core_Model_Adapter_ModelCollection();
     $userStatusCollectionData = $userStatusCollection->getModelCollection($userStatusModel);
     $urlServiceBankBetFormatter = Application::getRouter()->getFullUrl(array('controller' => 'servicehtml', 'action' => 'view')) . '&view=View_Admin_UserBankBets&user_id={value}';
     $table->addColumn('{key:"user_status_id_FK",label:"Group",allowHTML:true,formatter:' . $table->getFormatter("selectFromModel", array('values' => $userStatusCollectionData, 'value' => 'user_status_id', 'label' => 'status_name', 'attributes' => array('name' => 'model[' . $this->usersTableWithPanel->getModelName() . '][user_status_id_FK]'))) . '}', false, 'user_status');
     $table->addColumn('{key:"user_id",label:"Bets/Bank",allowHTML:true,formatter:\'<a class="yui_datatablepanel_bets_bank systemServiceLink" servicehtml="' . $urlServiceBankBetFormatter . '" href="javascript:void(0);" >Bets/Bank</a>\'}', false, 'bets_bank');
     $select = new Extension_View_Html_Form_Elements_Select();
     $select->setModel($userStatusCollection->toArray());
     $select->setAttribute('name', 'user_status_id_FK');
     $select->setOptionLabelKey('status_name');
     $select->setOptionValueKey('user_status_id');
     $select->setPrependHtml('User Status:');
     $this->usersTableWithPanel->addFilter($select);
     $selectBanned = new Extension_View_Html_Form_Elements_Select();
     $selectBanned->setModel(Extension_Helpers_Models_Elements_Select::yesNo());
     $selectBanned->setAttribute('name', 'banned');
     $selectBanned->setOptionLabelKey('label');
     $selectBanned->setOptionValueKey('value');
     $selectBanned->setPrependHtml('User Banned:');
     $this->usersTableWithPanel->addFilter($selectBanned);
     $selectMailValidation = new Extension_View_Html_Form_Elements_Select();
     $selectMailValidation->setModel(Extension_Helpers_Models_Elements_Select::yesNo());
     $selectMailValidation->setAttribute('mail_validated', 'banned');
     $selectMailValidation->setOptionLabelKey('label');
     $selectMailValidation->setOptionValueKey('value');
     $selectMailValidation->setPrependHtml('Mail Validated:');
     $this->usersTableWithPanel->addFilter($selectMailValidation);
     $username = new Extension_View_Html_Form_Elements_Input();
     $username->setAttributes(array('name' => 'user_name', 'type' => 'text'));
     $username->setPrependHtml('Username:'******'name' => 'first_name', 'type' => 'text'));
     $firstname->setPrependHtml('First Name:');
     $lastname = new Extension_View_Html_Form_Elements_Input();
     $lastname->setAttributes(array('name' => 'last_name', 'type' => 'text'));
     $lastname->setPrependHtml('Last Name:');
     $this->usersTableWithPanel->addFilter($username);
     $this->usersTableWithPanel->addFilter($firstname);
     $this->usersTableWithPanel->addFilter($lastname);
 }