Doc = &$Doc; $this->DBObj = SiteMap::getObj('Member/SupportRequest/SupportRequest.php'); $this->access_code = $_GET['access_code']; // $_GET['access_code'] - значення брати з $_GET масиву, тому що в $_COOKIE лежить змінна з такою ж назвою $this->initAction(); $this->callAction(); } function validForm($data) { $err = array(); if (!$this->DBObj->isUniqueMemberEmail($data['email'])){ $err['email'] = 'Email must be unique'; } if ($data['password'] != $data['confirm_password']) { $err['password'] = 'Web Site Password and Confirm password entries do not match'; } return (empty($err))?true:$err; } function doNew() { $data = $this->DBObj->getFromDBByAccessCode($this->access_code); if (!is_array($data) || empty($data)) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'Invalid Access Code')); return; } $data['email'] = $data['support_email']; $form = $this->_getNewForm(); $form->setDefaults($data); $this->renderForm($form); $this->setBackUrl(BASE_URL.'/'.CURR_PAGE.'?action=thanks'); } function doInsert() { $data = $this->DBObj->getFromDBByAccessCode($this->access_code); if (!is_array($data) || empty($data)) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'Invalid Access Code')); return; } $form = $this->_getNewForm(); if ($form->validate()) { $this->DBObj->initFromForm($form ); $this->DBObj->_data['id_location']=$this->DBObj->db->queryOne('SELECT id_location FROM mn_Member WHERE id='.(int)$data['id_member']); // vdie('responce',$data,$this->DBObj->_data); $id = $this->DBObj->register(); $this->DBObj->_initTable(); $updateData = array( 'access_code' => null, 'authorized' => 'y', 'id_support_account' => $id ); $this->DBObj->table->update($updateData, 'id='.intval($data['id'])); if (true !== ($error = $this->DBObj->assignMember($id, $data['id_member']))) { // } require_once('class/Session.php'); $url = Session::getData($this->Doc->MemberAuth->ses_arr_name, 'login_to'); if (empty($url)) { Session::setData($this->Doc->MemberAuth->ses_arr_name, 'login_to', BASE_URL); } $this->sendEmail($data, $data['support_email'], 'MNCAR.ORG. Support Account Registration Complete', 'email_registration_complete.tpl'); $ret = $this->Doc->MemberAuth->login(array( 'member_login'=>$this->DBObj->getData('email'), 'member_password'=>$this->DBObj->getData('password'), )); } else { $this->renderForm($form); } return true; } }