This commit is contained in:
afornerot 2019-07-24 13:41:35 +02:00
parent 8ad58b3d93
commit 5399306e87
12 changed files with 176 additions and 31 deletions

View File

@ -6,18 +6,18 @@
<containers>
<container name='web'>
<file filelist='ninegate' name='/etc/apache2/sites-available/ninegate' source='ninegate-apache.conf'/>
<file filelist='ninegate' name='/etc/apache2/sites-available/ninegate' source='ninegate-apache.conf' rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/app/config/parameters.yml" source="ninegate-parameters.yml" rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/app/config/template.yml" source="ninegate-template.yml" rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/scripts/ninegate-postservice-00.sh" source="ninegate-postservice-00.sh" rm="True" mode="700" />
<file filelist="ninegate" name="/var/www/html/ninegate/src/Cadoles/CoreBundle/Command/data/core-init-01.sql" source="ninegate-init-01.sql" rm="True"/>
<file filelist='ninegate' name='/etc/cron.d/ninegate' source='ninegate.cron' rm='True'/>
<file filelist='ninegate' name='/etc/nginx/conf.d/ninegate.conf' source='ninegate.nginx.conf' rm='True'/>
<file filelist='ninegate_websocket' name='/etc/nginx/conf.d/ninegate.conf' source='ninegate.nginx.conf' rm='True'/>
<service method='apache' servicelist='ninegate'>ninegate</service>
<service_access service='ninegate'>
<port>5555</port>
<service_access service='ninegate_websocket'>
<port port_type="SymLinkOption">ninegate_websocket_portexterne</port>
</service_access>
</container>
@ -168,10 +168,10 @@
<!-- WEBSOCKET -->
<variable type='string' name='ninegate_websocket_url' description='Host du serveur Websocket' mandatory='True' />
<variable type='string' name='ninegate_websocket_portexterne' description='Pot de commuinication externe du serveur Websocket' mandatory='True' >
<variable type='string' name='ninegate_websocket_portexterne' description='Port de commuinication externe du serveur Websocket' mandatory='True' >
<value>5555</value>
</variable>
<variable type='string' name='ninegate_websocket_portinterne' description='Pot de commuinication externe du serveur Websocket' mandatory='True'>
<variable type='string' name='ninegate_websocket_portinterne' description='Port de commuinication externe du serveur Websocket' mandatory='True'>
<value>5556</value>
</variable>
@ -275,6 +275,9 @@
<target type='variable'>ninegate_allow_hosts</target>
<target type='variable'>ninegate_dbuser</target>
<target type='variable'>ninegate_dbpass</target>
<target type='filelist'>ninegate</target>
<target type='servicelist'>ninegate</target>
</condition>
<condition name='hidden_if_in' source='ninegate_masteridentity'>
@ -383,6 +386,7 @@
<target type='variable'>ninegate_websocket_url</target>
<target type='variable'>ninegate_websocket_portinterne</target>
<target type='variable'>ninegate_websocket_portexterne</target>
<target type='servicelist'>ninegate_websocket</target>
</condition>
<fill name='calc_multi_condition' target='ninegate_websocket_url'>

View File

@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
(-100, 'DRAAF', '130007107');
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}XuBTTUoInXPRBr1msGCFHj0Nm1C83fj/
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}ydZGT20kB14WfmeVQZVPRTfbbrX0ahPR
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');

View File

@ -77,26 +77,16 @@ $(document).on('ready', function(){
return false;
});
/*
if( typeof CKEDITOR !== 'undefined') {
CKEDITOR.on('dialogDefinition', function(ev) {
try {
/* this just gets the name of the dialog */
var dialogName = ev.data.name;
/* this just gets the contents of the opened dialog */
var dialogDefinition = ev.data.definition;
/* Make sure that the dialog opened is the link plugin ... otherwise do nothing */
if(dialogName == 'link') {
/* Getting the contents of the Target tab */
var informationTab = dialogDefinition.getContents('target');
/* Getting the contents of the dropdown field "Target" so we can set it */
var targetField = informationTab.get('linkTargetType');
/* Now that we have the field, we just set the default to _blank */
targetField['default'] = '_blank';
}
@ -109,4 +99,5 @@ $(document).on('ready', function(){
}
});
}
*/
});

View File

@ -100,6 +100,7 @@
.grid-item h3,
.pagination>li>a,
.pagination>li>span,
.modal-dialog,
a
{
color: #{{ color['main'] }}

View File

@ -13,6 +13,8 @@ use Symfony\Component\Finder\Finder;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\File\File;
use GuzzleHttp\Exception\RequestException;
use Symfony\Component\Form\FormError;
use Cadoles\PortalBundle\Entity\Pagewidget;
use Cadoles\PortalBundle\Form\PagewidgetType;
@ -98,7 +100,11 @@ class PagewidgetController extends Controller
if($page->getPagecategory()->getId()!=2)
throw $this->createNotFoundException('Permission denied');
if ($form->isValid()) {
// Sur erreur
$this->getErrorForm(null,$form,$request,$idwidgettype,$page,$entity,"submit");
// Sur validation
if ($form->get('submit')->isClicked() && $form->isValid()) {
$idicon = $form->get('idicon')->getData();
$icon=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findoneby(["id"=>$idicon]);
$widgettype=$this->getDoctrine()->getRepository("CadolesPortalBundle:Widget")->findoneby(["id"=>$idwidgettype]);
@ -314,7 +320,38 @@ class PagewidgetController extends Controller
return new Response($response);
}
protected function getErrorForm($id,$form,$request,$idwidgettype,$page,$data,$mode) {
if ($form->get('submit')->isClicked()&&$mode=="delete") {
}
if ($form->get('submit')->isClicked() && ($mode=="submit" || $mode=="update")) {
// Interdire l'insertion de 2 chat dans la meme page
if($idwidgettype==-1840) {
$pagewidget=$this->getDoctrine()->getRepository("CadolesPortalBundle:Pagewidget")->findoneby(["page"=>$page,"widget"=>-1840]);
if($pagewidget) {
$form->addError(new FormError("Vous ne pouvez pas insérer deux widgets de type Chat dans la même page"));
}
}
}
if ($form->get('submit')->isClicked() && !$form->isValid()) {
$this->get('session')->getFlashBag()->clear();
$validator = $this->get('validator');
$errors = $validator->validate($data);
foreach( $errors as $error ) {
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
}
$errors = $form->getErrors();
foreach( $errors as $error ) {
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
}
}
}
public function viewurlAction($id,$access="config") {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository($this->labelentity)->find($id);

View File

@ -46,8 +46,11 @@
<span class="title">{{ entity.name }}</span>
</div>
<div class="widgetbody" style="{{ stylewidgetbodyframe }}">
<div class="widgetbody" style="{{ stylewidgetbody }}">
{{ render(url('cadoles_websocket_chat',{'id':group,'framed':true,'border':entity.border,'colorbodybacklight':colorbodyback, 'colorbodyback':colorbodyback,'colorbodyfont':colorbodyfont})) }}
<!--
<iframe src="{{ path(tool,{'id':group,'framed':true,'border':entity.border,'colorbodybacklight':colorbodyback, 'colorbodyback':colorbodyback,'colorbodyfont':colorbodyfont}) }}" class="{% if entity.autoajust %}frameajust {% endif %}"></iframe>
-->
</div>
{% endif %}
</div>

View File

@ -69,6 +69,7 @@ class ChatController extends Controller
'usesidebar' => false,
'userkey' => $key,
'groupid' => $id,
'group' => $group,
'messages' => $messages,
'framed' => $framed,
'border' => $border,

View File

@ -31,7 +31,15 @@ class ChatType extends AbstractType
'required' => false,
'config' => ["height" => "100px",'filebrowserUploadRoute' => 'cadoles_portal_user_pagewidget_upload']
]);
$builder
->add("messagemail",CKEditorType::class,[
'config_name' => 'small_config',
'label' => "Message",
'mapped'=> false,
'required' => false,
'config' => ["height" => "200px",'filebrowserUploadRoute' => 'cadoles_portal_user_pagewidget_upload']
]);
}
public function configureOptions(OptionsResolver $resolver)

View File

@ -36,6 +36,18 @@
line-height: 12px;
margin-bottom: 10px;
}
.bootstrap-switch{
margin-top:5px;
}
.labelswitch {
line-height: 40px;
float: right;
margin-right: 10px;
}
#listtoavatar img {
margin:0px 5px 5px 0px;
cursor:pointer;
}
#cke_1_bottom{ display:none }
{% endblock %}
@ -43,10 +55,12 @@
{{ form_start(form) }}
<div class='row'>
{{ form_widget(form.message) }}
<input id="sendbymail" type="checkbox" id="item_essential" name="item[essential]" style="float:right" class='switch' ></input>
<label class="custom-control-label" for="sendbymail">Envoyer par Mail ?</label>
<a id="sendbtn" class="btn btn-success" style="margin-top:5px; width:100%; margin-bottom:15px">Envoyer</a>
</div>
{{ form_end(form) }}
<div class="mychat">
{% for message in messages %}
@ -67,6 +81,35 @@
</div>
{% endfor %}
</div>
<div id="mymodal-sendmail" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Notifier par Mail</h4>
</div>
<div class="modal-body">
<div class="form-group ">
<label class="control-label required" for="mailsuject">Sujet du Mail<span class="mandatory">*</span></label>
<input type="text" id="mailsuject" name="mailsuject" required="required" class="form-control">
</div>
<div>
<label class="control-label required">Destinataires (cliquez sur les images pour les enlever de la liste des destinataires)<span class="mandatory">*</span></label>
<div id="listtoavatar"></div>
<input type="hidden" id="mailto" name="mailto" required="required" class="form-control">
</div>
<div class="form-group" style="margin-top:10px">
<label class="control-label required">Corps du Mail<span class="mandatory">*</span></label>
{{ form_widget(form.messagemail) }}
</div>
<a id="sendbtnmail" class="btn btn-success" style="margin-top:5px; width:100%; margin-bottom:15px">Envoyer</a>
</div>
</div>
</div>
</div>
{{ form_end(form) }}
{% endblock %}
{% block localexternalscript %}
@ -76,6 +119,7 @@
{% block localjavascript %}
$(document).ready(function(){
$(".switch").bootstrapSwitch();
var dateoptions = {weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" };
@ -120,22 +164,62 @@
$( "#sendbtn" ).click(function() {
var data = CKEDITOR.instances["chat_message"].getData();
if(data) {
event={mykey: "{{userkey}}", type: "add", message: data};
if($("#sendbymail").bootstrapSwitch('state')) {
CKEDITOR.instances["chat_messagemail"].setData(data);
$("#mailsuject").val("{{app.session.get('appname')}} = Notification {{ group.label }}");
$("#mailto").val("");
//$("#listtoavatar").html("");
{% for user in group.users %}
{%if(user.user!=app.user)%}
$("#mailto").val($("#mailto").val()+";{{user.user.email}}");
$("#listtoavatar").append($("<img class='avatar' title='{{user.user.lastname}} {{user.user.firstname}}' data-mail='{{user.user.email}}' src='\\{{alias}}\\uploads\\avatar\\{{user.user.avatar}}'>"));
{%endif%}
{% endfor %}
$('#mymodal-sendmail').modal('show');
}
else {
if(data) {
event={mykey: "{{userkey}}", type: "add", message: data};
session.publish("websocket/channel/{{groupid}}", event);
CKEDITOR.instances["chat_message"].setData('');
event={type: "add", group:{{groupid}}};
parent.counter(event);
}
}
});
$( "#sendbtnmail" ).click(function() {
var data = CKEDITOR.instances["chat_messagemail"].getData();
var subject=$("#mailsuject").val();
var mailto=$("#mailto").val();
if(data&&subject&&mailto) {
event={mykey: "{{userkey}}", type: "add", message: data, mail: "true", to: mailto, subject: subject};
session.publish("websocket/channel/{{groupid}}", event);
CKEDITOR.instances["chat_message"].setData('');
event={type: "add", group:{{groupid}}};
parent.parent.counter(event);
}
parent.counter(event);
$('#mymodal-sendmail').modal('hide');
}
else alert("Sujet, corps et destinataire(s) obligatoire");
});
$(document).on('click', '.delmessage', function(){
id=$(this).data("id");
event={mykey: "{{userkey}}", type: "del", id: id};
session.publish("websocket/channel/{{groupid}}", event);
});
$(document).on('click', '#listtoavatar img', function(){
var mail = ";"+$(this).data("mail");
$("#mailto").val($("#mailto").val().replace(mail, ""));
$(this).remove();
});
})
{% endif %}

View File

@ -36,10 +36,8 @@ class WebsocketCounter implements TopicInterface
*/
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
$userid=$connection->userid;
//this will broadcast the message to ALL subscribers of this topic.
//$topic->broadcast(['log' => $connection->resourceId." has joined ".$topic->getId()." ".$userid]);
}
/**

View File

@ -88,6 +88,24 @@ class WebsocketTopic implements TopicInterface
if($group&&$usergroup&&$user) {
if($event["type"]=="add") {
if(array_key_exists("mail",$event)) {
$mail = $this->container->get('cadoles.core.service.mail');
if($mail) {
$mail_params=array(
"subject" => $event["subject"],
"body_html"=>$event["message"],
"body_text"=>strip_tags($event["message"])
);
// Transformer la liste des destinataires en tableau : [0] tjr vide on l'unset
$to=explode(";",$event["to"]);
unset($to[0]);
$mail->sendEmail("template", $mail_params, $to, $user->getEmail(), $user->getLastname()." ".$user->getFirstname());
$event["message"].="<br><i>Notification envoyée par mail</i>";
}
}
$message=new Message();
$message->setTopic($event["message"]);
$message->setUser($user);

View File

@ -1,5 +1,5 @@
server {
listen 5555 ssl;
listen %%ninegate_websocket_portexterne ssl;
ssl on;
ssl_certificate %%server_cert;
@ -19,6 +19,6 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://%%web_url:5556;
proxy_pass http://%%web_url:%%ninegate_websocket_portinterne;
}
}