Commit d6410cc8 authored by Raph El's avatar Raph El

Amélioration answers add context

parent 0f46e30a
......@@ -8,18 +8,19 @@ class IndexAction extends CAction
if(!empty($form))
$form = PHDB::findOneById( Form::COLLECTION , $form);
$context = null;
if(!empty($contextId) && !empty($contextType)){
$context = array(
$contextId => array(
"type" => $contextType
)
);
}
if(!empty($id)){
if($id == "new"){
if(!empty(Yii::app()->session["userId"])){
$context = null;
if(!empty($contextId) && !empty($contextType)){
$context = array(
$contextId => array(
"type" => $contextType
)
);
}
$answer = Answer::generateAnswer($form, false, $context);
$params["answerId"] = $answer["_id"];
$mode = "w" ;
......
<?php
class NewAction extends CAction
{
public function run($id=null, $type=null , $tpl=null)
public function run($id=null, $type=null , $tpl=null, $contextId=null, $contextType=null)
{
$this->getController()->layout = "//layouts/empty";
$params = array();
......@@ -21,9 +21,15 @@ class NewAction extends CAction
// ) )
]]], ["name"] ) ;
}
if(!empty($contextId))
$params["contextId"] = $contextId;
if(!empty($contextType))
$params["contextType"] = $contextType;
//var_dump($this->getController()->costum); exit;
$tpl= "survey.views.tpls.views.new";
if($tpl == null)
$tpl= "survey.views.tpls.views.new";
echo $this->getController()->renderPartial($tpl,$params );
......
......@@ -24,11 +24,16 @@ class Answer{
],
"created" => time()
];
if( !empty($context) )
$ans["context"] = $context;
else
$ans["context"] = $form["parent"];
$ans["context"] = $form["parent"];
if( !empty($context) ){
foreach ($context as $keyC => $valC) {
if(empty($ans["context"][$keyC])){
$ans["context"][$keyC] = $valC;
}
}
}
if($draft === true)
$ans["draft"] = true;
......
......@@ -14,8 +14,13 @@
<h3 class="panel-title"><?php echo @$value["name"] ; ?></h3>
</div>
<div class="panel-body">
<?php if(!empty(Yii::app()->session['userId'])){ ?>
<a class="lbh btn btn-success" href="#answer.index.id.new.form.<?php echo $key; ?>" style="font-size: 17px;"> Déposer un candidature</a>
<?php if(!empty(Yii::app()->session['userId'])){
$url = "#answer.index.id.new.form.".$key;
if(!empty($contextId) && !empty($contextType))
$url .= ".contextId.".$contextId.".contextType.".$contextType;
?>
<a class="lbh btn btn-success" href="<?php echo $url; ?>" style="font-size: 17px;"> Déposer un candidature</a>
<?php } else { ?>
<button class="btn btn-default bg-white letter-green bold" data-toggle="modal" data-target="#modalLogin" style="font-size: 17px;">
<i class="fa fa-sign-in"></i>
......
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