Commit abbe7e6a authored by Kgneo's avatar Kgneo
Browse files

DDA - roles dans rooms #485

parent 81121436
......@@ -2,6 +2,18 @@
//var_dump($action); exit;
$auth = Authorisation::canParticipate(Yii::app()->session['userId'], $action["parentType"], $action["parentId"]);
$parentRoom = Room::getById($action["idParentRoom"]);
if(isset(Yii::app()->session['userId'])){
$me = Element::getByTypeAndId("citoyens", Yii::app()->session['userId']);
$myRoles = @$me["links"]["memberOf"][@$action["parentId"]]["roles"] ?
@$me["links"]["memberOf"][@$action["parentId"]]["roles"] : array();
}else{
$myRoles = array();
}
//lock access if the user doesnt have the good role
$accessRoom = @$parentRoom ? Room::getAccessByRole($parentRoom, $myRoles) : "";
if($accessRoom == "lock") exit;
?>
......
......@@ -102,7 +102,7 @@
"done" => "Done");
if(Yii::app()->session['userId'])
$allStatus["mine"] = "My proposals";
$allStatus["mine"] = "My actions";
foreach($allStatus as $status=>$tradStatus){ ?>
......
......@@ -32,7 +32,14 @@
//$menuCoopData = Cooperation::getCoopData(@$post["parentType"], @$post["parentId"], "room");
$parentId = @$post["parentId"]; $parentType = @$post["parentType"];
}
//else
if(isset(Yii::app()->session['userId'])){
$me = Element::getByTypeAndId("citoyens", Yii::app()->session['userId']);
$myRoles = @$me["links"]["memberOf"][@$parentId]["roles"] ?
@$me["links"]["memberOf"][@$parentId]["roles"] : array();
}else{
$myRoles = array();
}
$auth = Authorisation::canParticipate(Yii::app()->session['userId'], @$parentType, @$parentId);
......@@ -42,23 +49,8 @@
?>
<?php if(@$access=="deny"){ ?>
<div class="col-lg-12 col-md-12 col-sm-12">
<h5 class="padding-left-10 letter-red">
<i class="fa fa-ban"></i> Vous n'êtes pas autorisé à accéder à ce contenu
</h5>
<?php if(!isset(Yii::app()->session['userId'])){ ?>
<h5 class="padding-left-10">
<small class="letter-orange"><i class="fa fa-user-circle"></i> Vous n'êtes pas connecté</small>
</h5>
<?php } ?>
<h5 class="padding-left-10 letter-red">
<small>Devenez membre ou contributeur</small>
</h5>
</div>
<?php exit; } ?>
<?php $accessRoom = @$room ? Room::getAccessByRole($room, $myRoles) : ""; ?>
<div class="col-lg-12 col-md-12 col-sm-12 no-padding bg-white text-dark" id="coop-container">
......@@ -73,7 +65,7 @@
<?php if(@$room){ ?>
<?php if(@$auth){ ?>
<?php if(@$auth && $accessRoom != "lock"){ ?>
<button class="btn btn-default pull-right btn-sm margin-top-10 hidden-min tooltips"
data-target="#modalDeleteRoom" data-toggle="modal" id="btn-open-modal-delete">
<i class="fa fa-trash"></i> Supprimer
......@@ -101,7 +93,11 @@
<h4 class="room-desc"><small><?php echo @$room["description"]; ?></small></h4>
<?php if(@$room["roles"] && @$room["roles"] != ""){ ?>
<?php $roomRoles = explode(",", @$room["roles"]); ?>
<?php
$roomRoles = @$room["roles"];
if(!is_array(@$room["roles"]))
$roomRoles = explode(",", @$room["roles"]);
?>
<h5 class="room-desc">
<small class="letter-blue">
<b><i class="fa fa-unlock-alt"></i> Accès réservé : </b>
......@@ -126,6 +122,40 @@
<?php } ?>
<?php if(@$access=="deny"){ ?>
<div class="col-lg-12 col-md-12 col-sm-12">
<h5 class="padding-left-10 letter-red">
<i class="fa fa-ban"></i> Vous n'êtes pas autorisé à accéder à ce contenu
</h5>
<?php if(!isset(Yii::app()->session['userId'])){ ?>
<h5 class="padding-left-10">
<small class="letter-orange"><i class="fa fa-user-circle"></i> Vous n'êtes pas connecté</small>
</h5>
<?php } ?>
<h5 class="padding-left-10 letter-red">
<small>Devenez membre ou contributeur</small>
</h5>
</div>
<?php exit; } ?>
<?php if(@$accessRoom=="lock"){ ?>
<div class="col-lg-12 col-md-12 col-sm-12">
<h5 class="padding-left-10 letter-red">
<i class="fa fa-ban"></i> Vous n'êtes pas autorisé à accéder à ce contenu
</h5>
<?php
$rolesLabel = "";
if(!is_array(@$room["roles"])) $rolesLabel = @$room["roles"];
else foreach (@$room["roles"] as $r) $rolesLabel .= $rolesLabel == "" ? $r : ", ".$r;
?>
<h5 class="padding-left-10 letter-red">
<small>Cet espace est réservé au(x) rôle(s) suivant(s) : <?php echo $rolesLabel; ?></small>
</h5>
</div>
<?php exit; } ?>
<ul class="menuCoop margin-bottom-50">
......
<!-- ************ MODAL ********************** -->
<!-- ************ MAIN MODAL CO-SPACE ********************** -->
<div class="modal fade" tabindex="-1" role="dialog" id="modalCoop">
<div class="modal-dialog modal-lg">
<div class="modal-content">
......@@ -77,7 +77,7 @@
</div><!-- /.modal -->
<!-- ************ MODAL DELETE ********************** -->
<!-- ************ MODAL DELETE ROOM ********************** -->
<div class="modal fade" tabindex="-1" role="dialog" id="modalDeleteRoom">
<div class="modal-dialog modal-lg">
<div class="modal-content">
......@@ -112,7 +112,7 @@
</div><!-- /.modal -->
<!-- ************ MODAL ********************** -->
<!-- ************ MODAL ASSIGN ACTION ********************** -->
<div class="modal fade" tabindex="-1" role="dialog" id="modalAssignMe">
<div class="modal-dialog modal-lg">
<div class="modal-content">
......@@ -146,7 +146,7 @@
</div><!-- /.modal -->
<!-- ************ MODAL ********************** -->
<!-- ************ MODAL DELETE AMENDEMENT ********************** -->
<div class="modal fade" tabindex="-1" role="dialog" id="modalDeleteAm">
<div class="modal-dialog modal-lg">
<div class="modal-content">
......
......@@ -11,6 +11,18 @@
$totalVotant = Proposal::getTotalVoters($proposal);
$voteRes = Proposal::getAllVoteRes($proposal);
if(isset(Yii::app()->session['userId'])){
$me = Element::getByTypeAndId("citoyens", Yii::app()->session['userId']);
$myRoles = @$me["links"]["memberOf"][@$proposal["parentId"]]["roles"] ?
@$me["links"]["memberOf"][@$proposal["parentId"]]["roles"] : array();
}else{
$myRoles = array();
}
//lock access if the user doesnt have the good role
$accessRoom = @$parentRoom ? Room::getAccessByRole($parentRoom, $myRoles) : "";
if($accessRoom == "lock") exit;
?>
<?php if(@$access=="deny"){ ?>
......
......@@ -11,6 +11,20 @@
$parentRoom = Room::getById($resolution["idParentRoom"]);
if(isset(Yii::app()->session['userId'])){
$me = Element::getByTypeAndId("citoyens", Yii::app()->session['userId']);
$myRoles = @$me["links"]["memberOf"][@$resolution["parentId"]]["roles"] ?
@$me["links"]["memberOf"][@$resolution["parentId"]]["roles"] : array();
}else{
$myRoles = array();
}
//lock access if the user doesnt have the good role
$accessRoom = @$parentRoom ? Room::getAccessByRole($parentRoom, $myRoles) : "";
if($accessRoom == "lock") exit;
$totalVotant = Proposal::getTotalVoters($resolution);
$voteRes = Proposal::getAllVoteRes($resolution);
?>
......
......@@ -23,21 +23,11 @@
<?php foreach($roomList as $key => $room){ ?>
<?php
$roomRoles = explode(",", @$room["roles"]);
$intersect = array();
if(sizeof($myRoles) > 0)
foreach (@$roomRoles as $key => $roomRole) {
foreach ($myRoles as $key => $myRole) {
if($roomRole == $myRole)
$intersect[] = $myRole;
}
}
if(sizeof($intersect) > 0) $accessRoom = "unlock";
else if($roomRoles[0] == "") $accessRoom = "open";
else $accessRoom = "lock";
$accessRoom = Room::getAccessByRole($room, $myRoles);
//var_dump( @$roomRoles);
if(!isset($room["roles"]) || $intersect){ ?>
if(!isset($room["roles"]) || $accessRoom != "lock"){ ?>
<li class="submenucoop sub-rooms "
data-type="room" data-dataid="<?php echo (string)@$room["_id"]; ?>">
<a href="javascript:" class="load-coop-data droppable letter-turq"
......@@ -52,12 +42,16 @@
</a>
</li>
<?php }else{ ?>
<?php $roles = @$room["roles"]; ?>
<?php
$rolesTooltip = "";
if(!is_array(@$room["roles"])) $rolesTooltip = @$room["roles"];
else foreach (@$room["roles"] as $r) $rolesTooltip .= $rolesTooltip == "" ? $r : ", ".$r;
?>
<li class="submenucoop sub-rooms ">
<a href="javascript:" class="load-coop-data droppable letter-turq-light"
data-type="locked" data-dataid="locked">
<i class="fa fa-lock tooltips"
data-original-title="réservé au rôle : <?php echo $roles; ?>"
data-original-title="réservé au(x) rôle(s) : <?php echo $rolesTooltip; ?>"
data-placement="right"></i> <?php echo @$room["name"]; ?>
<i class="fa fa-inbox pull-right"></i>
</a>
......
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