diff --git a/include/class.config.php b/include/class.config.php index b420a7325b7ab16312769ca7452fa47aad905c97..5d297e8c528e94cd1bdd1b4fb57c879fd7a02801 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -368,6 +368,51 @@ class OsticketConfig extends Config { 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() { return $this->get('max_open_tickets'); } @@ -641,6 +686,9 @@ class OsticketConfig extends Config { case 'emails': return $this->updateEmailsSettings($vars, $errors); break; + case 'pages': + return $this->updatePagesSettings($vars, $errors); + break; case 'autoresp': return $this->updateAutoresponderSettings($vars, $errors); break; @@ -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) { if($errors) return false; diff --git a/include/staff/settings-pages.inc.php b/include/staff/settings-pages.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..c9c91343c153af42b048b6b6da121d5bc47f37cb --- /dev/null +++ b/include/staff/settings-pages.inc.php @@ -0,0 +1,73 @@ +<?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="">— Select Landing Page —</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> <font class="error">* <?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="">— Select Offline Page —</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> <font class="error">* <?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="">— Select Thank-You Page —</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> <font class="error">* <?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> diff --git a/scp/settings.php b/scp/settings.php index 2b30ced16a154a9a6976206045a801f2ae5efe68..9c8f70ac43d5cfd2b158334f690fd21529bbecaa 100644 --- a/scp/settings.php +++ b/scp/settings.php @@ -19,6 +19,7 @@ $settingOptions=array( 'system' => 'System Settings', 'tickets' => 'Ticket Settings and Options', 'emails' => 'Email Settings', + 'pages' => 'Site Pages', 'kb' => 'Knowledgebase Settings', 'autoresp' => 'Autoresponder Settings', 'alerts' => 'Alerts and Notices Settings');