'doEdit', 'update' => 'doUpdate', 'switch' => 'doSwitch', 'assign' => 'doAssign', ); var $concat_form_title = false; function exec(&$Doc) { $this->Doc = &$Doc; $this->DBObj = SiteMap::getObj('SupportAccount/Profile/Profile.php', $this->Doc->SupportAccountAuth->getData('id')); $this->DBObj->supportData = $this->Doc->SupportAccountAuth->getData(); $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); } if ($this->isXmlHttpRequest()) { $this->actionMethod .= 'Ajax'; } } protected function callAction() { if (method_exists($this, $this->actionMethod)) { $this->{$this->actionMethod}(); } } function _bindFormFields($form) { //$form->addElement('header', 'header_personal_information', 'PERSONAL INFORMATION'); $gName = array(); $gName[] = $form->createElement('text', 'first_name', '*First Name ', array('size'=>25, 'class'=>'first_name')); $gName[] = $form->createElement('text', 'middle_initial', 'Middle Initial ', array('size'=>1, 'maxlength'=>1, 'class'=>'middle_initial')); $gName[] = $form->createElement('text', 'last_name', '*Last Name ', array('size'=>25, 'class'=>'last_name')); $form->addGroup($gName, 'gName', 'Name', ' ', false); $form->addGroupRule('gName', array( 'first_name'=>array( array('First Name is required', 'required'), array('First Name is required', 'required', null, 'client'), ), 'last_name'=>array( array('Last Name is required', 'required'), array('Last Name is required', 'required', null, 'client'), ) )); $phoneFormat = ' Format: (xxx) xxx-xxxx'; $this->formAddTitledPhone($form, 'primary_phone', 'Primary Phone #'); $this->formAddTitledPhone($form, 'secondary_phone', 'Secondary Phone #'); $form->addElement('extended_text', 'fax', 'Direct Fax Number', array('class'=>'titled_phone', 'onblur'=>'hidehint(this);', 'onfocus'=>'showhint(this);', 'onkeyup'=>"formatPhone(this);"), null, $phoneFormat); $this->formAddPhoneRule($form, array('fax')); $form->addElement('text', 'email', 'Email Address', array('class'=>'inp_email', 'size'=>80)); $form->addRuleRequired(array('email')); $form->addRule('email', 'Email Address (Web Site Login) is in wrong format', 'email'); $form->addRule('email', 'Email Address (Web Site Login) is in wrong format', 'email', null, 'client'); $form->addElement('extended_password', 'password', 'Web Site Password', array('class'=>'inp_password'), null, '  Note: Leave blank to use current'); $form->addElement('extended_password', 'confirm_password', 'Confirm Password', array('class'=>'inp_password')); $form->setConstants(array('password' => '', 'confirm_password' => '')); $ids_member = $this->Doc->SupportAccountAuth->getData('ids_member'); if (is_array($ids_member) && !empty($ids_member)) { foreach ($ids_member as $id=>$name) { $form->addElement('hidden', 'ids_member['.$id.']', $name); } } $form->addElement('static', 'static_member_grid_container', 'Authorized Agents', '
Send New Authorization Request'); $form->addElement('static', 'static_agents_invitations_grid_container', 'Agents Invitations', $this->renderAgentsInvitations($this->DBObj->getAgentsInvitations())); $form->addElement('static', 'static_my_requests_grid_container', 'My Requests', $this->renderMyRequests($this->DBObj->getMyRequests())); $this->Doc->addItemProp('JSs', 'js/support_account.js'); $this->Doc->addItemProp('initFuncsEx', array('name'=>'initSupportAccountForm', 'params'=>array($form->_attributes['id']))); $form->addElement('select', 'id_autologin_member', 'Autologin this Agent in next time', array(0=>'Select One') + (array)$ids_member); $form->addFormRule(array($this, 'validForm')); return $form; } function renderAgentsInvitations($list) { $html = ''; foreach ($list as $row) { $html .= ''.htmlspecialchars($row['full_name']).''; } if (!empty($html)) { $html = ''.$html.'
'; } else { $html = 'All invitations have been accepted'; } return $html; } function renderMyRequests($list) { $html = ''; foreach ($list as $row) { $html .= ''.htmlspecialchars($row['full_name']).''; } if (!empty($html)) { $html = ''.$html.'
'; } else { $html = 'All requests have been accepted'; } return $html; } function validForm($data) { $err = array(); if (!$this->DBObj->isUnique('email', $data['email'])){ $err['email'] = 'This email is already in use. Please use another one.'; } if ($data['password'] != $data['confirm_password']) { $err['password'] = 'Web Site Password and Confirm password entries do not match'; } return (empty($err))?true:$err; } function formAddTitledPhone(&$form, $elName, $label, $phoneFormat = ' Format: (xxx) xxx-xxxx', $regex = "/^\(\d{3}\)\s*\d{3}\s*-\s*\d{4}(\s.*)?$/") { return MemberGrid::formAddTitledPhone($form, $elName, $label, $phoneFormat, $regex); } function setFormTitle() { return false; } function doEdit() { $this->DBObj->initFromDB(); $form = $this->_getEditForm(); $form->setDefaults($this->DBObj->getData()); $this->renderForm($form); } function doUpdate() { $form = $this->_getEditForm(); if ($form->validate()){ $this->DBObj->initFromForm($form); $this->DBObj->update(); Session::setData($this->_getPage4SaveMessage(), 'msg', $this->DBObj->itemName.' updated'); $this->doBack(); }else { $this->renderForm($form); } return true; } function doSwitch() { $ids_member = $this->Doc->SupportAccountAuth->getData('ids_member'); if (!is_array($ids_member) || empty($ids_member)){ $this->doBack(); } $id_member = intval($_REQUEST['id_member']); if (!array_key_exists($id_member, $ids_member)) { $this->doBack(); } $memberData = $this->DBObj->getMemberById($id_member); if (!is_array($memberData) || empty($memberData)) { $this->doBack(); } $this->Doc->MemberAuth->logout(false); //$this->Doc->MemberAuth->DBObj->updateAccessCode($this->Doc->MemberAuth->getData('id'), null); $this->Doc->assign('member', null); $this->Doc->assign('id_member4select', $id_member); require_once('class/Session.php'); Session::setData($this->Doc->MemberAuth->ses_arr_name, 'login_to', BASE_URL.'/'.SiteMap::getAliasByItemType('Member/MyAccount')); $ret = $this->Doc->MemberAuth->login(array( 'member_login' => $memberData[$this->DBObj->login_field], 'member_password'=> $memberData[$this->DBObj->pass_field], ), array(), true, false); /* if ($ret) { require_once ('class/HTTP.php'); skHTTP::redirect(BASE_URL . '/account'); } */ $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>current($ret))); } function renderForm(&$form) { $form->setCancelType(''); $form->setSubmitTitle('Update'); $form->exec(); $this->Doc->addItemProp('JSs', 'js/format_phone.js'); } function doAssign() { $this->DBObj->initFromDB(); $requestData = $this->DBObj->getMemberSupportRequestById(intval($_REQUEST['id_member_request'])); if (!is_array($requestData) || empty($requestData) || $requestData['support_email'] != $this->Doc->SupportAccountAuth->getData('email')) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'Invalid Identifier')); return; } if ($requestData['authorized'] == 'y' && array_key_exists(intval($requestData['id_member']), $this->DBObj->supportData['ids_member'])) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'This request is already authorized.')); return; } $this->DBObj->_initTable(); $id_support_account = $this->Doc->SupportAccountAuth->getData('id'); $updateData = array( 'id_support_account' => $id_support_account, 'authorized' => 'y' ); require_once('class/DB/DBTable.php'); $MemberSupportRequest = new DBTable('MemberSupportRequest'); $MemberSupportRequest->update($updateData, 'id='.intval($requestData['id'])); $idsData = array_keys($this->DBObj->_data['ids_member']); $idsData[$requestData['id_member']] = $requestData['id_member']; $this->DBObj->updateIds($this->DBObj->tableNameDB.'2Member', 'id_member', $idsData); Session::setData($this->_getPage4SaveMessage(), 'msg', 'New Agent added to your agent list'); $this->doBack(); } }