Commit c151a5a6 authored by thomas craipeau's avatar thomas craipeau
Browse files

fix private chat

parent b1022742
......@@ -410,8 +410,7 @@ var pageProfil = {
},
chat : function(){
hasRc=(typeof contextData.hasRC != "undefined" || contextData.type=="citoyens" ) ? true : false;
var isOpen = (params && params.element && params.element.preferences && params.element.preferences.private && params.element.preferences.private === true) ? false : true;
rcObj.loadChat(contextData.slug, contextData.type, isOpen,hasRc, contextData);
rcObj.loadChat(contextData.slug, contextData.type, (params && params.element && params.element.preferences && params.element.preferences.private && params.element.preferences.private === true) ? false : true,hasRc, contextData);
},
mindmap : function(){
co.mind();
......
......@@ -23,6 +23,17 @@ var settings = {
toastr.success(data.msg);
}
});
if (param.type === 'private') {
if (params && params.element && params.element.preferences) {
if (param.value === 'true'){
params.element.preferences.private = true;
delete contextData.hasRC;
} else {
params.element.preferences.private = false;
delete contextData.hasRC;
}
}
}
});
},
bindButtonConfidentiality : function(preferences){
......
......@@ -136,14 +136,16 @@ class RocketchatController extends CommunecterController {
}
else if($roomType == "channel"){
$path = "/channel/".$name;
$group = RocketChat::createGroup ($name,$roomType, Yii::app()->session['user']['username']);
$isAdmin = Authorisation::canEditItem(Yii::app()->session['userId'], $type, $id);
$group = RocketChat::createGroup ($name,$roomType, Yii::app()->session['user']['username'], null,$isAdmin);
}
else {
$path = "/group/".$name;
$group = null;
if(Authorisation::canEditItem(Yii::app()->session['userId'], $type, $id) ||
$isAdmin = Authorisation::canEditItem(Yii::app()->session['userId'], $type, $id);
if($isAdmin ||
Link::isLinked($id,$type,Yii::app()->session["userId"]) ){
$group = RocketChat::createGroup ($name,null, Yii::app()->session['user']['username']);
$group = RocketChat::createGroup ($name,null, Yii::app()->session['user']['username'], null,$isAdmin);
} else
Rest::json(array("result"=>false,
"error"=>"Unauthorized Access.",
......@@ -155,11 +157,19 @@ class RocketchatController extends CommunecterController {
}
if($group != null && @$group->create->channel->_id ) {
if($group != null && (@$group->create->channel->_id || @$group->create->group->_id)) {
$result = PHDB::update( $type, array("_id" => new MongoId($id)),
array('$set' => array("hasRC"=>true),
'$addToSet' => array( "tools.chat.int" => array( "name" => $name , "url" => $path ) ) ));
}
}
if($group != null && @$group->settype->success ) {
$result = PHDB::update( $type, array("_id" => new MongoId($id)),
array('$set' => array("hasRC"=>true)));
$result = PHDB::update( $type, array("_id" => new MongoId($id), "tools.chat.int.name" => $name),
array('$set' => array("tools.chat.int.$.url"=> $path) ));
}
if($group != null){
// TODO : notification or news
......
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