Skip to content

Commit

Permalink
#25 Added 'acknowledge' => true to core forms first step
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterHans committed Jan 14, 2021
1 parent 68ccf0f commit 9d18adf
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 41 deletions.
97 changes: 97 additions & 0 deletions protected/humhub/compat/CAcknowledgeActiveForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\compat;

use humhub\modules\ui\form\widgets\ActiveForm;

/**
* CActiveForm is a Yii 1 compatible active form
*
* @author luke
* @deprecated since 1.4
*/
class CAcknowledgeActiveForm extends ActiveForm
{
public function label($model, $attribute, $htmlOptions = [])
{
return CHtml::activeLabel($model, $attribute, $htmlOptions);
}

public function labelEx($model, $attribute, $htmlOptions = [])
{
return CHtml::activeLabelEx($model, $attribute, $htmlOptions);
}

public function error($model, $attribute, $htmlOptions = [], $enableAjaxValidation = true, $enableClientValidation = true)
{
return CHtml::error($model, $attribute, $htmlOptions);
}

public function passwordField($model, $attribute, $htmlOptions = [])
{
return CHtml::activePasswordInput($model, $attribute, $htmlOptions);
}

public function textArea($model, $attribute, $htmlOptions = [])
{
return CHtml::activeTextarea($model, $attribute, $htmlOptions);
}

public function checkBox($model, $attribute, $htmlOptions = [])
{
return CHtml::activeCheckboxNoLabel($model, $attribute, $htmlOptions);
}

public function dropDownList($model, $attribute, $data, $htmlOptions = [])
{
return CHtml::activeDropDownList($model, $attribute, $data, $htmlOptions);
}

public function radioButtonList($model, $attribute, $data, $htmlOptions = [])
{
return CHtml::activeRadioList($model, $attribute, $data, $htmlOptions);
}

public function radioButton($model, $attribute, $options = [])
{
$name = isset($options['name']) ? $options['name'] : CHtml::getInputName($model, $attribute);
$value = CHtml::getAttributeValue($model, $attribute);

if (!array_key_exists('value', $options)) {
$options['value'] = '1';
}

$checked = "$value" === "{$options['value']}";

if (!array_key_exists('id', $options)) {
$options['id'] = CHtml::getInputId($model, $attribute);
}

return CHtml::radio($name, $checked, $options);
}

public function textField($model, $attribute, $htmlOptions = [])
{
return CHtml::activeTextField($model, $attribute, $htmlOptions);
}

public function fileField($model, $attribute, $htmlOptions = [])
{
return CHtml::activeFileInput($model, $attribute, $htmlOptions);
}

public function hiddenField($model, $attribute, $htmlOptions = [], $value=null)
{
if ($value !== null) {
$model->$attribute = $value;
}

return CHtml::activeHiddenInput($model, $attribute, $htmlOptions);
}
}
4 changes: 2 additions & 2 deletions protected/humhub/modules/activity/views/mailSummaryForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
/* @var $form humhub\widgets\ActiveForm */

use humhub\libs\Html;
use yii\bootstrap\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\modules\space\widgets\SpacePickerField;
?>

<?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?>
<?php $form = ActiveForm::begin(['enableClientValidation' => false, 'acknowledge' => true]); ?>

<?= $form->field($model, 'interval')->dropDownList($model->getIntervals()) ?>
<?= $form->field($model, 'limitSpacesMode')->radioList($model->getLimitSpaceModes()) ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use yii\widgets\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\compat\CHtml;
use humhub\models\Setting;

Expand All @@ -11,7 +11,7 @@

<?php $this->beginContent('@admin/views/authentication/_authenticationLayout.php') ?>
<div class="panel-body">
<?php $form = ActiveForm::begin(['id' => 'authentication-settings-form']); ?>
<?php $form = ActiveForm::begin(['id' => 'authentication-settings-form', 'acknowledge' => true]); ?>

<?= $form->errorSummary($model); ?>

Expand Down
11 changes: 6 additions & 5 deletions protected/humhub/modules/admin/views/group/edit.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?php

use humhub\modules\ui\form\widgets\SortOrderField;
use yii\widgets\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;
use yii\helpers\Url;
use yii\helpers\Html;
use humhub\compat\CHtml;
use humhub\modules\user\widgets\UserPickerField;
use humhub\modules\space\widgets\SpacePickerField;

?>

<?php $this->beginContent('@admin/views/group/_manageLayout.php', ['group' => $group]) ?>
<?php $this->beginContent('@admin/views/group/_manageLayout.php', ['group' => $group, 'acknowledge' => true]) ?>
<div class="panel-body">
<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin(['acknowledge' => true]); ?>
<?= $form->field($group, 'name'); ?>
<?= $form->field($group, 'description')->textarea(['rows' => 5]); ?>

Expand All @@ -28,7 +29,7 @@

<?php if ($isManagerApprovalSetting && !$group->is_admin_group): ?>
<?php $url = ($group->isNewRecord) ? null : Url::to(['/admin/group/admin-user-search', 'id' => $group->id]); ?>
<?= UserPickerField::widget([
<?= UserPickerField::widget([
'form' => $form,
'model' => $group,
'attribute' => 'managerGuids',
Expand All @@ -54,6 +55,6 @@
echo Html::a(Yii::t('AdminModule.user', 'Delete'), Url::toRoute(['/admin/group/delete', 'id' => $group->id]), ['class' => 'btn btn-danger', 'data-method' => 'POST']);
}
?>
<?php ActiveForm::end(); ?>
<?php ActiveForm::end(); ?>
</div>
<?php $this->endContent(); ?>
4 changes: 2 additions & 2 deletions protected/humhub/modules/admin/views/setting/basic.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use humhub\libs\TimezoneHelper;
use yii\widgets\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\compat\CHtml;

?>
Expand All @@ -14,7 +14,7 @@

<br>

<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin(['acknowledge' => true]); ?>

<?= $form->field($model, 'name'); ?>

Expand Down
4 changes: 2 additions & 2 deletions protected/humhub/modules/admin/views/setting/caching.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use humhub\modules\admin\models\forms\CacheSettingsForm;
use humhub\widgets\Button;
use yii\widgets\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;

/* @var $cacheTypes [] */
/* @var $model CacheSettingsForm */
Expand All @@ -11,7 +11,7 @@

<?php $this->beginContent('@admin/views/setting/_advancedLayout.php') ?>

<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin(['acknowledge' => true]); ?>

<?= $form->field($model, 'type')->dropDownList($cacheTypes, ['readonly' => Yii::$app->settings->isFixed('cache.class')]) ?>

Expand Down
4 changes: 2 additions & 2 deletions protected/humhub/modules/admin/views/setting/design.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use humhub\modules\admin\models\forms\DesignSettingsForm;
use humhub\modules\web\pwa\widgets\SiteIcon;
use humhub\widgets\Button;
use yii\widgets\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;
use yii\helpers\Url;
use humhub\compat\CHtml;

Expand Down Expand Up @@ -35,7 +35,7 @@

<br>

<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'], 'acknowledge' => true]); ?>

<?= $form->field($model, 'theme')->dropDownList($model->getThemes()); ?>

Expand Down
8 changes: 4 additions & 4 deletions protected/humhub/modules/admin/views/setting/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @var string $currentImageLibrary
*/

use humhub\compat\CActiveForm;
use humhub\compat\CAcknowledgeActiveForm;
use humhub\compat\CHtml;
use humhub\models\Setting;

Expand All @@ -17,14 +17,14 @@
?>
<?php $this->beginContent('@admin/views/setting/_advancedLayout.php') ?>

<?php $form = CActiveForm::begin(); ?>
<?php $form = CAcknowledgeActiveForm::begin(['acknowledge' => true]); ?>

<?= $form->errorSummary($model); ?>

<div class="form-group">
<?= $form->labelEx($model, 'maxFileSize'); ?>
<?= $form->textField($model, 'maxFileSize', ['class' => 'form-control', 'readonly' => $fileModule->settings->isFixed('maxFileSize')]); ?>
<p class="help-block" <?= ($model->maxFileSize > $maxUploadSize) ? 'style="color:'.$this->theme->variable('danger').' !important"' : ''?>>
<p class="help-block" <?= ($model->maxFileSize > $maxUploadSize) ? 'style="color:' . $this->theme->variable('danger') . ' !important"' : '' ?>>
<?= Yii::t('AdminModule.settings', 'PHP reported a maximum of {maxUploadSize} MB', ['{maxUploadSize}' => $maxUploadSizeText]); ?>
</p>
</div>
Expand Down Expand Up @@ -58,6 +58,6 @@
<?= CHtml::submitButton(Yii::t('AdminModule.settings', 'Save'), ['class' => 'btn btn-primary', 'data-ui-loader' => ""]); ?>

<?= \humhub\widgets\DataSaved::widget(); ?>
<?php CActiveForm::end(); ?>
<?php CAcknowledgeActiveForm::end(); ?>

<?php $this->endContent(); ?>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
?>
<?php $this->beginContent('@admin/views/setting/_advancedLayout.php') ?>

<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin(['acknowledge' => true]); ?>

<?= $form->errorSummary($model); ?>

Expand Down
10 changes: 6 additions & 4 deletions protected/humhub/modules/admin/views/setting/proxy.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?php

use humhub\compat\CActiveForm;
use humhub\compat\CAcknowledgeActiveForm;
use humhub\compat\CHtml;
use humhub\models\Setting;

?>

<?php $this->beginContent('@admin/views/setting/_advancedLayout.php') ?>

<?php $form = CActiveForm::begin(); ?>
<?php $form = CAcknowledgeActiveForm::begin(['acknowledge' => true]); ?>

<?= $form->errorSummary($model); ?>

<div class="form-group">
<div class="checkbox">
<label>
<?= $form->checkBox($model, 'enabled', ['readonly' => Yii::$app->settings->isFixed('proxy.enabled')]); echo $model->getAttributeLabel('enabled'); ?>
<?= $form->checkBox($model, 'enabled', ['readonly' => Yii::$app->settings->isFixed('proxy.enabled')]);
echo $model->getAttributeLabel('enabled'); ?>
</label>
</div>
</div>
Expand Down Expand Up @@ -55,6 +57,6 @@
<?= CHtml::submitButton(Yii::t('AdminModule.settings', 'Save'), ['class' => 'btn btn-primary', 'data-ui-loader' => ""]); ?>

<?= \humhub\widgets\DataSaved::widget(); ?>
<?php CActiveForm::end(); ?>
<?php CAcknowledgeActiveForm::end(); ?>

<?php $this->endContent(); ?>
6 changes: 3 additions & 3 deletions protected/humhub/modules/admin/views/setting/statistic.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

use humhub\compat\CActiveForm;
use humhub\compat\CAcknowledgeActiveForm;
use humhub\compat\CHtml;
?>
<?php $this->beginContent('@admin/views/setting/_advancedLayout.php') ?>

<p><?= Yii::t('AdminModule.settings', 'You can add a statistic code snippet (HTML) - which will be added to all rendered pages.')?></p>
<br>

<?php $form = CActiveForm::begin(); ?>
<?php $form = CAcknowledgeActiveForm::begin(['acknowledge' => true]); ?>

<?= $form->errorSummary($model); ?>

Expand All @@ -21,6 +21,6 @@
<?= CHtml::submitButton(Yii::t('AdminModule.settings', 'Save'), ['class' => 'btn btn-primary', 'data-ui-loader' => ""]); ?>

<?= \humhub\widgets\DataSaved::widget(); ?>
<?php CActiveForm::end(); ?>
<?php CAcknowledgeActiveForm::end(); ?>

<?php $this->endContent(); ?>
4 changes: 2 additions & 2 deletions protected/humhub/modules/admin/views/user/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use humhub\compat\HForm;
use humhub\widgets\Button;
use humhub\widgets\ModalButton;
use yii\widgets\ActiveForm;
use humhub\modules\ui\form\widgets\ActiveForm;

/* @var $hForm HForm */
?>
Expand All @@ -22,7 +22,7 @@
<h4 class="pull-left"><?= Yii::t('AdminModule.user', 'Add new user') ?></h4>
</div>
<br>
<?php $form = ActiveForm::begin(['options' => ['data-ui-widget' => 'ui.form.TabbedForm', 'data-ui-init' => '']]); ?>
<?php $form = ActiveForm::begin(['options' => ['data-ui-widget' => 'ui.form.TabbedForm', 'data-ui-init' => ''], 'acknowledge' => true]); ?>
<?= $hForm->render($form); ?>
<?php ActiveForm::end(); ?>
</div>
27 changes: 15 additions & 12 deletions protected/humhub/modules/notification/views/admin/defaults.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<?php
use yii\widgets\ActiveForm;

use humhub\modules\ui\form\widgets\ActiveForm;

/* @var $model \humhub\modules\notification\models\forms\NotificationSettings */
?>

<div class="panel-body">
<h4><?= Yii::t('AdminModule.settings', 'Notification Settings'); ?></h4>
<div class="help-block">
<?= Yii::t('NotificationModule.base', 'Notifications are sent directly to your users to inform them about new activities in your network.'); ?><br />
<?= Yii::t('NotificationModule.base', 'Notifications are sent directly to your users to inform them about new activities in your network.'); ?>
<br/>
<?= Yii::t('NotificationModule.base', 'In this view, you can define the default behavior for your users. These settings can be overwritten by users in their account settings page.'); ?>
<br />
<br/>
</div>
<?php $form = ActiveForm::begin() ?>
<?= humhub\modules\notification\widgets\NotificationSettingsForm::widget([
'model' => $model,
'form' => $form,
'showSpaces' => true
]) ?>
<br />
<button type="submit" class="btn btn-primary" data-ui-loader><?= Yii::t('base', 'Save');?></button>
<?php ActiveForm::end(); ?>
<?php $form = ActiveForm::begin(['acknowledge' => true]) ?>
<?= humhub\modules\notification\widgets\NotificationSettingsForm::widget([
'model' => $model,
'form' => $form,
'showSpaces' => true
]) ?>
<br/>
<button type="submit" class="btn btn-primary" data-ui-loader><?= Yii::t('base', 'Save'); ?></button>
<?php ActiveForm::end(); ?>
</div>

0 comments on commit 9d18adf

Please sign in to comment.