diff --git a/include/class.company.php b/include/class.company.php new file mode 100644 index 0000000000000000000000000000000000000000..5122239f238b67064ee8c9e5655d2abb0172943d --- /dev/null +++ b/include/class.company.php @@ -0,0 +1,77 @@ +<?php +/********************************************************************* + class.company.php + + Company information + + Peter Rotich <peter@osticket.com> + Jared Hancock <jared@osticket.com> + Copyright (c) 2006-2013 osTicket + http://www.osticket.com + + Released under the GNU General Public License WITHOUT ANY WARRANTY. + See LICENSE.TXT for details. + + vim: expandtab sw=4 ts=4 sts=4: +**********************************************************************/ +require_once(INCLUDE_DIR.'class.forms.php'); +require_once(INCLUDE_DIR.'class.dynamic_forms.php'); + +class Company { + var $form; + var $entry; + + function getForm() { + if (!isset($this->form)) { + // Look for the entry first + if ($this->form = DynamicFormEntry::lookup(array('object_type'=>'C'))) { + return $this->form; + } + // Make sure the form is in the database + elseif (!($this->form = DynamicForm::lookup(array('type'=>'C')))) { + $this->__loadDefaultForm(); + return $this->getForm(); + } + // Create an entry to be saved later + $this->form = $this->form->instanciate(); + $this->form->object_type = 'C'; + } + return $this->form; + } + + function getVar($name) { + if ($info = $this->getInfo()) { + $name = mb_strtolower($name); + if (isset($info[$name])) + return $info[$name]; + } + } + + function asVar() { + return $this->getVar('name'); + } + + function getInfo() { + return $this->getForm()->getClean(); + } + + /** + * Auto-installer. Necessary for 1.8 users between the RC1 release and + * the stable release who don't have the form in their database because + * it wan't in the yaml file for installation or upgrade. + */ + function __loadDefaultForm() { + require_once(INCLUDE_DIR.'class.i18n.php'); + + $i18n = new Internationalization(); + $tpl = $i18n->getTemplate('form.yaml'); + foreach ($tpl->getData() as $f) { + if ($f['type'] == 'C') { + $form = DynamicForm::create($f); + $form->save(); + break; + } + } + } +} +?> diff --git a/include/class.config.php b/include/class.config.php index e692adb2f04a4c6215f22f89ef08efb272a9f7f7..ed98ec0e439594066699dd18533fa77140c61970 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -934,6 +934,7 @@ class OsticketConfig extends Config { } function updatePagesSettings($vars, &$errors) { + global $ost; $f=array(); $f['landing_page_id'] = array('type'=>'int', 'required'=>1, 'error'=>'required'); @@ -951,9 +952,16 @@ class OsticketConfig extends Config { $errors['logo'] = 'Unable to upload logo image. '.$error; } + $company = $ost->company; + $company_form = $company->getForm(); + if (!$company_form->isValid()) + $errors += $company_form->errors(); + if(!Validator::process($f, $vars, $errors) || $errors) return false; + $company_form->save(); + if (isset($vars['delete-logo'])) foreach ($vars['delete-logo'] as $id) if (($vars['selected-logo'] != $id) diff --git a/include/class.nav.php b/include/class.nav.php index 9dc4a79f25a31ff1d9f7aea5954d6f0abd22847c..8cb8e5bb83e68bab152d75c287537b35c8d17ded 100644 --- a/include/class.nav.php +++ b/include/class.nav.php @@ -194,10 +194,10 @@ class AdminNav extends StaffNav{ $subnav[]=array('desc'=>'Information','href'=>'system.php','iconclass'=>'preferences'); break; case 'settings': - $subnav[]=array('desc'=>'System Preferences','href'=>'settings.php?t=system','iconclass'=>'preferences'); + $subnav[]=array('desc'=>'Company','href'=>'settings.php?t=pages','iconclass'=>'pages'); + $subnav[]=array('desc'=>'System','href'=>'settings.php?t=system','iconclass'=>'preferences'); $subnav[]=array('desc'=>'Tickets','href'=>'settings.php?t=tickets','iconclass'=>'ticket-settings'); $subnav[]=array('desc'=>'Emails','href'=>'settings.php?t=emails','iconclass'=>'email-settings'); - $subnav[]=array('desc'=>'Pages','href'=>'settings.php?t=pages','iconclass'=>'pages'); $subnav[]=array('desc'=>'Knowledgebase','href'=>'settings.php?t=kb','iconclass'=>'kb-settings'); $subnav[]=array('desc'=>'Autoresponder','href'=>'settings.php?t=autoresp','iconclass'=>'email-autoresponders'); $subnav[]=array('desc'=>'Alerts & Notices','href'=>'settings.php?t=alerts','iconclass'=>'alert-settings'); diff --git a/include/class.osticket.php b/include/class.osticket.php index 10f16bf95c370273799e0c5dc85b063671a07db1..839d36e4bb39f61499efe7e5917d1b04719a2576 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -45,16 +45,20 @@ class osTicket { var $config; var $session; var $csrf; + var $company; function osTicket() { require_once(INCLUDE_DIR.'class.config.php'); //Config helper + require_once(INCLUDE_DIR.'class.company.php'); $this->session = osTicketSession::start(SESSION_TTL); // start DB based session $this->config = new OsticketConfig(); $this->csrf = new CSRF('__CSRFToken__'); + + $this->company = new Company(); } function isSystemOnline() { @@ -148,7 +152,8 @@ class osTicket { $replacer = new VariableReplacer(); $replacer->assign(array_merge($vars, - array('url' => $this->getConfig()->getBaseUrl()) + array('url' => $this->getConfig()->getBaseUrl(), + 'company' => $this->company) )); return $replacer->replaceVars($input); diff --git a/include/i18n/en_US/form.yaml b/include/i18n/en_US/form.yaml index 69b3ae30b0d0af5afd2df0dd0f25a2a0c1ba4482..fe37e3bc703da7db28d4fbacc9eff75478b41e82 100644 --- a/include/i18n/en_US/form.yaml +++ b/include/i18n/en_US/form.yaml @@ -103,3 +103,45 @@ private: true edit_mask: 3 sort: 3 + +- type: C # notrans + title: Company Information + instructions: Details available in email templates + deletable: false + fields: + - type: text # notrans + name: name # notrans + label: Company Name + required: true + sort: 1 + edit_mask: 3 + configuration: + size: 40 + length: 64 + + - type: text # notrans + name: website # notrans + label: Website + sort: 2 + configuration: + size: 40 + length: 64 + + - type: phone # notrans + name: phone # notrans + label: Phone Number + required: false + sort: 3 + configuration: + ext: false + + - type: memo # notrans + name: address + label: Address + required: false + sort: 4 + configuration: + rows: 2 + cols: 40 + html: false + diff --git a/include/i18n/en_US/templates/email/message.autoresp.yaml b/include/i18n/en_US/templates/email/message.autoresp.yaml index a4603bb2a89970b95ba3843a0ee9c6d5d82d046f..30c641de0f74048f297333de499197865c7a2dbd 100644 --- a/include/i18n/en_US/templates/email/message.autoresp.yaml +++ b/include/i18n/en_US/templates/email/message.autoresp.yaml @@ -20,7 +20,7 @@ body: | <br> <br> <div style="color: rgb(127, 127, 127); "> - Your Company Name Team,<br> + Your %{company.name} Team,<br> %{signature} </div> <hr> diff --git a/include/i18n/en_US/templates/email/ticket.autoreply.yaml b/include/i18n/en_US/templates/email/ticket.autoreply.yaml index c4817b8b91200d93a6b578d78ba32210eadc79cd..e50551566ac31ec72311dcd584fe70bde5bfc467 100644 --- a/include/i18n/en_US/templates/email/ticket.autoreply.yaml +++ b/include/i18n/en_US/templates/email/ticket.autoreply.yaml @@ -37,7 +37,7 @@ body: | %{response} <br> <br> - <div style="color: rgb(127, 127, 127);">Your Company Name Team,<br> + <div style="color: rgb(127, 127, 127);">Your %{company.name} Team,<br> %{signature}</div> <hr> <div style="color: rgb(127, 127, 127); font-size: small; text-align: diff --git a/include/i18n/en_US/templates/email/ticket.autoresp.yaml b/include/i18n/en_US/templates/email/ticket.autoresp.yaml index 98e48c1248663acea6d6e2d7370bd16b39f56f0d..ebdfde6f106bed221ff5ebe44af66f4456dea58f 100644 --- a/include/i18n/en_US/templates/email/ticket.autoresp.yaml +++ b/include/i18n/en_US/templates/email/ticket.autoresp.yaml @@ -43,11 +43,11 @@ body: | progress online</a>. <br> <br> - Your Company Name Team,<br> + Your %{company.name} Team,<br> %{signature} </td> <td style="vertical-align: top; padding-top: 12pt;"> - <span style="color: rgb(127, 127, 127); ">Company Name<br/> + <span style="color: rgb(127, 127, 127); ">%{company.name}<br/> %{signature}</span> <br> <br> diff --git a/include/i18n/en_US/templates/email/ticket.notice.yaml b/include/i18n/en_US/templates/email/ticket.notice.yaml index ba460d3aadb3148a6fe3a502e2de05a7e713c1f2..530f32a1f78fb33bab55b6b7b2942ffdaa798d73 100644 --- a/include/i18n/en_US/templates/email/ticket.notice.yaml +++ b/include/i18n/en_US/templates/email/ticket.notice.yaml @@ -41,7 +41,7 @@ body: | <br> <br> <div style="color: rgb(127, 127, 127);"> - Your Company Name Team,<br> + Your %{company.name} Team,<br> %{signature}</div> <hr> <div style="color: rgb(127, 127, 127); font-size: small; "><em>If you diff --git a/include/i18n/en_US/templates/email/ticket.reply.yaml b/include/i18n/en_US/templates/email/ticket.reply.yaml index d32259c8b39b5063dd083131d684c1244af5e1a0..c576a720945eb7b490132aa8d31c30d468da8a17 100644 --- a/include/i18n/en_US/templates/email/ticket.reply.yaml +++ b/include/i18n/en_US/templates/email/ticket.reply.yaml @@ -22,7 +22,7 @@ body: | <br> <br> <div style="color: rgb(127, 127, 127);"> - Your Company Name Team,<br> + Your %{company.name} Team,<br> %{signature} </div> <hr> diff --git a/include/staff/dynamic-forms.inc.php b/include/staff/dynamic-forms.inc.php index 2c4fa1d2c413191f5e648f16bc614292470814c7..35681f5b331c945d8c20ba6574e786c82b854be4 100644 --- a/include/staff/dynamic-forms.inc.php +++ b/include/staff/dynamic-forms.inc.php @@ -7,7 +7,7 @@ <?php $page = ($_GET['p'] && is_numeric($_GET['p'])) ? $_GET['p'] : 1; -$count = DynamicForm::objects()->filter(array('type__in'=>array('T','U','G')))->count(); +$count = DynamicForm::objects()->filter(array('type__in'=>array('G')))->count(); $pageNav = new Pagenate($count, $page, PAGE_LIMIT); $pageNav->setURL('forms.php'); $showing=$pageNav->showing().' forms'; @@ -21,35 +21,35 @@ $showing=$pageNav->showing().' forms'; <thead> <tr> <th width="7"> </th> - <th>Client Information Form <em>Added to all clients</em></th> + <th>Built-in Forms</th> <th>Last Updated</th> </tr> </thead> <tbody> - <?php foreach (UserForm::objects()->order_by('title') - ->limit($pageNav->getLimit()) - ->offset($pageNav->getStart()) as $form) { ?> + <?php + foreach (UserForm::objects()->order_by('title') as $form) { ?> <tr> <td/> - <td><a href="?id=<?php echo $form->get('id'); ?>"><?php echo $form->get('title'); ?></a></td> + <td><a href="?id=<?php echo $form->get('id'); ?>"> + <i class="icon-user"></i> <?php echo $form->get('title'); ?></a></td> <td><?php echo $form->get('updated'); ?></td> </tr> - <?php } ?> - </tbody> - <thead> + <?php } + foreach (TicketForm::objects()->order_by('title') as $form) { ?> <tr> - <th width="7"> </th> - <th>Common Ticket Form <em>Added to all tickets</em></th> - <th>Last Updated</th> + <td/> + <td><a href="?id=<?php echo $form->get('id'); ?>"> + <i class="icon-ticket icon"></i> + <?php echo $form->get('title'); ?></a></td> + <td><?php echo $form->get('updated'); ?></td> </tr> - </thead> - <tbody> - <?php foreach (TicketForm::objects()->order_by('title') - ->limit($pageNav->getLimit()) - ->offset($pageNav->getStart()) as $form) { ?> + <?php } + foreach (DynamicForm::objects()->filter(array('type'=>'C')) as $form) { ?> <tr> <td/> - <td><a href="?id=<?php echo $form->get('id'); ?>"><?php echo $form->get('title'); ?></a></td> + <td><a href="?id=<?php echo $form->get('id'); ?>"> + <i class="icon-building icon"></i> + <?php echo $form->get('title'); ?></a></td> <td><?php echo $form->get('updated'); ?></td> </tr> <?php } ?> @@ -59,7 +59,7 @@ $showing=$pageNav->showing().' forms'; <thead> <tr> <th width="7"> </th> - <th>Title</th> + <th>Custom Forms</th> <th>Last Updated</th> </tr> </thead> @@ -91,7 +91,7 @@ $showing=$pageNav->showing().' forms'; <a id="selectNone" href="#ckb">None</a> <a id="selectToggle" href="#ckb">Toggle</a> <?php }else{ - echo 'No extra forms defined yet — add one!'; + echo 'No extra forms defined yet — <a href="forms.php?a=add">add one!</a>'; } ?> </td> </tr> diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index d4e2ce612239c405dc5335650a2c0cf869ff6996..0e8924ea94aa983e47cf4b4e580e1f23b5772e67 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -25,7 +25,10 @@ <link rel="stylesheet" href="./css/typeahead.css" media="screen"> <link type="text/css" href="<?php echo ROOT_PATH; ?>css/ui-lightness/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" media="screen" /> - <link type="text/css" rel="stylesheet" href="../css/font-awesome.min.css"> + <link type="text/css" rel="stylesheet" href="<?php echo ROOT_PATH; ?>css/font-awesome.min.css"> + <!--[if IE 7]> + <link rel="stylesheet" href="<?php echo ROOT_PATH; ?>css/font-awesome-ie7.min.css"> + <![endif]--> <link type="text/css" rel="stylesheet" href="./css/dropdown.css"> <script type="text/javascript" src="./js/jquery.dropdown.js"></script> <?php diff --git a/include/staff/settings-pages.inc.php b/include/staff/settings-pages.inc.php index 43c8ea4fe31ad2be5f76912997e44a05f691ca81..8a849c6d8dad77460c215fcc77e5f5326aeee2c0 100644 --- a/include/staff/settings-pages.inc.php +++ b/include/staff/settings-pages.inc.php @@ -2,23 +2,33 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config) die('Access Denied'); $pages = Page::getPages(); ?> -<h2>Site Pages</h2> +<h2>Company Profile</h2> <form action="settings.php?t=pages" method="post" id="save" enctype="multipart/form-data"> <?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>Basic Information</h4> + </th> + </tr></thead> + <tbody> + <?php + $ost->company->getForm()->render(); + ?> + </tbody> <thead> <tr> <th colspan="2"> - <h4>Pages</h4> + <h4>Site Pages</h4> <em>To edit or add new pages go to <a href="pages.php">Manage > Site Pages</a></em> </th> </tr> </thead> <tbody> <tr> - <td width="220" class="required">Default Landing Page:</td> + <td width="220" class="required">Landing Page:</td> <td> <select name="landing_page_id"> <option value="">— Select Landing Page —</option> @@ -34,7 +44,7 @@ $pages = Page::getPages(); </td> </tr> <tr> - <td width="220" class="required">Default Offline Page:</td> + <td width="220" class="required">Offline Page:</td> <td> <select name="offline_page_id"> <option value="">— Select Offline Page —</option>