Skip to content

Commit

Permalink
Fixed issue #14363: In theme option : current template is the default…
Browse files Browse the repository at this point in the history
… one

Dev: remove a deprecated file
  • Loading branch information
Shnoulle committed Dec 20, 2018
1 parent 05aa0a3 commit 6b3627a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
21 changes: 11 additions & 10 deletions application/controllers/admin/themeoptions.php
Expand Up @@ -71,16 +71,14 @@ public function create()


/**
* Updates a particular model.
* Updates a particular model (globally)
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function update($id)
{
$model = $this->loadModel($id);
$hasPermission = $model->sid ? (Permission::model()->hasSurveyPermission($model->sid, 'surveysettings', 'update')) : false;

if ($hasPermission || (Permission::model()->hasGlobalPermission('templates', 'update'))) {
if (Permission::model()->hasTemplatePermission($model->template_name,'update')) {
if (isset($_POST['TemplateConfiguration'])) {
$model->attributes = $_POST['TemplateConfiguration'];
if ($model->save()) {
Expand All @@ -89,7 +87,6 @@ public function update($id)
}
}
$this->_updateCommon($model);

} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions"));
Expand All @@ -103,7 +100,8 @@ public function update($id)
*/
public function updatesurvey($sid)
{
if ( Permission::model()->hasGlobalPermission('templates', 'update') || Permission::model()->hasSurveyPermission($sid,'surveysettings','update') ) {
if (Permission::model()->hasGlobalPermission('templates', 'update') || Permission::model()->hasSurveyPermission($sid,'surveysettings','update') ) {
// Did we really need hasGlobalPermission template ? We are inside survey : hasSurveyPermission only seem better
$model = TemplateConfiguration::getInstance(null, null, $sid);
if (isset($_POST['TemplateConfiguration'])) {
$model->attributes = $_POST['TemplateConfiguration'];
Expand All @@ -127,7 +125,7 @@ public function updatesurvey($sid)
public function updatesurveygroup($id = null, $gsid, $l = null)
{
if (Permission::model()->hasGlobalPermission('templates', 'update')) {

// @todo : review permission : template permission or group permission ?
$sTemplateName = $id !== null ? TemplateConfiguration::model()->findByPk($id)->template_name : null;
$model = TemplateConfiguration::getInstance($sTemplateName, $gsid);

Expand Down Expand Up @@ -332,14 +330,17 @@ public function getPreviewTag()
* Renders the template options form.
*
* @param TemplateConfiguration $model
* @param int $sid
* @param int $sid : survey id
* @param int $gsid : survey group id
* @return void
*/
private function _updateCommon(TemplateConfiguration $model, $sid = null)
private function _updateCommon(TemplateConfiguration $model, $sid = null,$gsid = null)
{
/* set the template to current one if option use some twig function (imageSrc for example) mantis #14363 */
$oTemplate = Template::model()->getInstance($model->template_name,$sid,$iSurveyGroupId);

$oModelWithInheritReplacement = TemplateConfiguration::model()->findByPk($model->id);
$templateOptionPage = $oModelWithInheritReplacement->optionPage;

Yii::app()->clientScript->registerPackage('bootstrap-switch', LSYii_ClientScript::POS_BEGIN);
$aData = array(
'model' => $model,
Expand Down
11 changes: 0 additions & 11 deletions application/views/system/error404.php

This file was deleted.

0 comments on commit 6b3627a

Please sign in to comment.