Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Dec 12, 2023
2 parents 424fb24 + 3158c70 commit 85341c3
Show file tree
Hide file tree
Showing 41 changed files with 322 additions and 234 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'] = '30366';
$config['assetsversionnumber'] = '30367';
return $config;
10 changes: 5 additions & 5 deletions application/controllers/QuotasController.php
Expand Up @@ -36,7 +36,7 @@ public function actionIndex($surveyid)
{
$surveyid = sanitize_int($surveyid);
if (!Permission::model()->hasSurveyPermission($surveyid, 'quotas')) {
throw new CHttpException(403, gT("You do not have permission on this survey."));
throw new CHttpException(403, gT("You do not have permission for this survey."));
}
$oSurvey = Survey::model()->findByPk($surveyid);
$aData['surveyid'] = $oSurvey->sid;
Expand Down Expand Up @@ -104,8 +104,8 @@ public function actionIndex($surveyid)
public function actionQuickCSVReport($surveyid)
{
$surveyid = sanitize_int($surveyid);
if (!Permission::model()->hasSurveyPermission($surveyId, 'quotas')) {
throw new CHttpException(403, gT("You do not have permission on this survey."));
if (!Permission::model()->hasSurveyPermission($surveyid, 'quotas')) {
throw new CHttpException(403, gT("You do not have permission for this survey."));
}
$oSurvey = Survey::model()->findByPk($surveyid);

Expand Down Expand Up @@ -133,7 +133,7 @@ public function actionAddNewQuota($surveyid)
{
$surveyid = sanitize_int($surveyid);
if (!Permission::model()->hasSurveyPermission($surveyid, 'quotas', 'create')) {
throw new CHttpException(403, gT("You do not have permission on this survey."));
throw new CHttpException(403, gT("You do not have permission for this survey."));
}
Yii::app()->loadHelper('admin.htmleditor');

Expand Down Expand Up @@ -435,7 +435,7 @@ private function getQuotaWithPermission($quotaId, $sPermission = 'read')
throw new CHttpException(404, gT("Quota not found."));
}
if (!Permission::model()->hasSurveyPermission($oQuota->sid, 'quotas', $sPermission)) {
throw new CHttpException(403, gT("You do not have permission on this quota."));
throw new CHttpException(403, gT("You do not have permission for this quota."));
}
return $oQuota;
}
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/UserGroupController.php
Expand Up @@ -118,7 +118,7 @@ public function actionViewGroup($ugid, bool $header = false)
|| ($userGroup->hasUser(Yii::app()->user->id) && Permission::model()->hasGlobalPermission('usergroups', 'read')) // inside group and have global UserGroup view
)
) {
throw new CHttpException(403, gT("Access forbidden: you do not have permission to view this user group."));
throw new CHttpException(403, gT("No access : you do not have permission to this users group."));
}

$aData = [];
Expand Down Expand Up @@ -471,7 +471,7 @@ public function actionMailToAllUsersInGroup(int $ugid)
!Permission::model()->hasGlobalPermission('superadmin', 'read') // User is not a superadmin
&& $userGroup->owner_id != $currentUserId // User is not owner
) {
throw new CHttpException(403, gT("Access forbidden: you do not have permission to send emails to all users."));
throw new CHttpException(403, gT("No access : you do not have permission to send emails to all users."));
}
$redirectUrl = App()->createUrl("userGroup/viewGroup", ['ugid' => $ugid]);
$aData = [];
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/UserManagementController.php
Expand Up @@ -1324,13 +1324,13 @@ public function actionBatchApplyRoles()
$aResults[$sItem]['title'] = $model->users_name;
if ($model->uid == Yii::app()->user->id) {
$aResults[$sItem]['result'] = false;
$aResults[$sItem]['error'] = gT("You can not update your own roles.");
$aResults[$sItem]['error'] = gT("You are not allowed to update your own roles.");
continue;
}
$userManager = new UserManager(Yii::app()->user, $model);
if (!$userManager->canAssignRole()) {
$aResults[$sItem]['result'] = false;
$aResults[$sItem]['error'] = gT('You can not set role to this user.');
$aResults[$sItem]['error'] = gT('You are not allowed to assign a role to this user.');
} else {
foreach ($aUserRoleIds as $iUserRoleId) {
$aResults[$sItem]['result'] = Permissiontemplates::model()->applyToUser($sItem, $iUserRoleId);
Expand Down
40 changes: 0 additions & 40 deletions application/core/LSYii_Application.php
Expand Up @@ -591,44 +591,4 @@ private function setSessionByDB($aApplicationConfig)
'lifetime' => $lifetime
]);
}

/**
* Creates an absolute URL based on the given controller and action information.
* @param string $route the URL route. This should be in the format of 'ControllerID/ActionID'.
* @param array $params additional GET parameters (name=>value). Both the name and value will be URL-encoded.
* @param string $schema schema to use (e.g. http, https). If empty, the schema used for the current request will be used.
* @param string $ampersand the token separating name-value pairs in the URL.
* @return string the constructed URL
*/
public function createPublicUrl($route, $params = array(), $schema = '', $ampersand = '&')
{
$sPublicUrl = $this->getPublicBaseUrl(true);
$sActualBaseUrl = Yii::app()->getBaseUrl(true);
if ($sPublicUrl !== $sActualBaseUrl) {
$url = parent::createAbsoluteUrl($route, $params, $schema, $ampersand);
if (substr((string)$url, 0, strlen((string)$sActualBaseUrl)) == $sActualBaseUrl) {
$url = substr((string)$url, strlen((string)$sActualBaseUrl));
}
return trim((string)$sPublicUrl, "/") . $url;
} else {
return parent::createAbsoluteUrl($route, $params, $schema, $ampersand);
}
}

/**
* Returns the relative URL for the application while
* considering if a "publicurl" config parameter is set to a valid url
* @param boolean $absolute whether to return an absolute URL. Defaults to false, meaning returning a relative one.
* @return string the relative or the configured public URL for the application
*/
public function getPublicBaseUrl($absolute = false)
{
$sPublicUrl = Yii::app()->getConfig("publicurl");
$aPublicUrl = parse_url($sPublicUrl);
$baseUrl = parent::getBaseUrl($absolute);
if (isset($aPublicUrl['scheme']) && isset($aPublicUrl['host'])) {
$baseUrl = $sPublicUrl;
}
return $baseUrl;
}
}
47 changes: 40 additions & 7 deletions application/core/QuestionTypes/Date/RenderDate.php
Expand Up @@ -128,7 +128,13 @@ private function getDaySelect($iCurrent)
{
return Yii::app()->twigRenderer->renderQuestion(
$this->getMainView() . '/dropdown/rows/day',
array('dayId' => $this->sSGQA, 'currentday' => $iCurrent),
array(
'dayId' => $this->sSGQA,
'currentday' => $iCurrent,
'lang' => [
'Day' => gT("Day")
]
),
true
);
}
Expand All @@ -138,7 +144,14 @@ private function getMonthSelect($iCurrent)

return Yii::app()->twigRenderer->renderQuestion(
$this->getMainView() . '/dropdown/rows/month',
array('monthId' => $this->sSGQA, 'currentmonth' => $iCurrent, 'montharray' => $this->getTranslatorData()['montharray']),
array(
'monthId' => $this->sSGQA,
'currentmonth' => $iCurrent,
'montharray' => $this->getTranslatorData()['montharray'],
'lang' => [
'Month' => gT("Month")
]
),
true
);
}
Expand Down Expand Up @@ -185,7 +198,10 @@ private function getYearSelect($iCurrent)
'yearmax' => $yearmax,
'reverse' => $reverse,
'yearmin' => $yearmin,
'step' => $step
'step' => $step,
'lang' => [
'Year' => gT("Year")
]
),
true
);
Expand All @@ -195,7 +211,14 @@ private function getHourSelect($iCurrent, $datepart)
{
return Yii::app()->twigRenderer->renderQuestion(
$this->getMainView() . '/dropdown/rows/hour',
array('hourId' => $this->sSGQA, 'currenthour' => $iCurrent, 'datepart' => $datepart),
array(
'hourId' => $this->sSGQA,
'currenthour' => $iCurrent,
'datepart' => $datepart,
'lang' => [
'Hour' => gT("Hour")
]
),
true
);
}
Expand All @@ -208,7 +231,10 @@ private function getMinuteSelect($iCurrent, $datepart)
'minuteId' => $this->sSGQA,
'currentminute' => $iCurrent,
'dropdown_dates_minute_step' => $this->getQuestionAttribute('dropdown_dates_minute_step'),
'datepart' => $datepart
'datepart' => $datepart,
'lang' => [
'Minute' => gT("Minute")
]
),
true
);
Expand Down Expand Up @@ -325,8 +351,7 @@ public function renderDropdownDates($dateoutput, $coreClass)
LSYii_ClientScript::POS_POSTSCRIPT,
true
);



// ==> answer
$answer = Yii::app()->twigRenderer->renderQuestion(
$this->getMainView() . '/dropdown/answer',
Expand All @@ -339,6 +364,14 @@ public function renderDropdownDates($dateoutput, $coreClass)
'checkconditionFunction' => $this->checkconditionFunction . '(this.value, this.name, this.type)',
'dateformatdetails' => $this->aDateformatDetails['jsdate'],
'dateformat' => $this->aDateformatDetails['jsdate'],
/* language part, to be translated (see issue #19294) */
'lang' => [
'Day' => gT("Day"),
'Month' => gT("Month"),
'Year' => gT("Year"),
'Hour' => gT("Hour"),
'Minute' => gT("Minute"),
]
),
true
);
Expand Down
40 changes: 40 additions & 0 deletions application/core/Traits/LSApplicationTrait.php
Expand Up @@ -35,4 +35,44 @@ public function getCurrentUserId()
}
return $this->currentUserId;
}

/**
* Creates an absolute URL based on the given controller and action information.
* @param string $route the URL route. This should be in the format of 'ControllerID/ActionID'.
* @param array $params additional GET parameters (name=>value). Both the name and value will be URL-encoded.
* @param string $schema schema to use (e.g. http, https). If empty, the schema used for the current request will be used.
* @param string $ampersand the token separating name-value pairs in the URL.
* @return string the constructed URL
*/
public function createPublicUrl($route, $params = array(), $schema = '', $ampersand = '&')
{
$sPublicUrl = $this->getPublicBaseUrl(true);
$sActualBaseUrl = $this->getBaseUrl(true);
if ($sPublicUrl !== $sActualBaseUrl) {
$url = $this->createAbsoluteUrl($route, $params, $schema, $ampersand);
if (substr((string)$url, 0, strlen((string)$sActualBaseUrl)) == $sActualBaseUrl) {
$url = substr((string)$url, strlen((string)$sActualBaseUrl));
}
return trim((string)$sPublicUrl, "/") . $url;
} else {
return $this->createAbsoluteUrl($route, $params, $schema, $ampersand);
}
}

/**
* Returns the relative URL for the application while
* considering if a "publicurl" config parameter is set to a valid url
* @param boolean $absolute whether to return an absolute URL. Defaults to false, meaning returning a relative one.
* @return string the relative or the configured public URL for the application
*/
public function getPublicBaseUrl($absolute = false)
{
$sPublicUrl = Yii::app()->getConfig("publicurl");
$aPublicUrl = parse_url($sPublicUrl);
$baseUrl = $this->getBaseUrl($absolute);
if (isset($aPublicUrl['scheme']) && isset($aPublicUrl['host'])) {
$baseUrl = $sPublicUrl;
}
return $baseUrl;
}
}
4 changes: 2 additions & 2 deletions application/core/plugins/AzureOAuthSMTP/AzureOAuthSMTP.php
Expand Up @@ -66,7 +66,7 @@ public function beforeActivate()
if (!(PHP_VERSION_ID >= 70300)) {
$event = $this->getEvent();
$event->set('success', false);
$event->set('message', gT("This plugin requires PHP 7.3 or above."));
$event->set('message', gT("This plugin requires PHP version 7.3 or higher."));
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ protected function afterRefreshTokenRetrieved($provider, $token)
*/
protected function getDisplayName()
{
return gT('Azure');
return 'Azure';
}

/**
Expand Down
5 changes: 2 additions & 3 deletions application/core/plugins/GoogleOAuthSMTP/GoogleOAuthSMTP.php
Expand Up @@ -76,8 +76,7 @@ private function getHelpContent()
gT("Setup the OAuth 2.0 Web Application in %s."),
gT("Google Cloud Platform Console"),
gT("Redirect URI:"),
gT("You can find more details %s."),
gT("here"),
gT("You can find more details %shere%s."),
gT("Activate the plugin."),
gT("Set the 'Client ID' and 'Client Secret' below and save the settings."),
gT("Click the 'Get Token' button to open Google's consent screen in a new window."),
Expand Down Expand Up @@ -220,7 +219,7 @@ public function beforeEmailDispatch()
*/
protected function getDisplayName()
{
return gT('Google');
return 'Google';
}

public function beforePrepareRedirectToAuthPage()
Expand Down
2 changes: 1 addition & 1 deletion application/core/plugins/GoogleOAuthSMTP/views/Help.twig
Expand Up @@ -20,7 +20,7 @@
<li>
<div>{{ sprintf(gT("Setup the OAuth 2.0 Web Application in %s."), '<a href="https://console.cloud.google.com/" target="_blank">' ~ gT("Google Cloud Platform Console") ~ ' <span class="fa fa-external-link"></span></a>') }}</div>
<div class="text-break"><strong>{{ gT("Redirect URI:") }}</strong> {{ redirectUri }}</div>
<div>{{ sprintf(gT("You can find more details %s."), '<a href="https://support.google.com/cloud/answer/6158849" target="_blank">' ~ gT("here") ~ ' <span class="fa fa-external-link"></span></a>') }}</div>
<div>{{ sprintf(gT("You can find more details %shere%s"), '<a href="https://support.google.com/cloud/answer/6158849" target="_blank">', ' <span class="fa fa-external-link"></span></a>') }}</div>
</li>
<li>{{ gT("Activate the plugin.") }}</li>
<li>{{ gT("Set the 'Client ID' and 'Client Secret' below and save the settings.") }}</li>
Expand Down
2 changes: 1 addition & 1 deletion application/extensions/AccordionWidget/AccordionWidget.php
Expand Up @@ -26,7 +26,7 @@ public function normaliseItems($items)
'id' => $item['id'] ?? $this->id . '_item_' . bin2hex(random_bytes(2)),
'title' => $item['title'] ?? null,
'content' => $item['content'] ?? null,
'open' => $item['open'] ?? false,
'open' => $item['open'] ?? true,
'style' => $item['style'] ?? ''
];
}, $items);
Expand Down
6 changes: 3 additions & 3 deletions application/extensions/AccordionWidget/views/accordion.php
Expand Up @@ -3,18 +3,18 @@
<div class="accordion-item" style="<?=$item['style']?>">
<h2 class="accordion-header" id="<?=$item['id']?>">
<button
class="accordion-button"
class="accordion-button <?= $item['open'] ? '' : 'collapsed' ?>"
type="button"
data-bs-toggle="collapse"
data-bs-target="#<?=$item['id']?>-body"
aria-expanded="true"
aria-expanded="<?= $item['open'] ? 'true' : 'false' ?>"
aria-controls="<?=$item['id']?>">
<?=gT($item['title'])?>
</button>
</h2>
<div
id="<?=$item['id']?>-body"
class="accordion-collapse collapse show"
class="accordion-collapse collapse <?= $item['open'] ? 'show' : '' ?>"
aria-labelledby="<?=$item['id']?>"
>
<div class="accordion-body">
Expand Down
5 changes: 4 additions & 1 deletion application/helpers/admin/export/CsvWriter.php
Expand Up @@ -96,11 +96,14 @@ public function close()
/**
* Returns the value with all necessary escaping needed to place it into a CSV string.
*
* @param string $value
* @param string|null $value
* @return string
*/
protected function csvEscape($value)
{
if (is_null($value)) {
return '';
}
$sString = preg_replace(array('~\R~u'), array("\n"), $value);
return '"' . str_replace('"', '""', $sString) . '"';
}
Expand Down

0 comments on commit 85341c3

Please sign in to comment.