Commit afc94b48 authored by thomas craipeau's avatar thomas craipeau

refactor costum session change

parent a8c5940b
......@@ -637,19 +637,23 @@ class Form {
return $res;
}
public static function canFormAccess($rules){
$costum = CacheHelper::getCostum();
//WARNING la c'est ce qui est lier à l'user du costum connecté
if(Authorisation::isInterfaceAdmin())
return true;
if(isset($rules["roles"])
&& isset(Yii::app()->session["costum"]["hasRoles"])
&& !empty(array_intersect(Yii::app()->session["costum"]["hasRoles"], $rules["roles"])))
&& isset(Yii::app()->session["costum"][$costum["slug"]]["hasRoles"])
&& !empty(array_intersect(Yii::app()->session["costum"][$costum["slug"]]["hasRoles"], $rules["roles"])))
return true;
return false;
}
public static function getFormData($params){
if(isset(Yii::app()->session["costum"]["form"]["rules"])){
$costum = CacheHelper::getCostum();
//WARNING la c'est bien data que l'on veut
if(isset($costum["form"]["rules"])){
foreach ($params["formList"] as $k => $value) {
if(isset(Yii::app()->session["costum"]["form"]["rules"][$value])){
if(!self::canFormAccess(Yii::app()->session["costum"]["form"]["rules"][$value])){
if(isset($costum["form"]["rules"][$value])){
if(!self::canFormAccess($costum["form"]["rules"][$value])){
array_splice($params["formList"], $k, -1);
}
}
......@@ -686,12 +690,14 @@ class Form {
public static function getDataForAnswer($params){
//var_dump(Yii::app()->session['costum']);exit;
if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->session["costum"]["contextId"]))
$params["el"] = Element::getByTypeAndId(Yii::app()->session["costum"]["contextType"], Yii::app()->session["costum"]["contextId"] );
//WARNING
$costum = CacheHelper::getCostum();
if(isset($costum["contextType"]) && isset($costum["contextId"]))
$params["el"] = Element::getByTypeAndId($costum["contextType"], $costum["contextId"] );
if(isset(Yii::app()->session['costum']["hasOpenForm"])){
if(isset(Yii::app()->session['costum']["isMultiForms"])){
if(isset($costum["hasOpenForm"])){
if(isset($costum["isMultiForms"])){
$answerId=null;
$answer=null;
$generateAnswer = false;
......@@ -708,8 +714,8 @@ class Form {
$params["formList"] = explode("|", $answer["formId"]);
$params["formId"] = $answer["formId"];
}else if(isset(Yii::app()->session["costum"]["form"])){
$params["formList"] = Yii::app()->session["costum"]["form"]["ids"];
}else if(isset($costum["form"])){
$params["formList"] = $costum["form"]["ids"];
$params["formId"] = implode("|", $params["formList"]);
}
$params=self::getFormData($params);
......@@ -717,7 +723,7 @@ class Form {
if(isset($_GET["form"]))
$params["formId"] = $_GET["form"];
else
$params["formId"] = (isset(Yii::app()->session["costum"]["form"]["id"])) ? Yii::app()->session["costum"]["form"]["id"] : Form::generateOpenForm( $el["slug"] );
$params["formId"] = (isset($costum["form"]["id"])) ? $costum["form"]["id"] : Form::generateOpenForm( $el["slug"] );
}
......@@ -734,7 +740,7 @@ class Form {
if(!isset(Yii::app()->session["costum"]["form"]["oneAnswerPerPerson"]) || count($myAnswers) == 0){
if(!isset($costum["form"]["oneAnswerPerPerson"]) || count($myAnswers) == 0){
//si ya qu'une réponse et on la charge directe
if(count($myAnswers) == 1 )
$answer = $myAnswers[ array_keys($myAnswers)[0] ];
......
......@@ -7,10 +7,10 @@
var DFdata = {
'tpl' : '<?php echo $tpl ?>',
"id" : "<?php echo Yii::app()->session["costum"]["contextId"] ?>"
"id" : "<?php echo $this->costum["contextId"] ?>"
};
costum.col = "<?php echo Yii::app()->session["costum"]["contextType"] ?>";
costum.ctrl = "<?php echo Element::getControlerByCollection(Yii::app()->session["costum"]["contextType"]) ?>";
costum.col = "<?php echo $this->costum["contextType"] ?>";
costum.ctrl = "<?php echo Element::getControlerByCollection($this->costum["contextType"]) ?>";
var configDynForm = <?php echo json_encode(Yii::app()->session['costum']['dynForm']); ?>;
var tplsList = <?php echo json_encode((isset(Yii::app()->session['costum']['tpls'])) ? Yii::app()->session['costum']['tpls']:null); ?>;
......@@ -227,10 +227,10 @@ jQuery(document).ready(function() {
<div class="alert alert-danger text-center" id="acceptAndAdmin" >
<?php //echo Yii::app()->session["costum"]["contextId"]."<br/>" ?>
<?php //echo Yii::app()->session["costum"]["contextType"]."<br/>" ?>
<?php //echo Yii::app()->session["costum"]["contextSlug"]."<br/>" ?>
<?php //var_dump(Yii::app()->session["costum"]) ?>
<?php //echo $this->costum["contextId"]."<br/>" ?>
<?php //echo $this->costum["contextType"]."<br/>" ?>
<?php //echo $this->costum["contextSlug"]."<br/>" ?>
<?php //var_dump($this->costum) ?>
<?php if(isset($test) ){ ?>
<strong>Hey!</strong> Is this what you want ?
......@@ -240,7 +240,7 @@ jQuery(document).ready(function() {
?>
<!-- <strong>Configure</strong> your Costum Template <a href="/costum/co/config/slug/<?php //echo $slug ?>" class="btn btn-danger"><i class="fa fa-pencil"></i> here </a> -->
<a class="btn btn-default" href="javascript:previewTpl();"><i class="fa fa-eye"></i> Preview</a>
<a class="btn btn-default" href="#@<?= Yii::app()->session["costum"]["contextSlug"] ?>" data-hash="#page.type.<?= Yii::app()->session["costum"]["contextType"] ?>.id.<?= Yii::app()->session["costum"]["contextId"] ?>" target="_blank"><i class="fa fa-id-card-o" aria-hidden="true"></i>
<a class="btn btn-default" href="#@<?= $this->costum["contextSlug"] ?>" data-hash="#page.type.<?= $this->costum["contextType"] ?>.id.<?= $this->costum["contextId"] ?>" target="_blank"><i class="fa fa-id-card-o" aria-hidden="true"></i>
Element </a>
<?php echo $this->renderPartial("costum.views.tpls.blocCss", array("canEdit" => $canEdit)); ?>
<?php echo $this->renderPartial("costum.views.tpls.blocApp", array("canEdit" => $canEdit)); ?>
......
......@@ -11,16 +11,16 @@ $cssJS = array(
HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->request->baseUrl);
$poiList = array();
if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->session["costum"]["contextId"])){
if(isset($this->costum["contextType"]) && isset($this->costum["contextId"])){
$poiList = PHDB::find(Poi::COLLECTION,
array( "parent.".Yii::app()->session["costum"]["contextId"] => array('$exists'=>1),
"parent.".Yii::app()->session["costum"]["contextId"].".type"=>Yii::app()->session["costum"]["contextType"],
array( "parent.".$this->costum["contextId"] => array('$exists'=>1),
"parent.".$this->costum["contextId"].".type"=>$this->costum["contextType"],
"type"=>"cms") );
}
// $el = PHDB::findOne( Yii::app()->session["costum"]["contextType"] ,
// [ "_id" => new MongoId( Yii::app()->session["costum"]["contextId"] ) ] );
// $el = PHDB::findOne( $this->costum["contextType"] ,
// [ "_id" => new MongoId( $this->costum["contextId"] ) ] );
// $slug = $el["slug"];
?>
......@@ -59,7 +59,7 @@ if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->sess
min-width: 100%;
}
.btn-main-menu{
background: <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
background: <?php echo $this->costum["colors"]["pink"]; ?>;
border-radius: 10px;
padding: 10px !important;
color: white;
......@@ -70,14 +70,14 @@ if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->sess
}
.btn-main-menuW{
background: white;
color: <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
color: <?php echo $this->costum["colors"]["pink"]; ?>;
border:none;
cursor:text ;
}
.btn-main-menu:hover{
border:2px solid <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
border:2px solid <?php echo $this->costum["colors"]["pink"]; ?>;
background-color: white;
color: <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
color: <?php echo $this->costum["colors"]["pink"]; ?>;
}
.btn-main-menuW:hover{
border:none;
......@@ -118,18 +118,18 @@ if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->sess
<?php
$banner = Yii::app()->getModule("co2")->assetsUrl."/images/banniere-Campagne-Acoeur.jpg";
if(@Yii::app()->session["costum"]["metaImg"]){
if(@$this->costum["metaImg"]){
//ex this.profilBannerUrl
if(substr_count(Yii::app()->session["costum"]["metaImg"], 'this.') > 0 && isset($el)){
$field = explode(".", Yii::app()->session["costum"]["metaImg"]);
if(substr_count($this->costum["metaImg"], 'this.') > 0 && isset($el)){
$field = explode(".", $this->costum["metaImg"]);
if( isset( $el[ $field[1] ] ) )
$banner = Yii::app()->getRequest()->getBaseUrl(true).$el[$field[1]] ;
}
else if(strrpos(Yii::app()->session["costum"]["metaImg"], "http" ) === false && strrpos(Yii::app()->session["costum"]["metaImg"], "/upload/" ) === false ) {
$banner = Yii::app()->getModule("co2")->getAssetsUrl().Yii::app()->session["costum"]["metaImg"] ;
else if(strrpos($this->costum["metaImg"], "http" ) === false && strrpos($this->costum["metaImg"], "/upload/" ) === false ) {
$banner = Yii::app()->getModule("co2")->getAssetsUrl().$this->costum["metaImg"] ;
}
else
$banner = Yii::app()->session["costum"]["metaImg"];
$banner = $this->costum["metaImg"];
}
?>
<img class="img-responsive" style="margin:auto;background-color: black;" src='<?php echo $banner ?>'/>
......@@ -137,36 +137,36 @@ if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->sess
</div>
<?php
$color1 = "#E63458";
if(isset(Yii::app()->session["costum"]["cms"]["color1"]))
$color1 = Yii::app()->session["costum"]["cms"]["color1"];
if(isset($this->costum["cms"]["color1"]))
$color1 = $this->costum["cms"]["color1"];
if(!empty($canEdit))
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='color1' data-type='color' data-path='costum.cms.color1' data-label='Couleur Principale '><i class='fa fa-pencil'></i></a>";
?>
<div class="col-sm-12 col-md-12 col-xs-12 no-padding" style="background-color:<?php echo Yii::app()->session["costum"]["colors"]["grey"]; ?>; max-width:100%;">
<div class="col-sm-12 col-md-12 col-xs-12 no-padding" style="background-color:<?php echo $this->costum["colors"]["grey"]; ?>; max-width:100%;">
<div class="col-xs-12 no-padding" style="">
<?php if( !isset(Yii::app()->session["userId"])){ ?>
<div class="col-xs-12 no-padding">
<div class="col-md-12 col-sm-12 col-xs-12 padding-20" style="padding-left:100px;background-color: <?php echo Yii::app()->session["costum"]["colors"]["grey"]; ?>; ">
<div class="col-md-12 col-sm-12 col-xs-12 padding-20" style="padding-left:100px;background-color: <?php echo $this->costum["colors"]["grey"]; ?>; ">
<div class="col-xs-12 col-sm-10 col-sm-offset-1 pull-left padding-20 shadow2" style="font-family: montserrat; margin-top:-200px;background-color: #fff;font-size: 14px;z-index: 5;">
<div class="col-xs-12 ourvalues" style="text-align:center;">
<h2 class="mst col-xs-12 text-center">
<br>
<?php
if(isset(Yii::app()->session["costum"]["cms"]["title1"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["title1"]);
if(isset($this->costum["cms"]["title1"])){
echo htmlentities($this->costum["cms"]["title1"]);
} else { ?> Open Form Wizard (With steps)<?php }
if(!empty($canEdit))
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='title1' data-path='costum.cms.title1'><i class='fa fa-pencil'></i></a>";
?>
</h2>
<p class="mst" style="color:<?php echo Yii::app()->session["costum"]["colors"]["dark"]; ?>">
<p class="mst" style="color:<?php echo $this->costum["colors"]["dark"]; ?>">
<?php
if(isset(Yii::app()->session["costum"]["cms"]["subtitle1"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["subtitle1"]);
if(isset($this->costum["cms"]["subtitle1"])){
echo htmlentities($this->costum["cms"]["subtitle1"]);
} else { ?>
Votre questionnaire contient des sections ou des étapes
<br/>Vous etes au bon endroit.<br/>
......@@ -177,7 +177,7 @@ if(!empty($canEdit))
<br/>
</p>
<h2 class="mst" style="color:<?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>" >JE PARTICIPE</h2>
<h2 class="mst" style="color:<?php echo $this->costum["colors"]["pink"]; ?>" >JE PARTICIPE</h2>
<br/>
......@@ -206,8 +206,8 @@ if(!empty($canEdit))
<div class="col-xs-12 text-center " style="font-size: 1.5em; padding-top: 20px;" >
<?php
if(isset(Yii::app()->session["costum"]["cms"]["textIntro"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["textIntro"]);
if(isset($this->costum["cms"]["textIntro"])){
echo htmlentities($this->costum["cms"]["textIntro"]);
} else { ?> <b>Lorem ipsum dolor sit amet</b>, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
......@@ -249,8 +249,8 @@ if(!empty($canEdit))
<style type="text/css">
.monTitle{
border-top: 1px dashed <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
border-bottom: 1px dashed <?php echo Yii::app()->session["costum"]["colors"]["pink"]; ?>;
border-top: 1px dashed <?php echo $this->costum["colors"]["pink"]; ?>;
border-bottom: 1px dashed <?php echo $this->costum["colors"]["pink"]; ?>;
margin-top: -20px;
}
</style>
......@@ -259,20 +259,20 @@ if(!empty($canEdit))
<div class="col-md-12 col-sm-12 col-xs-12 " style="background-color: white; ">
<h1 class="margin-top-20 monTitle padding-20 text-center cbyg" style="color:<?php echo $color1 ?>">
<?php
if(isset(Yii::app()->session["costum"]["cms"]["sec1Title"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["sec1Title"]);
if(isset($this->costum["cms"]["sec1Title"])){
echo htmlentities($this->costum["cms"]["sec1Title"]);
} else { ?> Sondage <?php }
if(!empty($canEdit))
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='sec1Title' data-type='text' data-path='costum.cms.sec1Title' data-label='Titre '><i class='fa fa-pencil'></i></a>";
?>
</h1>
<div class="text-center">
<?php if(isset(Yii::app()->session["costum"]["form"]["startDate"])){ ?>
Démarrage : <?php echo Yii::app()->session["costum"]["form"]["startDate"]; ?>
<?php if(isset($this->costum["form"]["startDate"])){ ?>
Démarrage : <?php echo $this->costum["form"]["startDate"]; ?>
<?php }
if(isset(Yii::app()->session["costum"]["form"]["endDate"])){ ?>
et se termine : <?php echo Yii::app()->session["costum"]["form"]["endDate"]; ?>
if(isset($this->costum["form"]["endDate"])){ ?>
et se termine : <?php echo $this->costum["form"]["endDate"]; ?>
<?php } ?>
</div>
</div>
......@@ -283,8 +283,8 @@ if(!empty($canEdit))
<div class="padding-20 btnParticiper margin-top-20 Montserrat text-center" style="font-size:1.2em ">
<?php
if(isset(Yii::app()->session["costum"]["cms"]["textIntro"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["textIntro"]);
if(isset($this->costum["cms"]["textIntro"])){
echo htmlentities($this->costum["cms"]["textIntro"]);
} else { ?> Quelle est votre objectif avec ce formulaire <?php }
if(!empty($canEdit))
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='textIntro' data-type='textarea' data-markdown='1' data-path='costum.cms.textIntro' data-label='Expliquez les objectifs de ce formulaire ? '><i class='fa fa-pencil'></i></a>";
......@@ -338,8 +338,8 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
<div class="col-xs-12 margin-top-10 margin-bottom-25">
<h4>
<?php
if(isset(Yii::app()->session["costum"]["cms"]["sec2Title"])){
echo htmlentities(Yii::app()->session["costum"]["cms"]["sec2Title"]);
if(isset($this->costum["cms"]["sec2Title"])){
echo htmlentities($this->costum["cms"]["sec2Title"]);
} else { ?> Communauté <?php }
if(!empty($canEdit))
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='sec2Title' data-type='text' data-path='costum.cms.sec2Title' data-label='Votre texte '><i class='fa fa-pencil'></i></a>";
......@@ -357,7 +357,7 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
// "poiList"=>$poiList,
// "listSteps" => array("1","2","3","4"),
// "el" => $el,
// "color1" => Yii::app()->session["costum"]["colors"]["pink"],
// "color1" => $this->costum["colors"]["pink"],
// "wizid"=> "wizardInfo"
// );
// echo $this->renderPartial("costum.views.tpls.wizard",$params);
......@@ -387,8 +387,8 @@ jQuery(document).ready(function() {
mylog.log("render","/modules/costum/views/tpls/views/index.php");
contextData = {
id : "<?php echo Yii::app()->session["costum"]["contextId"] ?>",
type : "<?php echo Yii::app()->session["costum"]["contextType"] ?>",
id : "<?php echo $this->costum["contextId"] ?>",
type : "<?php echo $this->costum["contextType"] ?>",
name : '<?php echo htmlentities($el['name']) ?>',
profilThumbImageUrl : "http://127.0.0.1/ph/themes/CO2/assets/img/LOGOS/CO2/logo-min.png"
};
......
......@@ -17,11 +17,11 @@
if( stripos( $inp["type"] , "tpls.forms." ) === false )
echo "<th class='text-center'>".$inp["label"]."</th>";
}
if(isset(Yii::app()->session["costum"]["form"]["showDate"]))
if(isset($this->costum["form"]["showDate"]))
echo "<th class='text-center'>Date</th>";
if(isset(Yii::app()->session["costum"]["form"]["canVote"]))
if(isset($this->costum["form"]["canVote"]))
echo "<th class='text-center'>Vote</th>";
if(isset(Yii::app()->session["costum"]["form"]["canFund"]))
if(isset($this->costum["form"]["canFund"]))
echo "<th class='text-center'>Fund</th>";
echo "<th class='text-center'>Action</th>";
echo "</tr>";
......@@ -36,8 +36,8 @@
foreach ($form['inputs'] as $k => $inp) {
if( stripos( $inp["type"] , "tpls.forms." ) === false )
echo "<td class='text-center'>".@$a["answers"][$k]."</td>";
if(isset(Yii::app()->session["costum"]["form"]["sumColumns"]) &&
in_array($k, Yii::app()->session["costum"]["form"]["sumColumns"]) &&
if(isset($this->costum["form"]["sumColumns"]) &&
in_array($k, $this->costum["form"]["sumColumns"]) &&
isset($a["answers"][$k]) &&
is_numeric($a["answers"][$k]) ){
if(!isset($sum[$k]))
......@@ -46,17 +46,17 @@
}
}
if(isset(Yii::app()->session["costum"]["form"]["showDate"]))
if(isset($this->costum["form"]["showDate"]))
echo "<td>".date('Y-m-d',$a['created'])."</td>";
if(isset(Yii::app()->session["costum"]["form"]["canVote"])){
if(isset($this->costum["form"]["canVote"])){
echo "<td class='text-center'>";
echo "<a href='javascript:;' class='voteBtn btn btn-default'><i class='fa text-red fa-thumbs-up'></i> </a>";
echo "<a href='javascript:;' class='voteListBtn btn btn-default'>".@$a["voteUpCount"]." <i class='fa text-red fa-bars'></i> </a>";
echo "</td>";
}
if(isset(Yii::app()->session["costum"]["form"]["canFund"])){
if(isset($this->costum["form"]["canFund"])){
echo "<td class='text-center'>";
$totalFund = "";
if(isset($a["fund"])){
......@@ -74,7 +74,7 @@
echo "<td class='bg-red'>";
if(isset(Yii::app()->session["costum"]["form"]["canModifyAnswer"]))
if(isset($this->costum["form"]["canModifyAnswer"]))
echo "<a href='".Yii::app()->createUrl("/costum/co/index/slug/".$slug."/answer/".$a["_id"])."' class='btn btn-default'><i class='fa text-red fa-pencil'></i> </a>";
echo "<a href='javascript:;' data-id='".$a['_id']."' class='deleteAnswer btn btn-default'><i class='fa text-red fa-trash'></i> </a>";
......@@ -84,7 +84,7 @@
}
}
if(isset(Yii::app()->session["costum"]["form"]["sumColumns"])){
if(isset($this->costum["form"]["sumColumns"])){
echo "<tr>";
echo "<td class='bold'>SOMME</td>";
foreach ($form['inputs'] as $k => $inp) {
......@@ -95,11 +95,11 @@
echo "</td>";
}
}
if(isset(Yii::app()->session["costum"]["form"]["showDate"]))
if(isset($this->costum["form"]["showDate"]))
echo "<td></td>";
if(isset(Yii::app()->session["costum"]["form"]["canVote"]))
if(isset($this->costum["form"]["canVote"]))
echo "<td></td>";
if(isset(Yii::app()->session["costum"]["form"]["canFund"]))
if(isset($this->costum["form"]["canFund"]))
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
......
......@@ -12,10 +12,10 @@ $paramsData = [ "title" => "",
"tags" => "structags"
];
if( isset(Yii::app()->session["costum"]["tpls"][$keyTpl]) ) {
if( isset($this->costum["tpls"][$keyTpl]) ) {
foreach ($paramsData as $i => $v) {
if( isset(Yii::app()->session["costum"]["tpls"][$keyTpl][$i]) )
$paramsData[$i] = Yii::app()->session["costum"]["tpls"][$keyTpl][$i];
if( isset($this->costum["tpls"][$keyTpl][$i]) )
$paramsData[$i] = $this->costum["tpls"][$keyTpl][$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