mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Allow not changeable config settings
This commit is contained in:
parent
469d9887a3
commit
e7de3c6d1f
@ -22,13 +22,14 @@
|
||||
* This is the model class for table "settings" and is responsible for system
|
||||
* wide settings of modules.
|
||||
*
|
||||
* Only use this for settings and not for general proposes.
|
||||
* Only use this for settings and not for general value storage proposes.
|
||||
*
|
||||
* The registry is used to store systemwide settings.
|
||||
* Also modules can use this to store e.g. configuration options.
|
||||
*
|
||||
* Settings in configuration file at "params -> HSettingsFixed" are not
|
||||
* changeable.
|
||||
*
|
||||
* The followings are the available columns in table 'registry':
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $value
|
||||
@ -127,6 +128,14 @@ class HSetting extends HActiveRecord {
|
||||
*/
|
||||
public static function Get($name, $moduleId = "") {
|
||||
|
||||
if (self::IsFixed($name, $moduleId)) {
|
||||
if ($moduleId == "") {
|
||||
return Yii::app()->params['HSettingFixed'][$name];
|
||||
} else {
|
||||
return Yii::app()->params['HSettingFixed'][$moduleId][$name];
|
||||
}
|
||||
}
|
||||
|
||||
$record = self::GetRecord($name, $moduleId);
|
||||
return $record->value;
|
||||
}
|
||||
@ -154,6 +163,10 @@ class HSetting extends HActiveRecord {
|
||||
public static function Set($name, $value, $moduleId = "") {
|
||||
$record = self::GetRecord($name, $moduleId);
|
||||
|
||||
if (self::IsFixed($name, $moduleId)) {
|
||||
$value = self::Get($name, $moduleId);
|
||||
}
|
||||
|
||||
$record->name = $name;
|
||||
$record->value = $value;
|
||||
if ($moduleId != "")
|
||||
@ -185,6 +198,27 @@ class HSetting extends HActiveRecord {
|
||||
$record->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the setting value is fixed in the configuration
|
||||
* file or can be changed at runtime.
|
||||
*
|
||||
* @param type $name
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IsFixed($name, $moduleId = "") {
|
||||
|
||||
if ($moduleId == "") {
|
||||
if (isset(Yii::app()->params['HSettingFixed'][$name])) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (isset(Yii::app()->params['HSettingFixed'][$moduleId][$name])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Cache ID for this HSetting Entry
|
||||
*
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'type'); ?>
|
||||
<?php echo $form->dropDownList($model, 'type', $cacheTypes, array('class' => 'form-control')); ?><br>
|
||||
<?php echo $form->dropDownList($model, 'type', $cacheTypes, array('class' => 'form-control','readonly'=> HSetting::IsFixed('type', 'cache'))); ?><br>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'expireTime'); ?>
|
||||
<?php echo $form->textField($model, 'expireTime', array('class' => 'form-control')); ?><br>
|
||||
<?php echo $form->textField($model, 'expireTime', array('class' => 'form-control','readonly'=> HSetting::IsFixed('expireTime', 'cache'))); ?><br>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
@ -10,18 +10,18 @@ $form = $this->beginWidget('CActiveForm', array(
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'imageMagickPath'); ?>
|
||||
<?php echo $form->textField($model, 'imageMagickPath', array('class' => 'form-control', 'hint' => Yii::t('AdminModule.file', 'e.g. Linux=/usr/bin/convert or MacOSX = /opt/local/bin/convert or Win = C:\wamp\imagemagick\convert.exe'))); ?>
|
||||
<?php echo $form->textField($model, 'imageMagickPath', array('class' => 'form-control', 'hint' => Yii::t('AdminModule.file', 'e.g. Linux=/usr/bin/convert or MacOSX = /opt/local/bin/convert or Win = C:\wamp\imagemagick\convert.exe'), 'readonly'=> HSetting::IsFixed('imageMagickPath', 'file'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'maxFileSize'); ?>
|
||||
<?php echo $form->textField($model, 'maxFileSize', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'maxFileSize', array('class' => 'form-control','readonly'=> HSetting::IsFixed('maxFileSize', 'file'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<?php echo $form->checkBox($model, 'useXSendfile'); ?> <?php echo $model->getAttributeLabel('useXSendfile'); ?>
|
||||
<?php echo $form->checkBox($model, 'useXSendfile', array('disabled' => HSetting::IsFixed('useXSendfile', 'file'))); ?> <?php echo $model->getAttributeLabel('useXSendfile'); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,17 +10,17 @@ $form = $this->beginWidget('CActiveForm', array(
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'name'); ?>
|
||||
<?php echo $form->textField($model, 'name', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'name', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('name'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'baseUrl'); ?>
|
||||
<?php echo $form->textField($model, 'baseUrl', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'baseUrl', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('baseUrl'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'defaultLanguage'); ?>
|
||||
<?php echo $form->dropDownList($model, 'defaultLanguage', Yii::app()->getLanguages(), array('class' => 'form-control')); ?>
|
||||
<?php echo $form->dropDownList($model, 'defaultLanguage', Yii::app()->getLanguages(), array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('defaultLanguage'))); ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -8,19 +8,19 @@
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'systemEmailAddress'); ?>
|
||||
<?php echo $form->textField($model, 'systemEmailAddress', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'systemEmailAddress', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('systemEmailAddress', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'systemEmailName'); ?>
|
||||
<?php echo $form->textField($model, 'systemEmailName', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'systemEmailName', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('systemEmailName', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'transportType'); ?>
|
||||
<?php echo $form->dropDownList($model, 'transportType', $transportTypes, array('class' => 'form-control')); ?>
|
||||
<?php echo $form->dropDownList($model, 'transportType', $transportTypes, array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('transportType', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
@ -28,27 +28,27 @@
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'hostname'); ?>
|
||||
<?php echo $form->textField($model, 'hostname', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'hostname', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('hostname', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'username'); ?>
|
||||
<?php echo $form->textField($model, 'username', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'username', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('username', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'password'); ?>
|
||||
<?php echo $form->passwordField($model, 'password', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->passwordField($model, 'password', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('password', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'port'); ?>
|
||||
<?php echo $form->textField($model, 'port', array('class' => 'form-control')); ?>
|
||||
<?php echo $form->textField($model, 'port', array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('port', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->labelEx($model, 'encryption'); ?>
|
||||
<?php echo $form->dropDownList($model, 'encryption', $encryptionTypes, array('class' => 'form-control')); ?>
|
||||
<?php echo $form->dropDownList($model, 'encryption', $encryptionTypes, array('class' => 'form-control', 'readonly'=> HSetting::IsFixed('encryption', 'mailing'))); ?>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user