Commit 2d251feb authored by Raph El's avatar Raph El
Browse files

Test

parent 16b19665
......@@ -28,6 +28,7 @@ class IndexAction extends CAction
//Rest::json($params); exit;
$params = Form::getDataForAnswer($params);
var_dump(Yii::app()->session["budgetInputList"]); exit;
$params["answer"] = $answer;
// TODO améliorer getdataForAnser pour soit viré la création de lanswers soit charger la bonne answer
......@@ -38,16 +39,23 @@ class IndexAction extends CAction
$canEditAnswer = false;
$canSeeAnswer = false;
if(!empty(Yii::app()->session['userId'])){
$canEditForm = Form::canAdmin(Yii::app()->session['userId'], $form);
if(empty($canEditForm) && $mode == "fa")
$mode = "w";
$canEditAnswer = Form::canEditAnswer(Yii::app()->session['userId'], $params["answer"], $form, $parentForm);
if(empty($canEditAnswer)){
if($mode == "fa"){
$canEditForm = Form::canAdmin(Yii::app()->session['userId'], $form);
if(empty($canEditForm))
$mode = "w";
}
if( $mode == "w" || $mode == "fa" ){
$canEditAnswer = Form::canEditAnswer(Yii::app()->session['userId'], $params["answer"], $form, $parentForm);
if(empty($canEditAnswer))
$mode = "r";
else
$canSeeAnswer = true;
}
if(empty($canEditAnswer) && empty($canSeeAnswer)){
$canSeeAnswer = Form::canSeeAnswer(Yii::app()->session['userId'], $params["answer"], $form, $parentForm);
if($canSeeAnswer === true && !empty($mode) && ($mode == "w" || $mode == "fa") )
$mode = "r";
}else{
$canSeeAnswer = true;
}
}
// var_dump($canEditAnswer);
......
......@@ -681,7 +681,7 @@ class Form {
}
if(count($budgetInputList))
Yii::app()->session["budgetInputList"] = $budgetInputList;
var_dump($budgetInputList);
//use the cache
Yii::app()->session["forms"] = $allforms;
return $params;
......
......@@ -58,7 +58,7 @@ if( isset( $form["inputs"] ) ){ ?>
$editQuestionBtn = ($canEditForm) ? " <a class='btn btn-xs btn-danger editQuestion' href='javascript:;' data-form='".$form["id"]."' data-id='".$form["_id"]."' data-collection='".Form::COLLECTION."' data-key='".$key."' data-path='inputs.".$key."'><i class='fa fa-pencil'></i></a>".
" <a class='btn btn-xs btn-danger deleteLine' href='javascript:;' data-id='".$form["_id"]."' data-collection='".Form::COLLECTION."' data-key='question".$key."' data-path='inputs.".$key."'><i class='fa fa-trash'></i></a>" : "";
var_dump($canEditForm);
//var_dump($canEditForm);
$tpl = $input["type"];
if(in_array($tpl, ["textarea","markdown","wysiwyg"]))
......@@ -133,7 +133,7 @@ if( isset( $form["inputs"] ) ){ ?>
</form>
<?php }
if ($canEdit) { ?>
if ($canEditForm) { ?>
<div class="text-center">
<a href="javascript:;" class="addQuestion btn btn-danger" data-form="<?php echo $formId ?>" data-id="<?php echo $form['_id'] ?>" ><i class="fa fa-plus"></i> Ajouter Une Question</a>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment