Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the system configuration backend page.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       Backend
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Timo Trautmann, Simon Sprankel
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Renders a select element with a label.
 20:  * If there are only two possible values which are called true/false,
 21:  * enabled/disabled or 0/1, a checkbox is rendered.
 22:  * Returns an associative array with the label and the input field.
 23:  *
 24:  * @param string $name the name of the form element
 25:  * @param array $possibleValues the possible values
 26:  * @param string $value the value which should be selected
 27:  * @param string $label the label text which should be rendered
 28:  * @return array associative array with the label and the input field
 29:  */
 30: function renderSelectProperty($name, $possibleValues, $value, $label) {
 31:     global $auth;
 32: 
 33:     if (count($possibleValues) === 2 && (in_array('true', $possibleValues) && in_array('false', $possibleValues) || in_array('enabled', $possibleValues) && in_array('disabled', $possibleValues) || in_array('0', $possibleValues) && in_array('1', $possibleValues))) {
 34:         // render a checkbox if there are only the values true and false
 35:         $checked = $value == 'true' || $value == '1' || $value == 'enabled';
 36:         $html = new cHTMLCheckbox($name, $possibleValues[0], $name, $checked);
 37:         $html->setLabelText($label);
 38:     } else {
 39:         // otherwise render a select box with the possible values
 40:         $html = new cHTMLSelectElement('');
 41:         foreach ($possibleValues as $possibleValue) {
 42:             $element = new cHTMLOptionElement($possibleValue, $possibleValue);
 43:             if ($possibleValue == $value) {
 44:                 $element->setSelected(true);
 45:             }
 46:             $html->appendOptionElement($element);
 47:         }
 48:     }
 49: 
 50:     // disable the HTML element if user is not a sysadmin
 51:     if (strpos($auth->auth['perm'], 'sysadmin') === false) {
 52:         $html->updateAttribute('disabled', 'true');
 53:     }
 54: 
 55:     $return = array();
 56:     $return['input'] = $html->render();
 57:     $return['label'] = '';
 58: 
 59:     return $return;
 60: }
 61: 
 62: /**
 63:  * Renders a cHTMLLabel.
 64:  *
 65:  * @param string $text the label text
 66:  * @param string $name the name of the corresponding input element
 67:  * @param string $width the width in pixel
 68:  * @param string $seperator the seperator which is written at the end of the
 69:  *            label
 70:  * @return string the rendered cHTMLLabel element
 71:  */
 72: function renderLabel($text, $name, $width = 250, $seperator = ':') {
 73:     $label = new cHTMLLabel($text . $seperator, $name);
 74:     $label->setClass("sys_config_txt_lbl");
 75:     $label->setStyle('width:' . $width . 'px;');
 76: 
 77:     return $label->render();
 78: }
 79: 
 80: /**
 81:  * Renders a cHTMLTextbox.
 82:  * Returns an associative array with the label and the input field.
 83:  *
 84:  * @param string $name the name of the form element
 85:  * @param string $value the value of the text field
 86:  * @param string $label the label text
 87:  * @param bool $password if the input is a password
 88:  * @return array associative array with the label and the input field
 89:  */
 90: function renderTextProperty($name, $value, $label, $password = false) {
 91:     global $auth;
 92: 
 93:     $textbox = new cHTMLTextbox($name, conHtmlSpecialChars($value), '50', '96');
 94:     // disable the textbox if user is not a sysadmin
 95:     if (strpos($auth->auth['perm'], 'sysadmin') === false) {
 96:         $textbox->updateAttribute('disabled', 'true');
 97:     }
 98:     if ($password === true) {
 99:         $textbox->updateAttribute('type', 'password');
100:     }
101: 
102:     $return = array();
103:     $return['input'] = $textbox->render();
104:     $return['label'] = renderLabel($label, $name);
105: 
106:     return $return;
107: }
108: 
109: $page = new cGuiPage('system_configuration', '', '1');
110: 
111: // read the properties from the XML file
112: $propertyTypes = cXmlReader::xmlStringToArray(cFileHandler::read($cfg['path']['xml'] . 'system.xml'));
113: $propertyTypes = $propertyTypes['properties'];
114: 
115: // get the stored settings
116: $settings = getSystemProperties();
117: 
118: $reloadHeader = false;
119: // store the system properties
120: if (isset($_POST['action']) && $_POST['action'] == 'edit_sysconf' && $perm->have_perm_area_action($area, 'edit_sysconf')) {
121:     if (strpos($auth->auth['perm'], 'sysadmin') === false) {
122:         $page->displayError(i18n('You don\'t have the permission to make changes here.'));
123:     } else {
124:         // @TODO Find a general solution for this!
125:         if (defined('CON_STRIPSLASHES')) {
126:             $post = cString::stripSlashes($_POST);
127:         } else {
128:             $post = $_POST;
129:         }
130:         $stored = false;
131:         foreach ($propertyTypes as $type => $properties) {
132:             foreach ($properties as $name => $infos) {
133:                 // get the posted value
134:                 $fieldName = $type . '{_}' . $name;
135:                 if (isset($post[$fieldName])) {
136:                     $value = $post[$fieldName];
137:                 } else {
138:                     $value = (isset($infos['values'][1])) ? $infos['values'][1] : 'false';
139:                 }
140: 
141:                 $storedValue = $settings[$type][$name];
142:                 if ($storedValue != $value && (is_array($infos['values']) && $value != '' || !is_array($infos['values']))) {
143:                     if ($type == 'update' && $name == 'check_period' && $value < 60) {
144:                         $page->displayError(i18n('Update check period must be at least 60 minutes.'));
145:                         $stored = false;
146:                         // break out of both loops
147:                         break 2;
148:                     } else {
149:                         setSystemProperty($type, $name, $value);
150:                         // also update the settings array because it is used below
151:                         $settings[$type][$name] = $value;
152:                         $stored = true;
153: 
154:                         if (($type == 'debug' && $name == 'debug_to_screen') || ($type == 'system' && $name == 'clickmenu')) {
155:                             $reloadHeader = true;
156:                         }
157:                     }
158:                 }
159:             }
160:         }
161:         if ($stored) {
162:             $page->displayInfo(i18n('Changes saved'));
163:         }
164:     }
165: }
166: 
167: // generate the table for changing the system properties
168: $form = new cGuiTableForm('system_configuration');
169: $form->addHeader(i18n('System configuration'));
170: $form->setVar('area', $area);
171: $form->setVar('frame', $frame);
172: $form->setVar('action', 'edit_sysconf');
173: 
174: // show a disabled OK button if user is not a sysadmin
175: if (strpos($auth->auth['perm'], 'sysadmin') === false) {
176:     $form->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok_off.gif', i18n("You are not sysadmin. You can't change these settings."), 's');
177: }
178: 
179: $groups = array();
180: $currentGroup = '';
181: $leftContent = '';
182: // iterate over all property types
183: foreach ($propertyTypes as $type => $properties) {
184:     foreach ($properties as $name => $infos) {
185:         // $infos is an array with the keys 'values', 'label' and 'group'
186:         // extend the groups array if it is a new group
187:         if (!isset($groups[$infos['group']])) {
188:             $groups[$infos['group']] = '';
189:         }
190: 
191:         // get the currently stored value
192:         if (isset($settings[$type][$name])) {
193:             $value = $settings[$type][$name];
194:         } else {
195:             $value = '';
196:         }
197: 
198:         // render the HTML and add it to the groups array
199:         $fieldName = $type . '{_}' . $name;
200:         if (is_array($infos['values'])) {
201:             $htmlElement = renderSelectProperty($fieldName, $infos['values'], $value, i18n($infos['label']));
202:         } else {
203:             if (strlen($name) > 5 && substr($name, -5) === '_pass') {
204:                 $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']), true);
205:             } else {
206:                 $htmlElement = renderTextProperty($fieldName, $value, i18n($infos['label']));
207:             }
208:         }
209: 
210:         $groups[$infos['group']] .= new cHTMLDiv($htmlElement['label'] . $htmlElement['input'], 'systemSetting');
211:     }
212: }
213: 
214: // render the group names and the corresponding settings
215: foreach ($groups as $groupName => $groupSettings) {
216:     $groupName = i18n($groupName);
217:     $form->add(renderLabel($groupName, '', 150, ''), $groupSettings);
218: }
219: 
220: // show error if user is not allowed to see the page
221: if ($perm->have_perm_area_action($area, 'edit_sysconf')) {
222:     $page->set('s', 'RELOAD_HEADER', ($reloadHeader) ? 'true' : 'false');
223:     $page->set('s', 'FORM', $form->render());
224: } else {
225:     $page->displayCriticalError(i18n('Access denied'));
226: }
227: 
228: $page->render();
229: 
230: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen