Commit 642d9220 authored by Raph El's avatar Raph El
Browse files

Hotfix answers, mode views read et write

parent 7cbc3e03
......@@ -4,12 +4,17 @@ class IndexAction extends CAction
public function run($id=null, $answer=null, $tpl=null, $mode=null)
{
$this->getController()->layout = "//layouts/empty";
$params = array();
if(!empty($id)){
$params["answerId"]=$id;
}
$params = Form::getDataForAnswer($params);
// $answer = PHDB::findOne( Form::ANSWER_COLLECTION, array("_id"=>new MongoId($id)));
// TODO améliorer getdataForAnser pour soit viré la création de lanswers soit charger la bonne answer
$answer = PHDB::findOne( Form::ANSWER_COLLECTION, array("_id"=>new MongoId($id)));
$params["answer"] = $answer;
$form = PHDB::findOne( Form::COLLECTION , array("id"=>$answer["formId"]));
$parentForm = Slug::getElementBySlug($form["id"]);
......@@ -23,16 +28,21 @@ class IndexAction extends CAction
$mode = "r";
}
}
// var_dump($canEditAnswer);
// var_dump($canSeeAnswer);
if($canEditAnswer === true || $canSeeAnswer === true){
$params["canEdit"] = $canEditAnswer;
$params["canSee"] = $canSeeAnswer;
$params["mode"] = (!empty($mode) ? $mode : "r");
//Rest::json($params); exit;
//$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.forms.formWizard";
$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.views.index";
echo $this->getController()->renderPartial($tpl,$params );
} else {
echo "Erreur";
if(Yii::app()->request->isAjaxRequest)
echo $this->getController()->renderPartial("co2.views.default.unTpl",array("msg"=>Yii::t("common", "You are not allow to access to this answer"),"icon"=>"fa-lock"));
else
$this->getController()->render("co2.views.default.unTpl",array("msg"=>Yii::t("common", "You are not allow to access to this answer"),"icon"=>"fa-lock"));
}
}
......
......@@ -416,9 +416,11 @@ class Form {
public static function canSeeAnswer($userId, $answer, $form, $parentForm){
if(self::canEditAnswer($userId, $answer, $form, $parentForm))
return true;
else if(Costum::sameFunction("canSeeAnswer", array("answer"=>$answer))){
return true;
}
// else if(Costum::sameFunction("canSeeAnswer", array("answer"=>$answer))){
// return true;
// }
else if(Costum::isSameFunction("canEditAnswer", array("answer"=>$answer)))
return Costum::sameFunction("canEditAnswer", array("answer"=>$answer));
return false;
}
public static function canEditAnswer($userId, $answer, $form, $parentForm){
......@@ -426,13 +428,16 @@ class Form {
return true;
else if($answer["user"] == $userId)
return true;
else if(Authorisation::canEditItem( Yii::app()->session["userId"], $parentForm["type"], $parentForm["id"] ))
return true;
else if(Costum::sameFunction("canEditAnswer", array("answer"=>$answer)))
else if(Authorisation::canEditItem(Yii::app()->session["userId"], $parentForm["type"], $parentForm["id"] ))
return true;
// else if(Costum::sameFunction("canEditAnswer", array("answer"=>$answer)))
// return true;
else if(Costum::isSameFunction("canEditAnswer", array("answer"=>$answer)))
return Costum::sameFunction("canEditAnswer", array("answer"=>$answer));
return false;
}
public static function canAdmin($id, $form = array()){
if(empty($form) && @$id)
$form = PHDB::findOne( Form::COLLECTION , array("_id"=>new MongoId($id)));
......
......@@ -9,9 +9,12 @@ if($mode == "r"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php
foreach ($value as $keyAdd => $valAdd) {
echo $valAdd["name"];
if(!empty($value)){
foreach ($value as $keyAdd => $valAdd) {
echo $valAdd["name"];
}
}
?>
</div>
<?php
......
......@@ -109,7 +109,8 @@ var formInputsHere = formInputs;
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='".@$form["id"]."desc' data-type='textarea' data-markdown='1' data-path='costum.cms.".@$form["id"]."desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>";
echo "</div>";
echo "<div class='markdown'>";
//echo "<div class='markdown'>";
echo "<div class=''>";
echo $this->renderPartial("survey.views.tpls.forms.formSection",
[ "formId" => $v,
"form" => $form,
......@@ -140,13 +141,14 @@ jQuery(document).ready(function() {
descHtml = dataHelper.markdownToHtml($(v).html());
$(v).html(descHtml);
});
// Todo BUG en nav private
if( localStorage !== null && localStorage.wizardStep !== null)
showStepForm(localStorage.wizardStep);
});
function showStepForm(id){
mylog.log("showStepForm", id);
$(".sectionStep").addClass("hide");
$(id).removeClass("hide");
localStorage.setItem("wizardStep",id);
......
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