function actionIndex($params = '') { $objSearch = new SearchModel(); $searchQuery = !empty($params['searchQuery']) ? $params['searchQuery'] : ''; $searchOptions = array(); $searchResults = false; // load templates $objLayout = new LayoutModel(); $objTemplate = new TemplatesModel(); $layoutInfo = $objLayout->loadLayout(); $template = $objTemplate->loadTemplateFromKeyname('search'); // doing search? if (!empty($searchQuery)) { // add search options if (!empty($params['searchForType'])) { foreach ($params['searchForType'] as $typeSearch) { $searchOptions[] = array('type' => 'type', 'value' => $typeSearch); } } // do search $searchResults = $objSearch->performSearch($searchQuery, $searchOptions); } // assign to template $this->view->assign('searchQuery', $searchQuery); $this->view->assign('searchOptions', $searchOptions); $this->view->assign('searchResults', $searchResults); // render template $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content'])); $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar'])); $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code'])); $this->finish(); }
/** * Smarty {form} function plugin * * Type: function<br> * Name: form<br> * Purpose: generates form from database<br> * @author Nathan Gardner <*****@*****.**> */ function smarty_function_form($localparams, &$smarty) { global $params; if (!empty($localparams['identifier'])) { $objForm = new FormModel(); $objAuth = Authentication::getInstance(); $objTemplate = new TemplatesModel(); $objUser = new UserModel($objAuth->user_id); $userInfo = $objUser->getInfo(); $form_id = $objForm->getFormId($localparams['identifier']); if ($form_id) { $formInfo = $objForm->loadForm($form_id); $templateInfo = $objTemplate->loadTemplateFromKeyname('form'); // assign values if already submitted if (!empty($params['formSubmit']['fields']) && !empty($formInfo['fields'])) { foreach ($formInfo['fields'] as &$formField) { foreach ($params['formSubmit']['fields'] as $submittedId => $submittedValue) { if ($formField['id'] == $submittedId) { if ($formField['type'] == 'checkbox' || $formField['type'] == 'radio') { $formField['checked'] = 'checked'; } else { $formField['value'] = $submittedValue; } break; } } } } // assign error flag and message if invalid if (!empty($params['formErrors']) && !empty($formInfo['fields'])) { foreach ($params['formErrors'] as $formError) { foreach ($formInfo['fields'] as &$formField) { if ($formError['field_id'] == $formField['id']) { $formField['hasError'] = true; $formField['errorMsg'] = $formError['errorMsg']; break; } } } } // assign var to template if (!empty($params['formSubmitted'])) { $smarty->assign('formSubmitted', 1); } if (!empty($params['formErrors'])) { $smarty->assign('formErrors', $params['formErrors']); } $smarty->assign('formInfo', $formInfo); $output = $smarty->fetch('fromstring:' . $templateInfo['content']); } else { return 'Unknown form identifier'; } } else { return 'Must pass an identifier'; } return $output; }
function sendWebcastRegistrationAdmin($orderInfo) { $objEmailer = new Emailer(); $objLayout = new LayoutModel(); $objTemplate = new TemplatesModel(); $objSettings = Settings::getInstance(); $adminEmail = $objSettings->getEntry('admin', 'admin-email'); $layoutInfo = $objLayout->loadLayout(28); $template = $objTemplate->loadTemplateFromKeyname('email-webcastregistration-admin'); $this->view->assign('orderInfo', $orderInfo); $objEmailer->setFrom('*****@*****.**'); $objEmailer->addTo($adminEmail); $objEmailer->setSubject('WEBCAST PURCHASE'); // render template $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content'])); $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar'])); $objEmailer->setBody($this->view->fetch('fromstring:' . $layoutInfo['code']), true); $objEmailer->sendMail(); return true; }
function actionChangePassword($params = '') { $this->objAuthentication->requiresAccount(); $errorMsg = false; $changedpassword = false; if (!empty($params['changepassword'])) { $objUser = new UserModel(); if (!empty($params['orignal_pw']) && !empty($params['password']) && !empty($params['password2'])) { // verify old password $passwordMatch = $objUser->testPassword($this->objAuthentication->user_id, $params['orignal_pw']); if ($passwordMatch) { $objValidation = new Validator(); $objValidation->validatePassword($params['password']); $objValidation->passwordsMatch($params['password'], $params['password2']); if ($objValidation->hasError) { $errorMsg = $objValidation->getError(); if (is_array($errorMsg)) { $errorMsg = implode(', ', $errorMsg); } } else { $saveData = array(); $saveData['id'] = $this->objAuthentication->user_id; $saveData['password'] = $this->objAuthentication->encryptPassword($params['password']); $changedpassword = $objUser->save($saveData, 'users'); if ($changedpassword) { $objEmailer = new EmailSender(); $objEmailer->sendUserChangePassword($this->objAuthentication->user_id); } else { $errorMsg = 'Unable to change password.'; } } } else { $errorMsg = 'Current password incorrect.'; } } else { $errorMsg = 'Current password and new password are required.'; } } $objLayout = new LayoutModel(); $objTemplate = new TemplatesModel(); $layoutInfo = $objLayout->loadLayout(); $template = $objTemplate->loadTemplateFromKeyname('user-changepassword'); $this->view->assign('errorMsg', $errorMsg); $this->view->assign('changedpassword', $changedpassword); $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content'])); $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar'])); $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar'])); $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code'])); $this->finish(); }