Skip to content
Snippets Groups Projects
Commit 62de9660 authored by Jared Hancock's avatar Jared Hancock
Browse files

oops: Fix page lookup equipment

parent b2e7da58
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ elseif ($thisclient) { ...@@ -37,7 +37,7 @@ elseif ($thisclient) {
// Existing client (with an account) updating profile // Existing client (with an account) updating profile
else { else {
$user = User::lookup($thisclient->getId()); $user = User::lookup($thisclient->getId());
$content = Page::lookup(Page::getIdByType('registration-thanks')); $content = Page::lookupByType('registration-thanks');
$inc = isset($_GET['confirmed']) $inc = isset($_GET['confirmed'])
? 'register.confirmed.inc.php' : 'profile.inc.php'; ? 'register.confirmed.inc.php' : 'profile.inc.php';
} }
...@@ -94,7 +94,7 @@ elseif ($_POST) { ...@@ -94,7 +94,7 @@ elseif ($_POST) {
if (!$errors) { if (!$errors) {
switch ($_POST['do']) { switch ($_POST['do']) {
case 'create': case 'create':
$content = Page::lookup(Page::getIdByType('registration-confirm')); $content = Page::lookupByType('registration-confirm');
$inc = 'register.confirm.inc.php'; $inc = 'register.confirm.inc.php';
$acct->sendConfirmEmail(); $acct->sendConfirmEmail();
break; break;
......
...@@ -157,7 +157,7 @@ class ContentAjaxAPI extends AjaxController { ...@@ -157,7 +157,7 @@ class ContentAjaxAPI extends AjaxController {
$langs = $cfg->getSecondaryLanguages(); $langs = $cfg->getSecondaryLanguages();
$content = Page::lookup(Page::getIdByType($type, $lang)); $content = Page::lookupByType($type, $lang);
include STAFFINC_DIR . 'templates/content-manage.tmpl.php'; include STAFFINC_DIR . 'templates/content-manage.tmpl.php';
} }
......
...@@ -55,7 +55,7 @@ abstract class TicketUser { ...@@ -55,7 +55,7 @@ abstract class TicketUser {
if (!($ticket = $this->getTicket()) if (!($ticket = $this->getTicket())
|| !($email = $ost->getConfig()->getDefaultEmail()) || !($email = $ost->getConfig()->getDefaultEmail())
|| !($content = Page::lookup(Page::getIdByType('access-link')))) || !($content = Page::lookupByType('access-link')))
return; return;
$vars = array( $vars = array(
......
...@@ -196,6 +196,18 @@ class Page extends VerySimpleModel { ...@@ -196,6 +196,18 @@ class Page extends VerySimpleModel {
return self::getActivePages(array('type' => 'thank-you')); return self::getActivePages(array('type' => 'thank-you'));
} }
static function lookup($id, $lang=false) {
try {
$qs = self::objects()->filter(array('id'=>$id));
if ($lang)
$qs = $qs->filter(array('lang'=>$lang));
return $qs->one();
}
catch (DoesNotExist $ex) {
return null;
}
}
static function getIdByName($name, $lang=false) { static function getIdByName($name, $lang=false) {
try { try {
$qs = self::objects()->filter(array('name'=>$name)) $qs = self::objects()->filter(array('name'=>$name))
...@@ -210,14 +222,12 @@ class Page extends VerySimpleModel { ...@@ -210,14 +222,12 @@ class Page extends VerySimpleModel {
} }
} }
static function getIdByType($type, $lang=false) { static function lookupByType($type, $lang=false) {
try { try {
$qs = self::objects()->filter(array('type'=>$type)) $qs = self::objects()->filter(array('type'=>$type));
->values_flat('id');
if ($lang) if ($lang)
$qs = $qs->filter(array('lang'=>$lang)); $qs = $qs->filter(array('lang'=>$lang));
list($id) = $qs->one(); return $qs->one();
return $id;
} }
catch (DoesNotExist $ex) { catch (DoesNotExist $ex) {
return null; return null;
......
...@@ -687,7 +687,7 @@ class Staff extends AuthenticatedUser { ...@@ -687,7 +687,7 @@ class Staff extends AuthenticatedUser {
function sendResetEmail($template='pwreset-staff') { function sendResetEmail($template='pwreset-staff') {
global $ost, $cfg; global $ost, $cfg;
$content = Page::lookup(Page::getIdByType($template)); $content = Page::lookupByType($template);
$token = Misc::randCode(48); // 290-bits $token = Misc::randCode(48); // 290-bits
if (!$content) if (!$content)
......
...@@ -941,7 +941,7 @@ class UserAccount extends UserAccountModel { ...@@ -941,7 +941,7 @@ class UserAccount extends UserAccountModel {
$token = Misc::randCode(48); // 290-bits $token = Misc::randCode(48); // 290-bits
$email = $cfg->getDefaultEmail(); $email = $cfg->getDefaultEmail();
$content = Page::lookup(Page::getIdByType($template)); $content = Page::lookupByType($template);
if (!$email || !$content) if (!$email || !$content)
return new Error(sprintf(_S('%s: Unable to retrieve template'), return new Error(sprintf(_S('%s: Unable to retrieve template'),
......
...@@ -4,7 +4,7 @@ if(!defined('OSTCLIENTINC')) die('Access Denied'); ...@@ -4,7 +4,7 @@ if(!defined('OSTCLIENTINC')) die('Access Denied');
$email=Format::input($_POST['luser']?:$_GET['e']); $email=Format::input($_POST['luser']?:$_GET['e']);
$passwd=Format::input($_POST['lpasswd']?:$_GET['t']); $passwd=Format::input($_POST['lpasswd']?:$_GET['t']);
$content = Page::lookup(Page::getIdByType('banner-client')); $content = Page::lookupByType('banner-client');
if ($content) { if ($content) {
list($title, $body) = $ost->replaceTemplateVariables( list($title, $body) = $ost->replaceTemplateVariables(
......
...@@ -23,7 +23,7 @@ TextDomain::configureForUser(); ...@@ -23,7 +23,7 @@ TextDomain::configureForUser();
require_once(INCLUDE_DIR.'class.staff.php'); require_once(INCLUDE_DIR.'class.staff.php');
require_once(INCLUDE_DIR.'class.csrf.php'); require_once(INCLUDE_DIR.'class.csrf.php');
$content = Page::lookup(Page::getIdByType('banner-staff')); $content = Page::lookupByType('banner-staff');
$dest = $_SESSION['_staff']['auth']['dest']; $dest = $_SESSION['_staff']['auth']['dest'];
$msg = $_SESSION['_staff']['auth']['msg']; $msg = $_SESSION['_staff']['auth']['msg'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment