Commit d22d38a9 authored by Raph El's avatar Raph El

Hotfix

parent ff42b8b1
......@@ -6,14 +6,31 @@ class IndexAction extends CAction
$this->getController()->layout = "//layouts/empty";
$params = array();
if(!empty($id)){
$params["answerId"]=$id;
if($id == "new"){
if(!empty(Yii::app()->session["userId"])){
$answer = Answer::generateAnswer();
$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)));
}
}
$params = Form::getDataForAnswer($params);
$params = Form::getDataForAnswer($params);
// 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"]);
......@@ -26,6 +43,8 @@ class IndexAction extends CAction
$canSeeAnswer = Form::canSeeAnswer(Yii::app()->session['userId'], $params["answer"], $form, $parentForm);
if($canSeeAnswer === true && !empty($mode) && ($mode == "w" || $mode == "rplus") )
$mode = "r";
}else{
$canSeeAnswer = true;
}
}
// var_dump($canEditAnswer);
......@@ -34,7 +53,6 @@ class IndexAction extends CAction
$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 );
......
......@@ -14,13 +14,9 @@ class NewAction extends CAction
// }
// $params = Form::getDataForAnswer($params);
// $tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.forms.formWizard";
if(!empty(Yii::app()->session['userId'])){
echo "HERE";
}else{
$tpl= "survey.views.tpls.views.new";
echo $this->getController()->renderPartial($tpl,$params );
}
$tpl= "survey.views.tpls.views.new";
echo $this->getController()->renderPartial($tpl,$params );
}
......
<?php
class Answer{
const COLLECTION = "answers";
const CONTROLLER = "answer";
const ICON = "fa-calendar-check-o";
public static function getById($id, $fields=array()){
return PHDB::findOne( self::COLLECTION, array( "_id" => new MongoId((string)$id) ), $fields );
}
public static function generateAnswer(){
$costum = CacheHelper::getCostum();
$ans = [
"user" => Yii::app()->session["userId"],
"links"=>[
"answered" => [ Yii::app()->session["userId"] ] ,
//proposed,particpated,decision,financed,financed,referenced,commented,worked,payed,tested,validated
//each actor is connectable to his activitystream
],
"created" => time()
];
if(isset($costum["contextType"]) && isset($costum["contextId"])){
$ans["parentSlug"] = Slug::getSlugByIdAndCol($costum["contextId"], $costum["contextType"]);
}
$formList = null ;
if( !empty($costum["form"]) && !empty($costum["form"]["ids"]) ){
$formList = $costum["form"]["ids"];
$ans["formList"] = count($formList);
}
if( !empty($formList) ) {
$ans["formId"] = implode("|", $formList);
PHDB::insert(Answer::COLLECTION, $ans);
$answer = PHDB::findOne( Answer::COLLECTION, [ "_id" => new MongoId($ans["_id"]) ] ) ;
return $answer;
} else
return null;
}
}
?>
\ No newline at end of file
......@@ -766,21 +766,21 @@ class Form {
//si aucune reponse existe
//et qu'on a des input complexe alors on génere une answer
if( !isset($_GET['answer']) && $answer == null ){
if(isset($params["formList"])){
$generateAnswer = true;
}
else if(isset($form["inputs"])){
foreach ($form["inputs"] as $key => $inp)
{
if( stripos( $inp["type"] , "tpls.forms.cplx" ) !== false )
$generateAnswer = true;
}
}
}
if( isset($answerId) && $answerId == "new" )
$generateAnswer = true;
// if( !isset($_GET['answer']) && $answer == null ){
// if(isset($params["formList"])){
// $generateAnswer = true;
// }
// else if(isset($form["inputs"])){
// foreach ($form["inputs"] as $key => $inp)
// {
// if( stripos( $inp["type"] , "tpls.forms.cplx" ) !== false )
// $generateAnswer = true;
// }
// }
// }
// if( isset($answerId) && $answerId == "new" )
// $generateAnswer = true;
//on pré genere un anwser que quand il n'y en pas
//pour permettre le save onBlur , ou s'il y a des cplx forms
......@@ -791,25 +791,25 @@ class Form {
//il ne peut y avoir qu'un seul answer en cours simultanement
///TODO purger ANSwers via CRON
if( $generateAnswer )
{
//var_dump("create new" );
$ans = [
"formId" => $params["formId"],
"user" => Yii::app()->session["userId"],
"parentSlug" => $params["el"]["slug"],
"links"=>[
"answered" => [ Yii::app()->session["userId"] ] ,
//proposed ,particpated,decision,financed,financed,referenced,commented,worked,payed,tested,validated
//each actor is connectable to his activitystream
],
"created" => time()
];
if(isset($params["formList"]))
$ans["formList"] = count($params["formList"]);
PHDB::insert(Form::ANSWER_COLLECTION, $ans);
$answer = PHDB::findOne( Form::ANSWER_COLLECTION, [ "_id" => new MongoId($ans["_id"]) ] );
}
// if( $generateAnswer )
// {
// //var_dump("create new" );
// $ans = [
// "formId" => $params["formId"],
// "user" => Yii::app()->session["userId"],
// "parentSlug" => $params["el"]["slug"],
// "links"=>[
// "answered" => [ Yii::app()->session["userId"] ] ,
// //proposed ,particpated,decision,financed,financed,referenced,commented,worked,payed,tested,validated
// //each actor is connectable to his activitystream
// ],
// "created" => time()
// ];
// if(isset($params["formList"]))
// $ans["formList"] = count($params["formList"]);
// PHDB::insert(Form::ANSWER_COLLECTION, $ans);
// $answer = PHDB::findOne( Form::ANSWER_COLLECTION, [ "_id" => new MongoId($ans["_id"]) ] );
// }
// var_dump($params["el"]["slug"] );
// var_dump($params["formId"] );
......
......@@ -192,8 +192,13 @@ if(isset($this->costum["cms"]["color1"]))
<script type="text/javascript">
//to edit costum page pieces
var configDynForm = <?php echo json_encode($this->costum['dynForm']); ?>;
var answerId = <?php echo json_encode((String)$answer['_id']); ?>;
var mode = <?php echo json_encode($mode); ?>;
//information and structure of the form in this page
var tplCtx = {};
if(location.hash.indexOf("#answer.index.id.new")>=0){
history.replaceState("#answer.index.id.new", "", "#answer.index.id."+answerId+".mode."+mode);
}
jQuery(document).ready(function() {
......
......@@ -4,21 +4,29 @@
<div class="col-sm-10 col-sm-offset-1">
<h4>Etape</h4>
<div class="col-xs-12">
BLA BLA BLALALA
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas id fringilla nulla. Sed commodo tellus vestibulum condimentum mollis. Integer sit amet ex vel lectus posuere maximus. Duis diam justo, convallis ac ultricies pellentesque, porttitor quis nunc. Pellentesque finibus purus sit amet ipsum sagittis vehicula. Nunc laoreet laoreet purus, condimentum efficitur augue vestibulum eu. Suspendisse purus dui, commodo sed nibh a, faucibus semper ipsum. Curabitur in blandit odio, eget placerat ex. In porttitor quis sem vel vestibulum. Vivamus eget facilisis enim.
<br/><br/>
Quisque eu molestie risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi non nunc orci. Phasellus velit turpis, cursus scelerisque est id, rhoncus lacinia turpis. Etiam quis venenatis odio. Nam sollicitudin elementum faucibus. Ut pulvinar mi sit amet ante scelerisque, sit amet tempor enim sodales. Praesent imperdiet sit amet dolor vitae laoreet.
<br/><br/>
Ut mattis condimentum est. Praesent commodo dui sit amet augue elementum pulvinar. Maecenas sapien eros, volutpat quis rutrum a, faucibus quis dui. Fusce porta risus at arcu commodo, sit amet ullamcorper mauris pulvinar. Mauris rhoncus nibh ut ligula malesuada, sit amet auctor odio faucibus. Aenean a tempus nibh. Aliquam et sem et quam posuere accumsan eleifend at metus. Morbi non elementum dolor. Ut laoreet magna et hendrerit aliquet. Curabitur ut ante quis felis pulvinar dictum.
<br/><br/>
Sed enim odio, congue non lectus nec, ultricies congue nibh. Praesent scelerisque luctus nisl porttitor vulputate. Duis imperdiet cursus libero, et iaculis lacus finibus ut. Fusce malesuada gravida facilisis. Maecenas a urna purus. Sed hendrerit lectus nec nulla fermentum dapibus. Fusce in quam mi.
<br/><br/>
Ut mattis lacinia mattis. Morbi pharetra metus ligula, eget blandit neque fringilla vel. Mauris a orci a sem maximus scelerisque pulvinar vel arcu. Duis est est, hendrerit eu tincidunt non, ornare non massa. Donec sollicitudin tempor erat non vulputate. Ut nisl est, elementum vel aliquam et, euismod porttitor orci. Praesent rhoncus arcu vitae eros faucibus mattis. Nulla facilisi.
</div>
<div class="col-xs-12 padding-10">
<div class="col-xs-12 padding-10 text-center">
<?php
if(!empty(Yii::app()->session['userId'])){ ?>
<a class="lbh " href="#answer.index" style="font-size: 17px;"></a>
<a class="lbh btn btn-success" href="#answer.index.id.new" style="font-size: 17px;">Déposer un candidature</a>
<?php } else { ?>
<button class="letter-green font-montserrat btn-menu-connect margin-left-10 margin-right-10 menu-btn-top" data-toggle="modal" data-target="#modalLogin" style="font-size: 17px;">
<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>
<span class="hidden-xs"><small style="width:70%;">Se connecter</small></span>
</button>
<button class="letter-green font-montserrat btn-menu-connect margin-left-10 margin-right-10 menu-btn-top" data-toggle="modal" data-target="#modalLogin" style="font-size: 17px;">
<i class="fa fa-sign-in"></i>
<span class="hidden-xs"><small style="width:70%;">Crée un compte</small></span>
<span class="hidden-xs"><?php echo Yii::t("login", "Login") ?></span>
</button>
<button class="btn btn-default bg-white letter-blue bold" data-toggle="modal" data-target="#modalRegister" style="font-size: 17px;">
<i class="fa fa-plus-circle bold"></i>
<span class="hidden-xs"><?php echo Yii::t("login", "I create my account") ?></span>
</button>
<?php } ?>
</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