getController()->layout = "//layouts/empty"; $params = array(); if(!empty($form)) $form = PHDB::findOneById( Form::COLLECTION , $form); if(!empty($id)){ if($id == "new"){ if(!empty(Yii::app()->session["userId"])){ $answer = Answer::generateAnswer($form); $params["answerId"] = $answer["_id"]; $mode = "w" ; } else { 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")); exit; } } else { $params["answerId"]=$id; $answer = PHDB::findOne( Form::ANSWER_COLLECTION, array("_id"=>new MongoId($id))); //Rest::json($answer); exit; if(empty($form) && !empty($answer["form"])) $form = PHDB::findOneById( Form::COLLECTION , $answer["form"]); } $params["form"] = $form ; //Rest::json($params); exit; $params = Form::getDataForm($params); $params["answer"] = $answer; $canEditForm = false; $canAdminAnswer = false; $canEditAnswer = false; $canSeeAnswer = false; if( empty($mode) || ( $mode != "w" && $mode != "r" ) || ( !empty($answer["validated"]) && $answer["validated"] == true) ) $mode = "r"; if(!empty(Yii::app()->session['userId'])){ $canEditAnswer = Answer::canEdit($params["answer"], $form, Yii::app()->session['userId'], @$parentForm); $canAdminAnswer = Answer::canAdmin($params["answer"], $form); if($canEditAnswer === false && $canAdminAnswer === false) $canSeeAnswer = Answer::canAccess($params["answer"], $form, Yii::app()->session['userId'], @$parentForm); else $canSeeAnswer = true; } if( $mode == "w" && $canEditAnswer === false && $canAdminAnswer === false ) $mode = "r"; if($canSeeAnswer === true){ $params["canEditForm"] = $canEditForm; $params["canAdminAnswer"] = $canAdminAnswer; $params["canEdit"] = $canEditAnswer; $params["canSee"] = $canSeeAnswer; $params["mode"] = (!empty($mode) ? $mode : "r"); $tpl=(!empty($form["tpl"])) ? $form["tpl"] : "survey.views.tpls.forms.formWizard"; echo $this->getController()->renderPartial($tpl,$params ); } else { 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")); } } else { 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")); } } }