Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Mar 19, 2024
2 parents 5a464d3 + a61e6c0 commit 1e50bed
Show file tree
Hide file tree
Showing 28 changed files with 545 additions and 425 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -16,5 +16,5 @@
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
$config['assetsversionnumber'] = '30379';
$config['assetsversionnumber'] = '30381';
return $config;
9 changes: 5 additions & 4 deletions application/controllers/AjaxAlertController.php
Expand Up @@ -27,21 +27,22 @@ private function translateOptionsForWidget()
$customOptions = $request->getPost('customOptions', []);

$translatedOptions = [];
$translatedOptions['text'] = $request->getPost('message', 'message');
$translatedOptions['type'] = $request->getPost('alertType', 'success');
$translatedOptions['text'] = CHtml::encode($request->getPost('message', 'message'));
$translatedOptions['type'] = sanitize_alphanumeric($request->getPost('alertType', 'success'));
$knownOptions = ['tag', 'isFilled', 'showIcon', 'showCloseButton', 'timeout'];
foreach ($knownOptions as $knownOption) {
if (array_key_exists($knownOption, $customOptions)) {
if ($knownOption == 'tag') {
$translatedOptions[$knownOption] = $customOptions[$knownOption];
$translatedOptions[$knownOption] = sanitize_alphanumeric($customOptions[$knownOption]);
} elseif ($knownOption == 'timeout') {
$translatedOptions[$knownOption] = (int) $customOptions[$knownOption];
$translatedOptions[$knownOption] = intval($customOptions[$knownOption]);
} else {
$translatedOptions[$knownOption] = $customOptions[$knownOption] !== 'false';
}
}
}
if (array_key_exists('htmlOptions', $customOptions)) {
// htmlOptions is encoded by view
$translatedOptions['htmlOptions'] = json_decode_ls($customOptions['htmlOptions']);
}

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/PluginManagerController.php
Expand Up @@ -411,9 +411,9 @@ public function resetLoadError($pluginId)
$plugin->load_error_message = '';
$result = $plugin->update();
if ($result) {
Yii::app()->user->setFlash('success', sprintf(gt('Reset load error for plugin %d'), $pluginId));
Yii::app()->user->setFlash('success', sprintf(gt('Reset load error for plugin %s (%s)'), $plugin->name, $plugin->plugin_type));
} else {
Yii::app()->user->setFlash('error', sprintf(gt('Could not update plugin %d'), $pluginId));
Yii::app()->user->setFlash('error', sprintf(gt('Could not update plugin %s (%s)'), $plugin->name, $plugin->plugin_type));
}
$this->getController()->redirect($url);
} else {
Expand Down
9 changes: 8 additions & 1 deletion application/core/LSYii_AssetManager.php
Expand Up @@ -22,7 +22,14 @@ class LSYii_AssetManager extends CAssetManager
/* @inheritdoc */
protected function hash($path)
{
return sprintf('%x', crc32($path . Yii::app()->getConfig('globalAssetsVersion')));
return sprintf(
'%x',
crc32(
$path .
App()->getConfig('versionnumber') . // Always reset with version number
App()->getConfig('globalAssetsVersion') // Force reset between version number (for dev user)
)
);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion application/helpers/expressions/em_core_helper.php
Expand Up @@ -2221,7 +2221,12 @@ private function RDP_RunFunction($funcNameToken, $params)
}
break;
default:
$result = call_user_func($funcName, $params[0], $params[1]);
try {
$result = call_user_func($funcName, $params[0], $params[1]);
} catch (\Throwable $e) {
$this->RDP_AddError($e->getMessage(), $funcNameToken);
return false;
}
break;
}
}
Expand Down
15 changes: 9 additions & 6 deletions application/helpers/frontend_helper.php
Expand Up @@ -636,14 +636,17 @@ function getResponseTableReplacement($surveyid, $responseId, $emailLanguage, $bI
Yii::import('application.helpers.viewHelper');
foreach ($aFullResponseTable as $sFieldname => $fname) {
if (substr($sFieldname, 0, 4) === 'gid_') {
$ResultTableHTML .= "\t<tr class='printanswersgroup'><td colspan='2'>" . viewHelper::flatEllipsizeText($fname[0], true, 0) . "</td></tr>\n";
$ResultTableText .= "\n{$fname[0]}\n\n";
$questionText = viewHelper::flatEllipsizeText($fname[0], true, 0);
$ResultTableHTML .= "\t<tr class='printanswersgroup'><td colspan='2'>" . $questionText . "</td></tr>\n";
$ResultTableText .= "\n" . $questionText . "\n\n";
} elseif (substr($sFieldname, 0, 4) === 'qid_') {
$ResultTableHTML .= "\t<tr class='printanswersquestionhead'><td colspan='2'>" . viewHelper::flatEllipsizeText($fname[0], true, 0) . "</td></tr>\n";
$ResultTableText .= "\n{$fname[0]}\n";
$questionText = viewHelper::flatEllipsizeText($fname[0], true, 0);
$ResultTableHTML .= "\t<tr class='printanswersquestionhead'><td colspan='2'>" . $questionText . "</td></tr>\n";
$ResultTableText .= "\n" . $questionText . "\n";
} else {
$ResultTableHTML .= "\t<tr class='printanswersquestion'><td>" . viewHelper::flatEllipsizeText("{$fname[0]} {$fname[1]}", true, 0) . "</td><td class='printanswersanswertext'>" . CHtml::encode($fname[2]) . "</td></tr>\n";
$ResultTableText .= " {$fname[0]} {$fname[1]}: {$fname[2]}\n";
$questionText = viewHelper::flatEllipsizeText($fname[0], true, 0) . " " . viewHelper::flatEllipsizeText($fname[1], true, 0);
$ResultTableHTML .= "\t<tr class='printanswersquestion'><td>" . $questionText . "</td><td class='printanswersanswertext'>" . CHtml::encode($fname[2]) . "</td></tr>\n";
$ResultTableText .= " " . $questionText . ": {$fname[2]}\n";
}
}
$ResultTableHTML .= "</table>\n";
Expand Down
15 changes: 14 additions & 1 deletion application/helpers/questionHelper.php
Expand Up @@ -836,7 +836,7 @@ public static function getAttributesDefinitions()
);

self::$attributes["random_order"] = array(
"types" => Question::QT_EXCLAMATION_LIST_DROPDOWN . Question::QT_A_ARRAY_5_POINT . Question::QT_B_ARRAY_10_CHOICE_QUESTIONS . Question::QT_C_ARRAY_YES_UNCERTAIN_NO . Question::QT_E_ARRAY_INC_SAME_DEC . Question::QT_F_ARRAY . Question::QT_H_ARRAY_COLUMN . Question::QT_K_MULTIPLE_NUMERICAL . Question::QT_L_LIST . Question::QT_M_MULTIPLE_CHOICE . Question::QT_O_LIST_WITH_COMMENT . Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS . Question::QT_Q_MULTIPLE_SHORT_TEXT . Question::QT_R_RANKING . Question::QT_1_ARRAY_DUAL . Question::QT_COLON_ARRAY_NUMBERS . Question::QT_SEMICOLON_ARRAY_TEXT,
"types" => Question::QT_A_ARRAY_5_POINT . Question::QT_B_ARRAY_10_CHOICE_QUESTIONS . Question::QT_C_ARRAY_YES_UNCERTAIN_NO . Question::QT_E_ARRAY_INC_SAME_DEC . Question::QT_F_ARRAY . Question::QT_H_ARRAY_COLUMN . Question::QT_K_MULTIPLE_NUMERICAL . Question::QT_M_MULTIPLE_CHOICE . Question::QT_O_LIST_WITH_COMMENT . Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS . Question::QT_Q_MULTIPLE_SHORT_TEXT . Question::QT_1_ARRAY_DUAL . Question::QT_COLON_ARRAY_NUMBERS . Question::QT_SEMICOLON_ARRAY_TEXT,
'category' => gT('Display'),
'sortorder' => 100,
'inputtype' => 'singleselect',
Expand All @@ -848,6 +848,19 @@ public static function getAttributesDefinitions()
"caption" => gT('Random order')
);

self::$attributes["answer_order"] = array(
"types" => Question::QT_L_LIST . Question::QT_R_RANKING . Question::QT_EXCLAMATION_LIST_DROPDOWN,
'category' => gT('Display'),
'sortorder' => 100,
'inputtype' => 'singleselect',
'options' => array('normal' => gT('Normal'), 'random' => gT("Random"), 'alphabetical' => gT("Alphabetical")),
//1=>gT('Randomize on each page load') // Shnoulle : replace by yes till we have only one solution
//2=>gT('Randomize once on survey start') //Mdekker: commented out as code to handle this was removed in refactoring
'default' => 0,
"help" => gT('Present answer options in normal, random or alphabetical order'),
"caption" => gT('Answer options order')
);

self::$attributes["showpopups"] = array(
"types" => Question::QT_R_RANKING,
'category' => gT('Display'),
Expand Down
137 changes: 81 additions & 56 deletions application/models/Plugin.php
Expand Up @@ -128,7 +128,7 @@ public function getStatus()
if ($this->load_error == 1) {
return sprintf(
"<span data-bs-toggle='tooltip' title='%s' class='btntooltip ri-close-fill text-danger'></span>",
gT('Plugin load error')
CHtml::encode(sprintf(gT('Plugin load error : %s'), $this->load_error_message))
);
} elseif ($this->active == 1) {
return "<span class='ri-checkbox-blank-circle-fill'></span>";
Expand Down Expand Up @@ -191,6 +191,7 @@ public function getPossibleDescription()

/**
* Action buttons in plugin list.
* @deprecated 6.0
* @return string HTML
*/
public function getActionButtons()
Expand Down Expand Up @@ -223,6 +224,7 @@ public function getActionButtons()
}

/**
* @deprecated 6.0
* @return string HTML
*/
public function getActivateButton()
Expand Down Expand Up @@ -252,6 +254,7 @@ public function getActivateButton()


/**
* @deprecated 6.0
* @return string HTML
*/
public function getDeactivateButton()
Expand Down Expand Up @@ -281,6 +284,7 @@ public function getDeactivateButton()

/**
* @todo: Don't use JS native confirm.
* @deprecated 6.0
* @return string HTML
*/
protected function getUninstallButton()
Expand Down Expand Up @@ -310,6 +314,15 @@ protected function getUninstallButton()

public function getButtons(): string
{

$reloadUrl = Yii::app()->createUrl(
'admin/pluginmanager',
[
'sa' => 'resetLoadError',
'pluginId' => $this->id
]
);

$activateUrl = App()->getController()->createUrl(
'/admin/pluginmanager',
[
Expand All @@ -329,61 +342,73 @@ public function getButtons(): string
]
);
$dropdownItems = [];

$dropdownItems[] = [
'title' => gT('Activate'),
'url' => $activateUrl,
'iconClass' => "ri-play-fill text-success",
'enabledCondition' => $this->active == 0,
'linkAttributes' => [
'data-bs-toggle' => 'modal',
'data-bs-target' => '#confirmation-modal',
'data-btnclass' => 'btn-success',
'type' => 'submit',
'data-btntext' => gt("Activate"),
'data-title' => gt('Activate plugin'),
'data-message' => gT("Are you sure you want to activate this plugin?"),
'data-post-url' => $activateUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],

];
$dropdownItems[] = [
'title' => gT('Deactivate'),
'url' => $deactivateUrl,
'iconClass' => 'ri-stop-fill text-danger',
'enabledCondition' => $this->active == 1,
'linkAttributes' => [
'data-bs-toggle' => 'modal',
'data-bs-target' => '#confirmation-modal',
'data-btnclass' => 'btn-danger',
'type' => 'submit',
'data-btntext' => gt("Deactivate"),
'data-title' => gt('Deactivate plugin'),
'data-message' => gT("Are you sure you want to deactivate this plugin?"),
'data-post-url' => $deactivateUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],

];
$dropdownItems[] = [
'title' => gT('Uninstall'),
'url' => $uninstallUrl,
'iconClass' => 'ri-delete-bin-fill text-danger',
'enabledCondition' => $this->active == 0,
'linkAttributes' => [
'data-bs-toggle' => 'modal',
'data-bs-target' => '#confirmation-modal',
'data-btnclass' => 'btn-danger',
'type' => 'submit',
'data-btntext' => gt("Uninstall"),
'data-title' => gt('Uninstall plugin'),
'data-message' => gT("Are you sure you want to uninstall this plugin?"),
'data-post-url' => $uninstallUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],
];

if ($this->load_error) {
$dropdownItems[] = [
'title' => gT('Attempt plugin reload'),
'url' => $reloadUrl,
'iconClass' => "ri-refresh-line text-warning",
'enabledCondition' => $this->load_error == 1,
'linkAttributes' => [
'data-post-url' => $reloadUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],

];
} else {
$dropdownItems[] = [
'title' => gT('Activate'),
'url' => $activateUrl,
'iconClass' => "ri-play-fill text-success",
'enabledCondition' => $this->active == 0,
'linkAttributes' => [
'data-bs-toggle' => 'modal',
'data-bs-target' => '#confirmation-modal',
'data-btnclass' => 'btn-success',
'type' => 'submit',
'data-btntext' => gt("Activate"),
'data-title' => gt('Activate plugin'),
'data-message' => gT("Are you sure you want to activate this plugin?"),
'data-post-url' => $activateUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],

];
$dropdownItems[] = [
'title' => gT('Deactivate'),
'url' => $deactivateUrl,
'iconClass' => 'ri-stop-fill text-danger',
'enabledCondition' => $this->active == 1,
'linkAttributes' => [
'data-bs-toggle' => 'modal',
'data-bs-target' => '#confirmation-modal',
'data-btnclass' => 'btn-danger',
'type' => 'submit',
'data-btntext' => gt("Deactivate"),
'data-title' => gt('Deactivate plugin'),
'data-message' => gT("Are you sure you want to deactivate this plugin?"),
'data-post-url' => $deactivateUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],

];
$dropdownItems[] = [
'title' => gT('Uninstall'),
'url' => $uninstallUrl,
'iconClass' => 'ri-delete-bin-fill text-danger',
'enabledCondition' => $this->active == 0,
'linkAttributes' => [
'data-bs-toggle' => 'modal',
'data-bs-target' => '#confirmation-modal',
'data-btnclass' => 'btn-danger',
'type' => 'submit',
'data-btntext' => gt("Uninstall"),
'data-title' => gt('Uninstall plugin'),
'data-message' => gT("Are you sure you want to uninstall this plugin?"),
'data-post-url' => $uninstallUrl,
'data-post-datas' => json_encode(['pluginId' => $this->id]),
],
];
}
return App()->getController()->widget('ext.admin.grid.GridActionsWidget.GridActionsWidget', ['dropdownItems' => $dropdownItems], true);
}

Expand Down
3 changes: 3 additions & 0 deletions application/models/QuestionTemplate.php
Expand Up @@ -381,9 +381,12 @@ public function getCustomAttributes()
* @param string $type
* @return array
* @todo Move to QuestionTheme?
* @todo This is not the same as QuestionTheme::findQuestionMetaDataForAllTypes() which is the database layer
* @todo this should check the filestructure instead of the database as this is the filestructure layer
*/
public static function getQuestionTemplateList($type)
{
// todo: incorrect, this should check the filestructure instead of the database as this is the filestructure layer
/** @var QuestionTheme[] */
$questionThemes = QuestionTheme::model()->findAllByAttributes(
[],
Expand Down
3 changes: 1 addition & 2 deletions application/models/SurveyURLParameter.php
Expand Up @@ -31,11 +31,10 @@ class SurveyURLParameter extends LSActiveRecord
*/
public function rules()
{
return [
return [
['sid', 'required'],
['sid', 'numerical', 'integerOnly' => true],
['parameter', 'required'],
['targetqid', 'required'],
['targetqid', 'numerical', 'integerOnly' => true],
['targetsqid', 'numerical', 'integerOnly' => true, 'allowEmpty' => true],
];
Expand Down

0 comments on commit 1e50bed

Please sign in to comment.