'doNew', 'insert' => 'doInsert', 'verify' => 'doVerify', 'checkemail' => 'doCheckEmail', ); function initAction() { if (empty($this->action)) { if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) { $this->action= $_REQUEST['action']; } else { $this->action = $this->defaultAction; } } if (key_exists($this->action, $this->actions)){ $this->actionMethod = $this->actions[$this->action]; } else { $this->action = key($this->actions); $this->actionMethod = current($this->actions); } if ($this->isXmlHttpRequest()) { $this->actionMethod .= 'Ajax'; } } function exec(&$Doc) { $this->Doc = &$Doc; $this->DBObj = SiteMap::getObj('Member/Activation/Activation.php'); $this->initAction(); if (method_exists($this, $this->actionMethod)) { $function = $this->actionMethod; $this->$function(); } else { exit; } } function setFormTitle(&$form, $title) { return false; } function _getBaseForm($method = 'get') { require_once 'class/Form/Form.class.php'; $form = new Form($this->Doc, 'form_'.strtolower(get_class($this->DBObj)), $method, '', '_self', array('class'=>'form form_'.strtolower(get_class($this->DBObj)))); return $form; } function _bindFormFields($form) { $form->addElement('text', 'email', 'Email', array('style'=>'width:400px')); $form->addRuleRequired(array('email')); $form->addRule('email', 'Email is in wrong format', 'email'); $form->addRule('email', 'Email is in wrong format', 'email', null, 'client'); $form->addFormRule(array($this, 'validForm')); return $form; } function doNew() { $form = $this->_getNewForm(); $this->renderForm($form); } function validForm($data) { $err = array(); $memberData = $this->DBObj->getMemberByEmail($data['email']); if (!is_array($memberData) || empty($memberData)) { $err['email'] = 'We are sorry, but we do not have an account with that email address in our system. '. 'Please try another email address or contact MNCAR to discuss your membership status'; } else if (true !== Member::validStatus($memberData)) { $err['email'] = ' Your account is not active (or pending) in our system. ' . '
Please contact us for more information.


'; } return (empty($err))?true:$err; } function doInsert() { $form = $this->_getNewForm(); if ($form->validate()){ require_once('class/HTTP.php'); $this->DBObj->initFromForm($form); $memberData = $this->DBObj->getMemberByEmail($this->DBObj->getData('email')); if ($memberData['email_verified'] == 'y') { if ($memberData['info_verified'] == 'y') { $loginAlias = SiteMap::getAliasByItemType('Member/Login'); Session::setData($loginAlias, 'msg', 'That email address has already been activated. Please login.'); skHTTP::redirect(BASE_URL.'/'.$loginAlias.'?hide_content'); } } $this->id = (int)$memberData['id']; $memberData['activation_code'] = md5($memberData['email'].time()); $this->DBObj->_initTable(); $this->DBObj->table->update(array('activation_code'=>$memberData['activation_code']), 'id='.$this->DBObj->db->quote($memberData['id'], 'integer')); $memberData['link'] = array( 'activation'=>BASE_URL.'/'.SiteMap::GetAliasByItemType('Member/Activation/Email'), 'info'=>BASE_URL.'/'.SiteMap::GetAliasByItem('HTMLBlock/Show', 'account/activation/info.html') ); $ret = $this->sendEmail($memberData); if ($ret) { if (isset($_REQUEST['resend'])){ Session::setData($this->_getPage4SaveMessage(), 'msg', 'Email has been resent successfully. '); } } else { Session::setData($this->_getPage4SaveMessage(), 'error', 'Email send error.'); } skHTTP::redirect(BASE_URL.'/'.CURR_PAGE.'?action=checkemail&email='.$memberData['email']); }else { $this->renderForm($form); } return true; } function renderForm(&$form) { $this->Doc->content['ITEMS'] = array(); $form->return_form_arr = true; $form->setRendType(FORM_RENDERER_ARRAY_SMARTY); $form->setTpl(SiteMap::getPath('Member/tpl/Activation/email_verification_form.tpl')); $form->setSubmitTitle('Submit'); $form->setCancelType(''); $item = $form->exec(); $this->Doc->addContent($item); } function sendEmail($data) { require_once('class/Const.php'); Constant::set('DEBUG', false); $this->Doc->assign('item', $data); $this->Doc->setMainTpl('Member/Activation/email.tpl'); $html = $this->Doc->fetch(); require_once ('lib/htmlMimeMail/htmlMimeMail.php'); $mail = new htmlMimeMail(); $mail->setHtml($html); require_once('app/Settings/Settings.php'); $mail->setFrom(Settings::get('admin_email_from')); $mail->setSubject('New MNCAR Website: Activate your Account!'); $mail->setHeader('X-Mailer', 'HTML Mime mail class'); return $mail->send(array($data['email'])); } function doCheckEmail() { $item = $this->DBObj->getMemberByEmail($_REQUEST['email']); $item['tpl'] = 'Member/Activation/check_email.tpl'; $this->Doc->addContent($item); } function doVerify() { $activation_code = strval(@$_REQUEST['activation_code']); $ret = $this->DBObj->verifyEmail($activation_code); if (is_string($ret)) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>$ret)); return; } require_once('class/HTTP.php'); skHTTP::redirect(BASE_URL.'/'.SiteMap::getAliasByItemType('Member/Activation/Account').'?activation_code='.$ret['activation_code']); } }