'doAuthorize', 'insert' => 'doInsert', 'thanks' => 'doThanks', 'send_error'=> 'doSendError', ); function exec(&$Doc) { $this->Doc = &$Doc; $this->DBObj = SiteMap::getObj('SupportAccount/SupportAccount.php', $_REQUEST['id_request']); $this->initAction(); $this->callAction(); } protected 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); } } protected function callAction() { if (method_exists($this, $this->actionMethod)) { $this->{$this->actionMethod}(); } } function doAuthorize() { $this->DBObj->initFromDB(); $data = $this->DBObj->getData(); if (!is_array($data) || empty($data) || $data['request_email'] != $this->Doc->MemberAuth->getData('email')) { $this->Doc->addContent(array( 'tpl' => 'msg_error.tpl', 'text'=> 'Invalid identifier', )); return false; } if ($data['authorized'] == 'y') { $this->Doc->addContent(array( 'tpl' => 'msg.tpl', 'text'=> 'This request is already authorized.', )); return false; } $id_requested_member = $this->Doc->MemberAuth->getData('id'); $updateData = array( 'authorized' => 'y', 'id_requested_member' => $id_requested_member, ); $accountData = $this->DBObj->getMemberByEmail($data['email']); if (!is_array($accountData) || empty($accountData)) { $updateData['access_code'] = $this->DBObj->getUniqueAccessCode(); } else { $updateData['id_support_account'] = $accountData['id']; $this->DBObj->assignMember($accountData['id'], $id_requested_member); } $data = array_merge($data, $updateData); $this->DBObj->_initTable(); $this->DBObj->table->update($updateData, 'id='.intval($this->DBObj->id)); $ret = $this->sendEmail($data, $this->Doc->MemberAuth->getData(), (empty($accountData['id']))?'email.tpl':'email2registerd.tpl'); require_once('class/HTTP.php'); if (!$ret) { skHTTP::redirect(BASE_URL.'/'.CURR_PAGE_FULL.'?action=send_error'); } else { skHTTP::redirect(BASE_URL.'/'.CURR_PAGE_FULL.'?action=thanks'); } } function sendEmail($request, $member, $tpl) { require_once('class/Const.php'); Constant::set('DEBUG', false); $this->Doc->assign('request', $request); $this->Doc->assign('member', $member); $this->Doc->setMainTpl('SupportAccount/Authorize/'.$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('MNCAR.ORG. Your Support Account has been Authorized'); $mail->setHeader('X-Mailer', 'HTML Mime mail class'); return $mail->send(array($request['email'])); } function doThanks() { $this->Doc->addContent(array('tpl'=>'SupportAccount/Authorize/thanks.tpl')); } function doSendError() { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'Email Send Error')); } }