Esempio n. 1
0
 /**
  * 根据微信推送的包,创建相关帐户信息
  *
  * @param $openid 微信服务器推送的微信粉丝OpenId
  * @param $account 接受微信服务器推送数据的公众号实体对象
  * @return 创建成功返回微信OpenId数据对象,否则返回False
  */
 public static function createWechatAccount($openid, $account = [])
 {
     //创建微信信息
     $wechat = \Model_Wechat::forge(['nickname' => $openid]);
     //是否创建用户登录信息
     if (isset($account->is_subscribe_create_user) && $account->is_subscribe_create_user) {
         $params = ['username' => "wx_{$openid}", 'password' => "w{$account->id}#{$openid}", 'email' => "wx_{$openid}@{$account->id}.com", 'group_id' => $account->create_user_default_group];
         $user_id = \Model_User::createUser($params);
         $wechat->user_id = $user_id;
         $params = ['user_id' => $user_id];
         $people = \Model_People::forge($params);
         $people->save();
         //是否创建会员信息
         if (isset($account->is_subscribe_create_member) && $account->is_subscribe_create_member) {
             $params = ['no' => "{$account->seller_id}{$wechat->user_id}" . time(), 'user_id' => $wechat->user_id];
             $member = \Model_Member::forge($params);
             $member->save();
         }
     }
     //创建微信OpenID记录
     $params = ['openid' => $openid, 'account_id' => $account->id];
     $wechatOpenid = \Model_WechatOpenid::forge($params);
     $wechat->ids = [$wechatOpenid];
     $wechat->save();
     return $wechatOpenid;
 }
Esempio n. 2
0
 public function createAction()
 {
     $frmUser = new Form_User();
     if ($this->_request->isPost()) {
         if ($frmUser->isValid($_POST)) {
             $mdlUser = new Model_User();
             $mdlUser->createUser($frmUser->getValue('username'), $frmUser->getValue('password'), $frmUser->getValue('first_name'), $frmUser->getValue('last_name'), $frmUser->getValue('role'));
             return $this->_forward('list');
         }
     }
     $frmUser->setAction('/user/create');
     $this->view->form = $frmUser;
 }
Esempio n. 3
0
 public function indexAction()
 {
     $sessionId = $_REQUEST["sessionId"];
     $no = $_REQUEST["phoneNumber"];
     $no = str_replace("+", "", $no);
     $no2 = substr($no, -9);
     if (!empty($_REQUEST['text'])) {
         $message = $_REQUEST["text"];
         $result = explode("*", $message);
         if (empty($result)) {
             $message = $message;
         } else {
             end($result);
             // move the internal pointer to the end of the array
             $message = current($result);
         }
     } else {
         $message = 'start';
     }
     $data = array('content' => $message);
     //$tablee = "ussd";
     $userModel = new Model_User();
     $user = $userModel->getUserWithPhone($no);
     // print_r($user);
     // exit;
     if ($user['id'] == 0) {
         $user = $userModel->getUserWithPhone($no2);
         if ($user['id'] == 0) {
             //register user
             $dataa = array('phoneno' => $no, 'menu_item_id' => 1);
             $result = $userModel->createUser($dataa);
             $user = $userModel->getUserWithPhone($no);
             if ($result) {
                 $output = $this->mainMenu($user, $no);
                 $response = "CON ";
                 $response .= $output;
                 echo $response;
                 exit;
                 //print_r($output);
                 //exit;
             }
         } else {
             if ($user->role == 102) {
                 $this->agrovet($user, $message, $sessionId);
             }
         }
     } else {
         $this->main($user, $message, $sessionId);
         exit;
     }
 }
Esempio n. 4
0
 /**
  * Creates a new user
  *
  * @param  string $userName  User name to create User for
  * @param  string $firstName User's first name
  * @param  string $lastName  User's last name
  * @param  string $email     User's email address
  * @param  string $password  User's password
  * @param  string $active    User's activity status
  * @param  string $role      User's acl role
  * @return mixed  False if unsuccessful, otherwise Model_User object
  */
 public function createUser($userName, $firstName, $lastName, $email, $password, $active = 0, $role = Model_Group::GUEST_ROLE)
 {
     $mdlUser = new Model_User();
     $userName = $mdlUser->createUser($userName, $firstName, $lastName, $email, $password, $active, $role);
     if (!empty($userName) && '' != $userName) {
         return $this->prepareChallenge($userName, $email);
     }
     return false;
 }
Esempio n. 5
0
 public function createEnterpriseTransaction($ficha)
 {
     $AddressEnterprise = new Model_AddressEnterprise();
     $AddressPresident = new Model_AddressPresident();
     $President = new Model_President();
     $PresidentProgram = new Model_PresidentProgram();
     $User = new Model_User();
     $UserLocality = new Model_UserLocality();
     $Acl = new Model_Acl();
     $modelEntCatAwardCompetition = new Model_EnterpriseCategoryAwardCompetition();
     $modelLogCadastroEmpresa = new Model_LogCadastroEmpresa();
     //$Eligibility = new Model_Eligibility();
     // dados da Empresa
     $registerEnterpriseData = $ficha['enterprise'];
     $registerEnterpriseData['status'] = 'A';
     // dados endereço da Empresa
     $registerAddressEnterpriseData = $ficha['addressEnterprise'];
     // dados da presidente da Empresa
     $registerPresidentData = $ficha['president'];
     $registerPresidentData['gender'] = 'F';
     $registerPresidentData['created'] = date('Y-m-d');
     $registerPresidentData['hasnt_email'] = isset($ficha['enterprise']['hasnt_email']) ? $ficha['enterprise']['hasnt_email'] : 0;
     // dados endereço da Empresa
     $registerAddressPresidentData = $ficha['addressPresident'];
     // dados do program do presidente da Empresa
     $registerPresidentProgramData = isset($ficha['presidentProgram']) ? $ficha['presidentProgram'] : null;
     // dados do usuário
     $registerUserData = $ficha['user'];
     $registerUserData['login'] = $registerPresidentData['cpf'];
     $registerUserData['first_name'] = $registerPresidentData['name'];
     $registerUserData['surname'] = isset($registerPresidentData['nick_name']) ? $registerPresidentData['nick_name'] : null;
     $registerUserData['email'] = $registerPresidentData['email'];
     $registerUserData['status'] = 'A';
     $registerLogCadastro = isset($ficha['log_cadastro_empresa']) ? $ficha['log_cadastro_empresa'] : false;
     // start transaction externo
     Zend_Registry::get('db')->beginTransaction();
     try {
         $enterpriseEmail = isset($ficha['enterprise']['email_default']) ? $ficha['enterprise']['email_default'] : '';
         $hasntEmail = isset($ficha['enterprise']['hasnt_email']) ? $ficha['enterprise']['hasnt_email'] : 0;
         $this->validateEmail(NULL, $enterpriseEmail, $hasntEmail);
         $this->validateLandline($ficha['enterprise']['phone']);
         // Validação Categoria do Premio
         $insertCategoryAward = $this->validCategoryAward($registerEnterpriseData);
         if (!$insertCategoryAward['status']) {
             throw new Vtx_UserException($insertCategoryAward['messageError'], 10);
         }
         // 1.1 Insert Empresa
         $insertEnterprise = $this->createEnterprise($registerEnterpriseData);
         if (!$insertEnterprise['status']) {
             throw new Vtx_UserException($insertEnterprise['messageError'], 10);
         }
         // elegibilidade para questionario de diagnostico
         //$Eligibility->doDiagnosticoEligibility($insertEnterprise['row']);
         // 1.2 Insert Endereço da Empresa
         $registerAddressEnterpriseData['enterprise_id'] = $insertEnterprise['lastInsertId'];
         $insertAddressEnterprise = $AddressEnterprise->createAddressEnterprise($registerAddressEnterpriseData);
         if (!$insertAddressEnterprise['status']) {
             throw new Vtx_UserException($insertAddressEnterprise['messageError'], 10);
         }
         // validação dos campos NewsLetter da Candidata (President)
         $newsLetterValid = $President->isValidNewsletter($ficha['newsletter'], $registerPresidentData);
         if (!$newsLetterValid['status']) {
             throw new Vtx_UserException($newsLetterValid['messageError']);
         }
         // 2.1 Insert Presidente da Empresa
         $registerPresidentData['enterprise_id'] = $insertEnterprise['lastInsertId'];
         $insertPresident = $President->createPresident($registerPresidentData);
         if (!$insertPresident['status']) {
             throw new Vtx_UserException($insertPresident['messageError']);
         }
         $registerECAC = array();
         $registerECAC['enterprise_id'] = $insertEnterprise['lastInsertId'];
         $registerECAC['competition_id'] = Zend_Registry::get('configDb')->competitionId;
         $registerECAC['category_award_id'] = $registerEnterpriseData['category_award_id'];
         $insertECAC = $modelEntCatAwardCompetition->createECAC($registerECAC);
         if (!$insertECAC['status']) {
             throw new Vtx_UserException($insertECAC['messageError']);
         }
         // 2.2 Insert Endereço da Presidente
         $registerAddressPresidentData['president_id'] = $insertPresident['lastInsertId'];
         $insertAddressPresident = $AddressPresident->createAddressPresident($registerAddressPresidentData);
         if (!$insertAddressPresident['status']) {
             throw new Vtx_UserException($insertAddressPresident['messageError']);
         }
         // 2.3 Programa do Presidente da Empresa
         if ($registerPresidentProgramData) {
             $presidentId = $insertPresident['lastInsertId'];
             $createPresidentProgram = $PresidentProgram->createPresidentProgramByPresidentId($registerPresidentProgramData, $presidentId);
             if (!$createPresidentProgram['status']) {
                 throw new Vtx_UserException($createPresidentProgram['messageError']);
             }
         }
         // 3.1 Insert Responsável pelo preenchimento - usuário do sistema
         if (isset($registerUserData['set_login_cpf']) and $registerUserData['set_login_cpf'] == '1') {
             $registerUserData['login'] = $registerUserData['cpf'];
         }
         $insertUser = $User->createUser($registerUserData);
         if (!$insertUser['status']) {
             throw new Vtx_UserException($insertUser['messageError']);
         }
         // 4.1 Insert Relação UserLocality
         $registerUserLocalityData['user_id'] = $insertUser['lastInsertId'];
         $registerUserLocalityData['enterprise_id'] = $insertEnterprise['lastInsertId'];
         $insertUserLocality = $UserLocality->createUserLocality($registerUserLocalityData);
         if (!$insertUserLocality['status']) {
             throw new Vtx_UserException($insertUserLocality['messageError']);
         }
         $enterpriseEmail = isset($registerEnterpriseData['email_default']) ? $registerEnterpriseData['email_default'] : '';
         $presidentEmail = isset($registerPresidentData['email']) ? $registerPresidentData['email'] : '';
         if ($enterpriseEmail != '') {
             // Envia email com login/senha pro responsavel pelo cadastro
             $this->sendMail($enterpriseEmail, $registerUserData['first_name'], $insertEnterprise['lastInsertId']);
             if ($enterpriseEmail != $presidentEmail) {
                 $this->sendMail($presidentEmail, $registerPresidentData['name'], $insertEnterprise['lastInsertId']);
             }
         }
         // 5.1 Insert User Role
         $Acl->setUserRole($insertUser['lastInsertId'], Zend_Registry::get('config')->acl->roleEnterpriseId);
         // 6.1 Log Cadastro da Empresa
         if (!$registerLogCadastro) {
             $registerLogCadastro['user_id_log'] = $insertUser['lastInsertId'];
         }
         $logCadastroEmpresa['user_id_log'] = $registerLogCadastro['user_id_log'];
         $logCadastroEmpresa['enterprise_id'] = $insertEnterprise['lastInsertId'];
         $logCadastroEmpresa['programa_id'] = Zend_Registry::get('configDb')->competitionId;
         $logCadastroEmpresa['acao'] = 'aceite';
         $insertlogCadastroEmpresa = $modelLogCadastroEmpresa->createLogCadastroEmpresa($logCadastroEmpresa);
         if (!$insertlogCadastroEmpresa['status']) {
             throw new Vtx_UserException($insertlogCadastroEmpresa['messageError']);
         }
         // end transaction externo
         Zend_Registry::get('db')->commit();
         return array('status' => true, 'lastInsertIdKey' => $insertEnterprise['lastInsertIdKey']);
         //throw new Vtx_UserException("Chegou aqui - gravacao ate o fim codigo");
     } catch (Vtx_UserException $e) {
         Zend_Registry::get('db')->rollBack();
         return array('status' => false, 'messageError' => $e->getMessage(), 'errorCode' => $e->getCode());
     } catch (Exception $e) {
         Zend_Registry::get('db')->rollBack();
         throw new Exception($e);
     }
 }