source: trunk/content/plugins/contact_us/contact_us_settings.php @ 1375

Revision 1375, 3.1 KB checked in by nick_ramsay, 3 years ago (diff)

[Trunk] Hotaru 1.1.3 [Run upgrade script]

RevLine 
[1352]1<?php
2/**
3 * Contact Us Settings
4 *
5 * PHP version 5
6 *
7 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
18 *
19 * @category  Content Management System
20 * @package   HotaruCMS
21 * @author    Nick Ramsay <admin@hotarucms.org>
22 * @copyright Copyright (c) 2009, Hotaru CMS
23 * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
24 * @link      http://www.hotarucms.org/
25 */
26 
27class ContactUsSettings
28{
29     /**
30     * Admin settings for the Users plugin
31     */
32    public function settings($h)
33    {
34        // If the form has been submitted, go and save the data...
35        if ($h->cage->post->getAlpha('submitted') == 'true') {
36            $this->saveSettings($h);
37        }   
38       
39        echo "<h1>" . $h->lang["contact_us_settings_header"] . "</h1>\n";
40       
41        // Get settings from database if they exist...
42        $contact_us_settings = $h->getSerializedSettings();
43        $recaptcha = $contact_us_settings['recaptcha'];
44       
45        //...otherwise set to blank:
46        if (!$recaptcha) { $recaptcha = ''; }
47       
48        echo "<form name='contact_us_settings_form' action='" . BASEURL . "admin_index.php?page=plugin_settings&amp;plugin=contact_us' method='post'>\n";
49       
50        echo "<input type='checkbox' name='recaptcha' value='recaptcha' " . $recaptcha . " >&nbsp;&nbsp;" . $h->lang["contact_us_settings_recaptcha"] . "<br /><br />\n";
51
52        echo "<input type='hidden' name='submitted' value='true' />\n";
53        echo "<input type='submit' value='" . $h->lang["main_form_save"] . "' />\n";
54        echo "<input type='hidden' name='csrf' value='" . $h->csrfToken . "' />\n";
55        echo "</form><br />\n";
56       
57        echo "<p>" . $h->lang["contact_us_instruct"] . "<a href='" . $h->url(array('page'=>'contact')) . "'>" . $h->url(array('page'=>'contact')) . "</a></p>\n";
58
59    }
60   
61   
62    /**
63     * Save Settings
64     */
65    public function saveSettings($h)
66    {
67        // get current settings
68        $contact_us_settings = $h->getSerializedSettings();
69       
70        // Use reCaptcha?
71        if ($h->cage->post->keyExists('recaptcha')) {
72            $contact_us_settings['recaptcha'] = "checked";
73        } else {
74            $contact_us_settings['recaptcha'] = "";
75        }
76       
77        $h->updateSetting('contact_us_settings', serialize($contact_us_settings));
78       
79        $h->message = $h->lang["main_settings_saved"];
80        $h->messageType = "green";
81        $h->showMessage();
82       
83        return true;   
84    }
85}
86?>
Note: See TracBrowser for help on using the repository browser.