Skip to content

Commit

Permalink
Dev Added text configuration for survey. Updated integrity check to n…
Browse files Browse the repository at this point in the history
…ew layout.
  • Loading branch information
SamMousa committed May 26, 2015
1 parent 22ef2cf commit 84a36aa
Show file tree
Hide file tree
Showing 27 changed files with 218 additions and 90 deletions.
12 changes: 12 additions & 0 deletions application/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ public function actionUpdate()
}
}

public function actionInfo()
{
/**
* @todo Technically this renders invalid HTML since phpinfo() adds its own HTML tag.
*/
ob_start();
phpinfo();
return $this->renderText(ob_get_clean());

// $this->renderText(phpinfo());
}

}
10 changes: 9 additions & 1 deletion application/controllers/admin/checkintegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,14 @@ protected function _checkintegrity()
*/
protected function _renderWrappedTemplate($sAction = 'checkintegrity', $aViewUrls = array(), $aData = array())
{
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
$this->controller->layout = 'main';
if (is_array($aViewUrls) && count($aViewUrls > 1)) {
return parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
} else {
$view = $sAction . '/' . (is_array($aViewUrls) ? $aViewUrls[0] : $aViewUrls);
return $this->controller->render($view, $aData);
}


}
}
1 change: 0 additions & 1 deletion application/controllers/admin/labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public function index($sa, $lid=0)

$aViewUrls['editlabel_view'][] = $aData;
}

$this->_renderWrappedTemplate('labels', $aViewUrls, $aData);

}
Expand Down
10 changes: 0 additions & 10 deletions application/core/plugins/Authdb/AuthDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,4 @@ public function authenticate(\CHttpRequest $request) {
}
}

/**
* @return boolean True if all users for this authenticator can be listed.
*/
public function enumerable() {
return true;
}




}
17 changes: 12 additions & 5 deletions application/core/plugins/PermissionDb/PermissionDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ public function executeBizRule($bizRule, $params, $data) {
}

public function getAuthAssignment($itemName, $userId) {

// \Permission::model()->findAllByAttributes(['uid' => $userId]);
}

public function getAuthAssignments($userId) {

return \Permission::model()->findAllByAttributes(['uid' => $userId]);
}

public function getAuthItem($name) {

}

public function getAuthItems($type = null, $userId = null) {

return \Permission::getGlobalBasePermissions();
}

public function getItemChildren($itemName) {
Expand All @@ -69,7 +69,14 @@ public function hasItemChild($itemName, $childName) {
}

public function isAssigned($itemName, $userId) {

if (strpos($itemName, '.')) {
list($itemName, $crud) = explode('.', $itemName);
return \Permission::model()->countByAttributes([
'entity' => 'global',
'entity_id' => 0,
"{$crud}_p" => 1
]) > 0;
}
}

public function removeAuthItem($name) {
Expand Down
3 changes: 1 addition & 2 deletions application/helpers/surveytranslator_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
* If $iDateFormat is given only the particual dateformat will be returned
*
* @param $iDateFormat integer
* @param $sLanguageCode string
* @returns array
*
*/
function getDateFormatData($iDateFormat=0,$sLanguageCode='en')
function getDateFormatData($iDateFormat=0)
{
$aDateFormats= array(
1=> array ('phpdate' => 'd.m.Y', 'jsdate' => 'dd.mm.yy', 'dateformat' => gT('dd.mm.yyyy')),
Expand Down
31 changes: 30 additions & 1 deletion application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @property-read Question[] $questions
* @property boolean $bool_usetokens
* @property-read boolean $isExpired
* @property-read SurveyLanguageSetting[] $languagesettings
* @property-read QuestionGroup[] $groups
*/
class Survey extends LSActiveRecord
Expand Down Expand Up @@ -249,7 +250,7 @@ public function rules()
// array('expires','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
// array('startdate','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
// array('datecreated','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),

['translatedFields', 'safe'],
['use_series', 'boolean'],
['features', 'safe']
);
Expand Down Expand Up @@ -953,4 +954,32 @@ public function getLanguages() {
array_unshift($result, $this->language);
return $result;
}


public function getTranslatedFields() {
/** @var SurveyLanguageSetting $languageSetting */
$result = [];
foreach($this->languagesettings as $languageSetting) {
$result[$languageSetting->surveyls_language] = $languageSetting->attributes;
}
return $result;
}

/**
* We save this immediately if / when we move to TranslatableBehavior, saving will happen automatically when
* saving the main record.
* @param $value
*/
public function setTranslatedFields($value) {
foreach($value as $language => $fields) {
if (!isset($this->languagesettings[$language])) {
$this->languagesettings[$language] = $languageSetting = new SurveyLanguageSetting();
$languageSetting->surveyls_language = $language;
} else {
$languageSetting = $this->languagesettings[$language];
}
$languageSetting->attributes = $fields;
$languageSetting->save();
}
}
}
35 changes: 35 additions & 0 deletions application/models/SurveyLanguageSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,36 @@
* See COPYRIGHT.php for copyright notices and details.
*
*/

/**
* Class SurveyLanguageSetting
* @property string $surveyls_title
* @property string $surveyls_description
* @property string $surveyls_welcometext
* @property string $surveyls_endtext
* @property string $surveyls_url
* @property string $surveyls_urldescription
* @property string $surveyls_language
* @property int $surveyls_dateformat
* @property int $surveyls_numberformat
*/
class SurveyLanguageSetting extends LSActiveRecord
{
public function attributeLabels()
{
return [
'surveyls_title' => gT("Survey title"),
'surveyls_endtext' => gT("End message"),
'surveyls_welcometext' => gT('Welcome message'),
'surveyls_description' => gT('Description'),
'surveyls_url' => gT("End URL"),
'surveyls_urldescription' => gT('URL description'),
'surveyls_dateformat' => gT('Date format'),
'surveyls_numberformat' => gT('Decimal mark'),

];
}

/**
* Returns the table's name
*
Expand Down Expand Up @@ -229,4 +257,11 @@ function insertSomeRecords($data)
$lang->$k = $v;
return $lang->save();
}

public function getDateFormatOptions() {
return array_map(function($e) { return $e['dateformat']; }, getDateFormatData());
}
public function getNumberFormatOptions() {
return array_map(function($e) { return $e['desc']; }, getRadixPointData());
}
}
4 changes: 4 additions & 0 deletions application/views/admin/checkintegrity/check_view.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class='messagebox ui-corner-all data-integrity consistency'>
<div class='header ui-widget-header'><?php eT("Data consistency check"); ?><br />
<span class='hint'><?php eT("If errors are showing up you might have to execute this script repeatedly."); ?></span>
Expand Down Expand Up @@ -269,3 +271,5 @@
} ?>

</div>
</div>
</div>
6 changes: 5 additions & 1 deletion application/views/admin/checkintegrity/fix_view.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class='messagebox ui-corner-all'>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class='messagebox ui-corner-all'>
<div class='header ui-widget-header'><?php eT("Data consistency check"); ?><br />
<span style='font-size:7pt;'><?php eT("If errors are showing up you might have to execute this script repeatedly."); ?></span>
</div>
Expand All @@ -11,4 +13,6 @@

<p><?php eT("Check database again?"); ?><br />
<a href='<?php echo $this->createUrl('admin/checkintegrity');?>'><?php eT("Check again"); ?></a><br />
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion application/views/settings/global/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'label' => gT('Environment'),
'type' => 'raw',
'visible' => App()->user->checkAccess('superadmin'),
'value' => TbHtml::link(gT('Show PHPInfo'), ['admin/globalsettings', 'sa'=>'showphpinfo'])
'value' => TbHtml::link(gT('Show PHPInfo'), ['settings/info'])
],
[
'label' => gT('Current version'),
Expand Down
36 changes: 24 additions & 12 deletions application/views/surveys/update.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
<div class="row">
<div class="col-md-12">
<?php
echo TbHtml::beginFormTb(TbHtml::FORM_LAYOUT_HORIZONTAL, '', 'post', []);

/** @var TbActiveForm $form */
$form = $this->beginWidget(TbActiveForm::class, [
'enableAjaxValidation' => false,
'enableClientValidation' => true,
'layout' => TbHtml::FORM_LAYOUT_VERTICAL,
'action' => ['surveys/update', 'id' => $survey->sid],
'method' => 'put',
'htmlOptions' => [
'validateOnSubmit' => true
]
]);
$this->widget('TbTabs', [
'tabs' => [
[
'label' => 'Properties',
'content' => $this->renderPartial('view/properties', ['survey' => $survey], true),
'label' => gT('Overview'),
'content' => $this->renderPartial('update/properties', ['survey' => $survey], true),
'active' => true
], [
'label' => gT('Texts'),
'content' => $this->renderPartial('update/texts', ['survey' => $survey, 'form' => $form], true),
], [
'label' => gT('General'),
'content' => $this->renderPartial('view/general', ['survey' => $survey], true),
'content' => $this->renderPartial('update/general', ['survey' => $survey, 'form' => $form], true),
], [
'label' => gT('Languages'),
'content' => $this->renderPartial('view/languages', ['survey' => $survey], true),
'content' => $this->renderPartial('update/languages', ['survey' => $survey, 'form' => $form], true),
], [
'label' => gT('Presentation & Navigation'),
'content' => $this->renderPartial('view/presentation', ['survey' => $survey], true),
'content' => $this->renderPartial('update/presentation', ['survey' => $survey, 'form' => $form], true),

], [
'label' => gT('Notification & data management'),
'content' => $this->renderPartial('view/data', ['survey' => $survey], true),
'content' => $this->renderPartial('update/data', ['survey' => $survey, 'form' => $form], true),

], [
'label' => gT('Tokens'),
'content' => $this->renderPartial('view/tokens', ['survey' => $survey], true),
'content' => $this->renderPartial('update/tokens', ['survey' => $survey, 'form' => $form], true),
'visible' => $survey->bool_usetokens

], [
Expand All @@ -38,11 +50,11 @@

], [
'label' => 'Optional features',
'content' => $this->renderPartial('view/features', ['survey' => $survey], true),
'content' => $this->renderPartial('update/features', ['survey' => $survey, 'form' => $form], true),
// 'active' => true
], [
'label' => 'Access control',
'content' => $this->renderPartial('view/access', ['survey' => $survey], true),
'content' => $this->renderPartial('update/access', ['survey' => $survey, 'form' => $form], true),

]

Expand All @@ -54,7 +66,7 @@
'color' => 'primary'
]);
echo TbHtml::closeTag('div');
echo TbHtml::endForm();
$this->endWidget();

?>
</div>
Expand Down
13 changes: 13 additions & 0 deletions application/views/surveys/update/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
echo TbHtml::well("Features below can be enabled / disabled while the survey is active.");

$expires = TbHtml::activeDateTimeLocalField($survey, 'expires', ['class' => 'form-control']);
$starts = TbHtml::activeDateTimeLocalField($survey, 'startdate', ['class' => 'form-control']);
echo $form->customControlGroup($expires, $survey, 'expires');

echo $form->customControlGroup($starts, $survey, 'startdate');

echo $form->dropDownListControlGroup($survey, 'usecaptcha', $survey->captchaOptions);
echo $form->checkBoxControlGroup($survey, 'bool_usecookie');

echo $form->checkBoxControlGroup($survey, 'bool_listpublic');
7 changes: 7 additions & 0 deletions application/views/surveys/update/data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
echo TbHtml::openTag('fieldset', []);
$key = 'bool_alloweditaftercompletion';
echo $form->checkBoxControlGroup($survey, $key, [
'label' => $survey->attributeLabels()[$key] . ' ' . TbHtml::link(TbHtml::icon('info-sign'), 'https://manual.limesurvey.org/Feature:' . $key, ['target' => '_blank'])
]);
echo TbHtml::closeTag('fieldset');
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
foreach ($options as $key => &$label) {
$label .= ' ' . TbHtml::link(TbHtml::icon('info-sign'), 'https://manual.limesurvey.org/Feature:' . $key, ['target' => '_blank']);
}
echo TbHtml::activeCheckBoxListControlGroup($survey, 'features', $options, ['formLayout' => TbHtml::FORM_LAYOUT_HORIZONTAL]);
echo TbHtml::hiddenField('id', $survey->sid);
echo $form->checkBoxListControlGroup($survey, 'features', $options);
echo TbHtml::closeTag('fieldset');
7 changes: 7 additions & 0 deletions application/views/surveys/update/general.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
echo TbHtml::openTag('fieldset', []);
echo $form->textFieldControlGroup($survey, 'admin');
echo $form->emailFieldControlGroup($survey, 'adminemail');
echo $form->emailFieldControlGroup($survey, 'bounce_email');
echo $form->textFieldControlGroup($survey, 'faxto');
echo TbHtml::closeTag('fieldset');
6 changes: 6 additions & 0 deletions application/views/surveys/update/languages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
echo TbHtml::openTag('fieldset', []);
echo $form->dropDownListControlGroup($survey, 'language', CHtml::listData(getLanguageData(), 'code', 'description'));
App()->clientScript->registerCss('languages', '#Survey_additionalLanguages .checkbox { display:inline-block; width: 19%;}');
echo $form->checkBoxListControlGroup($survey, 'additionalLanguages', CHtml::listData(getLanguageData(), 'code', 'description'));
echo TbHtml::closeTag('fieldset');
4 changes: 4 additions & 0 deletions application/views/surveys/update/presentation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
echo TbHtml::openTag('fieldset', []);
echo $form->dropDownListControlGroup($survey, 'format', $survey->formatOptions);
echo TbHtml::closeTag('fieldset');
Loading

0 comments on commit 84a36aa

Please sign in to comment.