Skip to content
Snippets Groups Projects
Commit 2fcdd56a authored by Peter Rotich's avatar Peter Rotich Committed by Jared Hancock
Browse files

Add ability set default (required) pages

parent 76bedb10
No related branches found
No related tags found
No related merge requests found
...@@ -368,6 +368,51 @@ class OsticketConfig extends Config { ...@@ -368,6 +368,51 @@ class OsticketConfig extends Config {
return $this->defaultTemplate; return $this->defaultTemplate;
} }
function getLandingPageId() {
return $this->get('landing_page_id');
}
function getLandingPage() {
if(!$this->landing_page && $this->getLandingPageId())
$this->landing_page = Page::lookup($this->getLandingPageId());
return $this->landing_page;
}
function getOfflinePageId() {
return $this->get('offline_page_id');
}
function getOfflinePage() {
if(!$this->offline_page && $this->getOfflinePageId())
$this->offline_page = Page::lookup($this->getOfflinePageId());
return $this->offline_page;
}
function getThankYouPageId() {
return $this->get('thank-you_page_id');
}
function getThankYouPage() {
if(!$this->thankyou_page && $this->getThankYouPageId())
$this->thankyou_page = Page::lookup($this->getThankYouPageId());
return $this->thankyou_page;
}
function getDefaultPages() {
/* Array of ids...as opposed to objects */
return array(
$this->getLandingPageId(),
$this->getOfflinePageId(),
$this->getThankYouPageId(),
);
}
function getMaxOpenTickets() { function getMaxOpenTickets() {
return $this->get('max_open_tickets'); return $this->get('max_open_tickets');
} }
...@@ -641,6 +686,9 @@ class OsticketConfig extends Config { ...@@ -641,6 +686,9 @@ class OsticketConfig extends Config {
case 'emails': case 'emails':
return $this->updateEmailsSettings($vars, $errors); return $this->updateEmailsSettings($vars, $errors);
break; break;
case 'pages':
return $this->updatePagesSettings($vars, $errors);
break;
case 'autoresp': case 'autoresp':
return $this->updateAutoresponderSettings($vars, $errors); return $this->updateAutoresponderSettings($vars, $errors);
break; break;
...@@ -804,6 +852,23 @@ class OsticketConfig extends Config { ...@@ -804,6 +852,23 @@ class OsticketConfig extends Config {
)); ));
} }
function updatePagesSettings($vars, &$errors) {
$f=array();
$f['landing_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required');
$f['offline_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required');
$f['thank-you_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required');
if(!Validator::process($f, $vars, $errors) || $errors)
return false;
return $this->updateAll(array(
'landing_page_id' => $vars['landing_page_id'],
'offline_page_id' => $vars['offline_page_id'],
'thank-you_page_id' => $vars['thank-you_page_id'],
));
}
function updateAutoresponderSettings($vars, &$errors) { function updateAutoresponderSettings($vars, &$errors) {
if($errors) return false; if($errors) return false;
......
<?php
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config) die('Access Denied');
$pages = Page::getPages();
?>
<h2>Site Pages</h2>
<form action="settings.php?t=pages" method="post" id="save">
<?php csrf_token(); ?>
<input type="hidden" name="t" value="pages" >
<table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4>Pages</h4>
<em>To edit or add new pages go to <a href="pages">Manage > Site Pages</a></em>
</th>
</tr>
</thead>
<tbody>
<tr>
<td width="220" class="required">Default Landing Page:</td>
<td>
<select name="landing_page_id">
<option value="">&mdash; Select Landing Page &mdash;</option>
<?php
foreach($pages as $page) {
if(strcasecmp($page->getType(), 'landing')) continue;
echo sprintf('<option value="%d" %s>%s</option>',
$page->getId(),
($config['landing_page_id']==$page->getId())?'selected="selected"':'',
$page->getName());
} ?>
</select>&nbsp;<font class="error">*&nbsp;<?php echo $errors['landing_page_id']; ?></font>
</td>
</tr>
<tr>
<td width="220" class="required">Default Offline Page:</td>
<td>
<select name="offline_page_id">
<option value="">&mdash; Select Offline Page &mdash;</option>
<?php
foreach($pages as $page) {
if(strcasecmp($page->getType(), 'offline')) continue;
echo sprintf('<option value="%d" %s>%s</option>',
$page->getId(),
($config['offline_page_id']==$page->getId())?'selected="selected"':'',
$page->getName());
} ?>
</select>&nbsp;<font class="error">*&nbsp;<?php echo $errors['offline_page_id']; ?></font>
</td>
</tr>
<tr>
<td width="220" class="required">Default Thank-You Page:</td>
<td>
<select name="thank-you_page_id">
<option value="">&mdash; Select Thank-You Page &mdash;</option>
<?php
foreach($pages as $page) {
if(strcasecmp($page->getType(), 'thank-you')) continue;
echo sprintf('<option value="%d" %s>%s</option>',
$page->getId(),
($config['thank-you_page_id']==$page->getId())?'selected="selected"':'',
$page->getName());
} ?>
</select>&nbsp;<font class="error">*&nbsp;<?php echo $errors['thank-you_page_id']; ?></font>
</td>
</tr>
</tbody>
</table>
<p style="padding-left:250px;">
<input class="button" type="submit" name="submit" value="Save Changes">
<input class="button" type="reset" name="reset" value="Reset Changes">
</p>
</form>
...@@ -19,6 +19,7 @@ $settingOptions=array( ...@@ -19,6 +19,7 @@ $settingOptions=array(
'system' => 'System Settings', 'system' => 'System Settings',
'tickets' => 'Ticket Settings and Options', 'tickets' => 'Ticket Settings and Options',
'emails' => 'Email Settings', 'emails' => 'Email Settings',
'pages' => 'Site Pages',
'kb' => 'Knowledgebase Settings', 'kb' => 'Knowledgebase Settings',
'autoresp' => 'Autoresponder Settings', 'autoresp' => 'Autoresponder Settings',
'alerts' => 'Alerts and Notices Settings'); 'alerts' => 'Alerts and Notices Settings');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment